How To Repair MySQL Replication | HowtoForge - Linux Howtos and Tutorials

Register

Login

Contribute

Subscribe

RSS

Howtos

Forums

Contribute

Subscribe

ISPConfig

FAQForge

News

Options For This Howto
q q

English |

Deutsch | Site Map/RSS Feeds | Advertise

Free Support Paid Support

Navigation
[+] Expand [-] Collapse

Home » Howtos » MySQL» How To Repair MySQL Replication

How To Repair MySQL Replication

Howtos Linux
s

Want to support HowtoForge? Become a subscriber!

Android CentOS Debian Fedora Kernel Mandriva PCLinuxOS SuSE Ubuntu Web Server Apache Cherokee Lighttpd nginx Backup Control Panels ISPConfig DNS BIND MyDNS PowerDNS djbdns Desktop Email
q

s

s

s

s

s

s

s

s

s

s

s

s

r

Submitted by falko (Contact Author) (Forums) on Fri, 2008-06-06 12:10. :: MySQL

s

q

q

s

How To Repair MySQL Replication
Version 1.0 Author: Falko Timme <ft [at] falkotimme [dot] com> Last edited 05/29/2008

s

s

s

r

http://www.howtoforge.com/how-to-repair-mysql-replication (1 of 12)16/04/12 22:32:01

for example. To verify that the replication is really not working. In this short guide I explain how you can repair the replication on the MySQL slave without the need to set it up from scratch again. taggregate_temp_1212047760' doesn't exist' on query. row *************************** Slave_IO_State: Waiting for master to send event Log in Create a new account Request new password http://www.Linux Howtos and Tutorials s Anti-Spam/Virus Postfix FTP High-Availability Monitoring MySQL Programming C/C++ PHP Samba Security Anti-Spam/Virus Storage Virtualization KVM OpenVZ VMware VirtualBox Xen Other FreeBSD Commercial Mini-Howtos s r r If you have set up MySQL replication. log in to MySQL: s s r r r q Forums Contribute q Subscription Login Site Map/RSS Feeds q q mysql -u root -p User login Username: On the MySQL shell. MySQL logs to /var/log/syslog: r s r grep mysql /var/log/syslog s s s server1:/home/admin# grep mysql /var/log/syslog May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Slave: Error 'Table 'mydb. you probably know this problem: sometimes there are invalid MySQL queries which cause the replication to not work anymore. then the replication is broken: mysql> SHOW SLAVE STATUS \G *************************** 1.001079' position 203015142 server1:/home/admin# You can see what query caused the error.views May 29 09:56:08 http2 mysqld[1380]: ^IWHERE thread. Fix the problem.threadid'. I do not issue any guarantee that this will work for you! r r s s 1 Identifying The Problem To find out whether replication is/is not working and what has caused to stop it. slave SQL thread aborted.com/how-to-repair-mysql-replication (2 of 12)16/04/12 22:32:01 .taggregate_temp_1212047760 AS aggregate May 29 09:56:08 http2 mysqld[1380]: ^ISET thread.How To Repair MySQL Replication | HowtoForge . We stopped at log 'mysql-bin.threadid = aggregate. Error_code: 1146 May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Error running query. run: mysql> SHOW SLAVE STATUS \G Password: Remember Me? If one of Slave_IO_Running or Slave_SQL_Running is set to No.views = thread.howtoforge. On Debian. and restart the slave SQL thread with "SLAVE START". you can take a look at the logs.views + aggregate. Default database: 'mydb'. Query: 'UPDATE thread AS thread. and at what log position the replication stopped.

