Skip to main content

Posts

Showing posts from June, 2012

MySQL Enterprise Monitoring Agent Installation

Mysql monitor is the nagios of Database. It is especially useful when you have a bunch of mysql DB servers to manage. http://www.mysql.com/products/enterprise/monitor.html Here are 8 steps to enable the monitoring agent on the DB server. It is assumed that the monitor server is already configured and active on a server (for e.g. 10.10.10.63) 1) sudo root 2) download agent 3) Change file permissions chmod +x mysqlmonitoragent-2.3.1.2044-linux-glibc2.3-x86-64bit-installer.bin 4) Run file [root@localhost]# ./mysqlmonitoragent-2.3.1.2044-linux-glibc2.3-x86-64bit-installer.bin 5) Start agent /etc/init.d/mysql-monitor-agent start 6) check status ps -ef | grep monitor 7) check log cat /opt/mysql/enterprise/agent/mysql-monitor-agent.log 8) create mysql user for e.g. mysql> grant all on *.* to 'agent'@'%' identified by 'agent'; _____ The following options must be selected very carefully or else monitor will not work as expected. Instal...

MySQL Resetting root password

If you have forgotten your root password, you will need to start mysql service with --skip-grant-tables mode and then run the following 2 commands to reset it to root / root@123 UPDATE mysql.user SET Password = password('root@123') WHERE Host = 'localhost' AND User = 'root'; REPLACE INTO mysql.user VALUES ('%','root','*A00C34073A26B40AB4307650BFB9309D6BFA6999', 'Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','','','','', 0,0,0,0,'',''); You may now remove the skip grant tables option and restart mysql service. I assume you are not using old-passwords option in my.cnf that makes it compa...

MySQL start new instance with new data-directory

Sometimes you need fresh mysql installation. You need to run script to create default mysql database and system tables. The script is called "mysql_install_db" and is either in the bin or in scripts directory of your mysql installation. Change the my.cnf to reflect new datadir and run mysql_install_db for it to create mysql database and system tables in the new datatir and then start mysqld_safe. /usr/bin/mysql_install_db --datadir=/mnt/mysql3310 

MySQL Master Slave Replication on Linux Environment

1) Check if the server-id variable is set in my.cnf on both master and slave. If the IP is 192.178.90.51 then the id can be server-id=1789051 # config on master server to start binary logs log-bin=/var/log/mysql/mysql-bin.log max_binlog_size=1024M expire_logs_days=40 2) Take backup of master server using the following command or set it in a cron: 50 13 * * * /usr/bin/mysqldump -uroot -pPassWord dbName --routines --single-transaction --master-data=2 > /backup/dumpmysqldaily/ACCNT`date +'%d-%b-%Y-%H-%M'`.sql 2> /backup/dumpmysqldaily/ACCNT_err.txt 3) Create a "slave_user" user for replication purpose on the slave. GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'slave_user'; 4) Copy the dump file from master to slave. Restore the dump on slave server mysql -uroot -pPassWord myDBname < /root/ACCNT07-Jan-2010-11-30.sql Do not forget to turn off binary/ slow/ general logs of slave server. The logging may...

Mysql Script to install and run mysql instance on linux box

Here is the shell script that will install mysql version 5.5 on a new instance. sh -xv /root/clean_install.sh The mysql data directory (/data/mysql/jun19) should be changed in 2 places. #!/bin/sh ## disable selinux /usr/sbin/setenforce 0 ## shut-down mysql if already running mysqladmin shutdown # remove old data directory rm -rf /var/lib/mysql/ rm -rf /root/download ## create required directories # datadir mkdir -p /data/mysql/jun19 # pid directory mkdir -p /var/run/mysql # default socket directory mkdir -p /var/lib/mysql # download directory mkdir /root/download cd /root/download wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-client-5.5.20-1.linux2.6.x86_64.rpm wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-devel-5.5.20-1.linux2.6.x86_64.rpm wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-server-5.5.20-1.linux2.6.x86_64.rpm wget http://files.directadmin.com/services/all/mysq...

MySQL Multi-Master Replication Manager

MMM  ( M ulti- M aster Replication  M anager for  MySQL ) is a set of flexible scripts to perform monitoring/failover and management of  MySQL  master-master replication configurations (with only one node writable at any time). The toolset also has the ability to read balance standard master/slave configurations with any number of slaves, so you can use it to move virtual IP addresses around a group of servers depending on whether they are behind  in  replication. The current version of this software is stable, but the authors would appreciate any comments, suggestions, bug reports about this version to make it even better. Current version 2.0 development is led by Pascal Hofmann. If you require support, advice or assistance with deployment, please contact  Percona  or  Open Query . Latest bugs (2.x) [911277] Monitor sets ip first after changing state from ADMIN_OFFLINE to ONLINE [897099] the value of auto_set_online is ...