Posts

Showing posts from December, 2008

Monitor Dual Master Mysql Replication

Here are shell script for monitoring replication, resetting replication if failed, logging if replication occured. Write a file name mysqlslave.sh on /tmp directory. #!/bin/sh user=mysql_root_username passwd=mysql_root_passwd repuser=mysql_replica_username reppasswd=mysql_replica_passwd GO=1 while [ $GO=1 ]; do rf=$(mktemp) /usr/local/mysql/bin/mysql -u$user -p$passwd -e "show slave status \G" > $rf 2>&1 repl_IO=$(cat $rf|grep "Slave_IO_Running"|cut -f2 -d':') repl_SQL=$(cat $rf|grep "Slave_SQL_Running"|cut -f2 -d':') if [ "$repl_IO" != " Yes" -o "$repl_SQL" != " Yes" ] ; then /usr/local/mysql/bin/mysql -u$user -p$passwd -e "stop slave" /usr/local/mysql/bin/mysql -u$user -p$passwd -e "reset slave" rg=$(mktemp) /usr/local/mysql/bin/mysql -hserverb -u$repuser -p$reppasswd -e "show master status \G" > $rg 2>&1 filemaster=$(cat $rg|grep "File"|cu

Dual Master Mysql Replication ( Circular Replication )

We have 2 servers that will be configured as Circular Replication. It means both servers act as master and slave to another server. After we install mysql-server on both servers, check /etc/hosts should be same as both servers. # more /etc/hosts 127.0.0.1 localhost 192.168.0.21 servera 192.168.0.22 serverb 192.168.0.23 dbhost After that try to look at /etc/my.cnf At Server A : # more /etc/my.cnf [MYSQLD] basedir = /usr/local/mysql datadir = /data/mysql/data max_connections=10000 default-character-set=utf8 default-collation=utf8_bin # InnoDB parameters set-variable = innodb_buffer_pool_size=1500M set-variable = innodb_additional_mem_pool_size=500M set-variable = innodb_log_buffer_size=10M log-bin binlog-do-db=test binlog-ignore-db=mysql server-id=1 replicate-same-server-id = 0 auto-increment_increment = 2 auto-increment_offset = 1 master-host = serverb master-user = replica master-password = slave123 master-port = 3306 expire_logs_days = 10 max_binlog_size = 500M [