views WHERE thread..000130 Relay_Log_Pos: 100125935 Relay_Master_Log_File: mysql-bin.How To Repair MySQL Replication | HowtoForge .001079 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: mydb Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1146 Last_Error: Error 'Table 'mydb.10 .com/how-to-repair-mysql-replication (3 of 12)16/04/12 22:32:01 .taggregate_temp_1212047760 AS aggregate SET thread.. Default database: 'mydb'.Linux Howtos and Tutorials Facebook Who's online There are currently 4 users and 3310 guests online.2.views + aggregate.howtoforge. 16 April 2012 Larry vs Larry: Oracle and Google in courtroom smackdown q 2 Repairing The Replication Just to go sure.001079 Read_Master_Log_Pos: 269214454 Relay_Log_File: slave-relay..2 . Query: 'UPDATE thread AS thread.Problem with hdds Mail and FTP doesn´t work ISPConfig 3 Centos 6 Slow Sites Problem with adding new mail adresses q q q q q q q q q News q DistroWatch Weekly.Sites Display . Master_Host: 1.10 with icinga monitorin ubuntu 11.threadid' Skip_Counter: 0 Exec_Master_Log_Pos: 203015142 Relay_Log_Space: 166325247 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL 1 row in set (0. we stop the slave: http://www. Install horde ISPConfig Not Recognized .4 Master_User: slave_user Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.views = thread... Issue 452.00 sec) mysql> HowtoForge Forums q Ubuntu 11.Shows Same Content Unable to connect to the specified MySQL server . VMWARE . Problem with my VPS and /etc/fstab 2 Sites On ISPConfig .threadid = aggregate..Centos 6.3. taggregate_temp_1212047760' doesn't exist' on query.

. q This tells the slave to skip one query (which is the invalid one that caused the replication to stop). That's it already. q q q q q q Fixing the problem is actually quite easy. q .. Issue 195 RSSOwl 2.com/how-to-repair-mysql-replication (4 of 12)16/04/12 22:32:01 . row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 1. We tell the slave to simply skip the invalid SQL query: Recent comments q bin file problem 1 day 3 hours ago Do I need to format/clean the hard drive before replacing? 1 day 5 hours ago Thank you very much! 1 day 6 hours ago Missing package dovecotmysql 2 days 12 hours ago How to Running Drupal on Nginx + php-fpm + apc in Russian 2 days 13 hours ago Re: Working solution without reinstalling anything 3 days 7 hours ago Re: SSL? 3 days 8 hours ago Re: Re: using OTP and nonOTP simultaneously 3 days 8 hours ago Re: re:Install and Configure mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1. If you'd like to skip two queries.4 Master_User: slave_user q q http://www.2: The Best News Feed Reader for Ubuntu/ Linux more q mysql> STOP SLAVE. and check if replication is working again: q mysql> SHOW SLAVE STATUS \G q mysql> SHOW SLAVE STATUS \G *************************** 1. Now we can start the slave again.How To Repair MySQL Replication | HowtoForge . q q mysql> START SLAVE.1... you'd use SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2. instead and so on.Linux Howtos and Tutorials q Don't forget the newbies! An OS in the Public Interest a Mandriva Linux Foundation? LibreOffice Tips: Inserting Qur’an text in LibreOffice Writer Latest Release Of Linux Contains Code Developed Via Google Plus Interview with Aviv Sharon of Wildfire Games How to easily create your own Google Chrome theme Softpedia Linux Weekly.howtoforge.2.3.

Now leave the MySQL shell.000130 225644062 mysql-bin.) mysql> quit. both Slave_IO_Running and Slave_SQL_Running are set to Yes now.com/how-to-repair-mysql-replication (5 of 12)16/04/12 22:32:01 ..Linux Howtos and Tutorials OpenLDAP on Ubuntu Karmic Koala 3 days 12 hours ago q Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.00 sec) mysql> As you see.How To Repair MySQL Replication | HowtoForge . visit this link. .001079 A GREAT TUTORIAL THAT WORKS!!! STRANGE 3 days 13 hours ago Newsletter Subscribe to HowtoForge Newsletter and stay informed about our latest HOWTOs and projects. Submit (To unsubscribe from our newsletter. and check the log again: grep mysql /var/log/syslog http://www..001079 Read_Master_Log_Pos: Relay_Log_File: Relay_Log_Pos: Relay_Master_Log_File: 447560366 slave-relay.. enter email address Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: mydb Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 447560366 Relay_Log_Space: 225644062 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 1 row in set (0.howtoforge..

taggregate_temp_1212047760' doesn't exist' on query. and restart the slave SQL thread with "SLAVE START".views + aggregate. 3 Links q MySQL: http://www.threadid = aggregate.views May 29 09:56:08 http2 mysqld[1380]: ^IWHERE thread.001079' at position 203015142.I am waiting for your http://www. everything is ok. We stopped at log 'mysql-bin. q q q add comment | view as pdf | print Related Tutorials q Setting Up Master-Master Replication With MySQL 5 On Debian Etch Master-Master Replication With MySQL 5 On Fedora 8 How To Set Up Database Replication In MySQL Please do not use the comment function to ask for help! If you need help. Query: 'UPDATE thread AS thread. Default database: 'mydb'.How To Repair MySQL Replication | HowtoForge .views = thread. Please help me.taggregate_temp_1212047760 AS aggregate May 29 09:56:08 http2 mysqld[1380]: ^ISET thread.com Copyright © 2008 Falko Timme All Rights Reserved.001079' position 203015142 May 29 11:42:13 http2 mysqld[1380]: 080529 11:42:13 [Note] Slave SQL thread initialized.Linux Howtos and Tutorials server1:/home/admin# grep mysql /var/log/syslog May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Slave: Error 'Table 'mydb. q q Slave_IO_Running: No and Seconds_Behind_Master: NULL Submitted by Ramanath (not registered) on Mon.mysql. starting replication in log 'mysql-bin. Comments will be published after administrator approval. What i have to do if Slave_IO_Running: No and Seconds_Behind_Master: NULL. 2011-03-14 11:13.threadid'. relay log '/var/lib/mysql/slave-relay. please use our forum.000130' position: 100125935 server1:/home/admin# The last line says that replication has started again.com/how-to-repair-mysql-replication (6 of 12)16/04/12 22:32:01 . Error_code: 1146 May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Error running query. and if you see no errors after that line. slave SQL thread aborted.howtoforge. Fix the problem.

reply | view as pdf Be careful.com/how-to-repair-mysql-replication (7 of 12)16/04/12 22:32:01 ..howtoforge. I got replication working Submitted by Farshid (not registered) on Sat.howtoforge.. Thank you. I got replication working without having to rebuild in middle of night remotely! reply | view as pdf Thanks Submitted by sureshkumar (not registered) on Fri. but we are missing your proposed solution http://www.. Thanks. 2009-01-15 16:51. this is sometimes necessary. noted that this is not the proper "fix" for the problem..How To Repair MySQL Replication | HowtoForge . http://www. then the problems go much deeper than merely broken replication.Please suggest me for Slave_IO_Running: No and Seconds_Behind_Master: NULL reply | view as pdf Thank you.. 2009-11-24 07:42.. 2010-10-23 23:13. though. reply | view as pdf Re: Be careful..com/how-to-repair-mysql-replication.... but if it is a recurring issue. Bear in mind that any time you have a query which *did* successfully execute on the master and is skipped on the slave and you use a SQL_SLAVE_SKIP_COUNTER method to "fix" the problem. Submitted by Anonymous (not registered) on Tue. though.Linux Howtos and Tutorials response..... Yes. In this link you have mentioned the solution for Slave_SQL_Running: No. 2009-07-03 10:46. Submitted by Richard (not registered) on Thu. your master and slave are now no longer in sync.. Good work ..

. though.. Submitted by Anonymous (not registered) on Thu.. reply | view as pdf Re: Be careful. This isn't fixing.Linux Howtos and Tutorials reply | view as pdf Re: Be careful. it's just brushing the problem under the carpet and hoping it goes away.com/how-to-repair-mysql-replication (8 of 12)16/04/12 22:32:01 . and be sure its absence won't cause future queries to fail reply | view as pdf Automated Script Inquiry Submitted by Perry Whelan (not registered) on Wed. ## Set to run from cron once a minute.sh > /dev/null 2>&1 # Last updated: MM/DD/YYYY COMMANDS="mysql grep awk logger" export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' for i in $COMMANDS http://www. Submitted by Anonymous (not registered) on Sun. And if you skip a query to 'fix' the replication. Indeed. If you must skip a query. though. look at the query first. I've written a cron script to manage the situation. 2009-01-18 01:43. So.howtoforge.mysql. I'm managing an infrastructure with a number of databases who (for codified reasons that I cannot influence) suffer from this situation often.How To Repair MySQL Replication | HowtoForge . 2008-10-22 17:32. you run the very serious risk that the replication will become even more out of sync further down the line. sometimes the slave will try to execute things that don't apply like a "drop trigger" statement for a trigger that doesn't ever exist because the slave is only replicating specific tables.. # */1 * * * * /usr/local/bin/whipSlave. 2009-01-29 21:20. but. Does anyone see any foreseeable issues with this logic (see below)? #!/bin/bash ## Tool to unstick MySQL Replicators. True.

START SLAVE..com/how-to-repair-mysql-replication (9 of 12)16/04/12 22:32:01 .Linux Howtos and Tutorials do X=`echo $i | tr '[a-z]' '[A-Z]'` export $X=`type -p $i` done # Define variables USERNAME=dbuser PASSWORD=password # Define Functions ## Obtain MwSQL slave server status function SLAVE() { STATUS=`$MYSQL -u $USERNAME -p$PASSWORD -e \ "SHOW SLAVE STATUS \G" | $GREP Seconds_Behind_Master | $AWK '{print $2}'` } ## Skip errors function UNSTICK() { $MYSQL -u $USERNAME -p$PASSWORD -e \ "STOP SLAVE." sleep 5 # Check everything again CHECK } ## Decide what to do. Fixing...howtoforge." | $LOGGER UNSTICK else # Everything should be fine http://www. SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1. function CHECK() { # Obtain status SLAVE if [ $STATUS = NULL ] then # I think the replicator is broken echo "MySQL Slave database is not replicating..How To Repair MySQL Replication | HowtoForge .

2009-01-15 17:33. I believe): #!/bin/bash done=0 while [ $done -eq 0 ].' | tail -1 | cut -f12 | grep Yes | wc -l ) if [ $done -eq 0 ].let's not do anything. then. do # get status done=$( mysql -Be 'show slave status.0+.' | tail -1 | cut http://www.howtoforge." | $LOGGER fi } ## Are we running? function ALIVE() { UP=`$MYSQL -u $USERNAME -p$PASSWORD -e \ "SHOW SLAVE STATUS \G" | $GREP Slave_IO_Running | $AWK '{print $2}'` if [ $UP = Yes ] then # Let's check if everything is good.com/how-to-repair-mysql-replication (10 of 12)16/04/12 22:32:01 . CHECK else # Uh oh. echo "MySQL Slave IO is not running!" | $LOGGER exit 1 fi } # How is everything? ALIVE #EoF exit 0 reply | view as pdf Re: Automated Script Inquiry Submitted by Jeff Buchbinder (not registered) on Thu.How To Repair MySQL Replication | HowtoForge .... This might be a little bit simpler (works with MySQL 5.Linux Howtos and Tutorials echo "MySQL Slave is $STATUS seconds behind its Master. then echo "Advancing position past [$(mysql -Be 'show slave status..

echo "All set" reply | view as pdf Howtos | Mini-Howtos | Forums | News | Search | Contribute | Subscription Site Map/RSS Feeds | Advertise | Contact | Disclaimer | Imprint http://www. 2011-10-01 14:42.Linux Howtos and Tutorials f20)].." sleep 1 fi done reply | view as pdf Re: Re: Automated Script Inquiry Submitted by Anonymous (not registered) on Sat.'`" ] do echo "Skipped one Error" sleep 1 done .How To Repair MySQL Replication | HowtoForge .. start slave.com/how-to-repair-mysql-replication (11 of 12)16/04/12 22:32:01 . " mysql -uroot -Be "SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1. start slave.howtoforge. while [ ! "`mysql -uroot -Be 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1.

Linux Howtos and Tutorials All Rights Reserved.howtoforge.How To Repair MySQL Replication | HowtoForge .com/how-to-repair-mysql-replication (12 of 12)16/04/12 22:32:01 .Linux Howtos and Tutorials Copyright © 2012 HowtoForge . http://www.

Sign up to vote on this title
UsefulNot useful