Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mysql:replication [2008/09/03 18:57]
a
mysql:replication [2009/05/25 00:35] (current)
Line 66: Line 66:
    mysql -u user -ppassword    mysql -u user -ppassword
    mysql> START SLAVE;    mysql> START SLAVE;
 +
  
 ===== Master Master  ===== ===== Master Master  =====
  
-see [[http://www.howtoforge.com/mysql_master_master_replication|this]]+see **[[http://www.howtoforge.com/mysql_master_master_replication|this]]** for Step-by-step configuration. 
 + 
 + 
 +==== Script To Check If MySQL Master Master Replication Is Working Correctly ==== 
 + 
 +This short article explains how you can use a short script to check whether your MySQL master master replication is working as expected or not. 
 + 
 +First add a user named "check" with the following mysql queries: 
 + 
 +   CREATE USER 'check'@'localhost' IDENTIFIED BY 'YOURPASSWORD'; 
 + 
 +   GRANT SUPER , REPLICATION CLIENT ON * . * TO 'check'@'localhost' IDENTIFIED BY 'YOURPASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; 
 + 
 +Then add this bash script to your /root directory. Add it to your crontab if needed : 
 + 
 +<code bash|check-master-master.sh> 
 +#!/bin/bash 
 +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
 + 
 +###check if already notified### 
 +cd /root 
 +if [ -f slave_problem.txt ]; then 
 +  exit 1; 
 +fi
  
 +###Check if slave running###
 +(echo "show slave status \G;") | mysql -u check -pYOURPASSWORD 2>&1 | grep "Slave_IO_Running: No"
 +if [ "$?" -ne "1" ]; then
 +  echo "Replication failed" > /root/slave_problem.txt
 +fi
  
 +###Send notification if replication down###
 +cd /root
 +if [ -f slave_problem.txt ]; then
 +  mail -s "Replication problem" admin@example.com < /root/slave_problem.txt
 +fi
 +</code>
  
mysql/replication.1220461056.txt.gz · Last modified: 2009/05/25 00:34 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready