Revision [3672]
Last edited on 2010-03-16 00:55:38 by KenFongAdditions:
===Seeing difference with compression===
tcpdump -i eth0 -s 0 -l -w - dst port 3306
tcpdump -i eth0 -s 0 -l -w - dst port 3306
Revision [3671]
Edited on 2010-03-16 00:53:51 by KenFongAdditions:
slave_compressed_protocol=1
Revision [3659]
Edited on 2010-03-08 21:12:25 by WikiAdminAdditions:
replicate-wild-do-table=database1.%
Deletions:
replicate-do-db=database3
Revision [3445]
Edited on 2009-07-23 22:17:34 by WikiAdminAdditions:
# selectively replicate
# binlog-do-db=db_name
7.Restore snapsnot backup taken in step 1 to slave database. One can also use mysqldump-restore to achieve the same. dump with the --with-master-data option. then the master log position will be recorded in first 30 lines or so in the dump file.
# binlog-do-db=db_name
7.Restore snapsnot backup taken in step 1 to slave database. One can also use mysqldump-restore to achieve the same. dump with the --with-master-data option. then the master log position will be recorded in first 30 lines or so in the dump file.
Deletions:
Revision [2234]
Edited on 2009-02-26 02:15:23 by WikiAdminAdditions:
# rename relay-log.info which contains info about the problematic relay log
Revision [2208]
Edited on 2009-02-16 03:04:23 by WikiAdminAdditions:
===Fix broken relay logs===
You may instruct mysql to purge current relay logs and restart replication at a certain point. See the following example:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
...
Master_Log_File: db01-bin.000009
Read_Master_Log_Pos: 127484667
Relay_Log_File: ws01-relay.000032
Relay_Log_Pos: 115781533
Relay_Master_Log_File: db01-bin.000009 <-- set master_log_file to this
Slave_IO_Running: No
Slave_SQL_Running: No
...
Exec_Master_Log_Pos: 115781384 <-- set master_log_pos to this
...
1 row in set (0.92 sec)
mysql> stop slave
mysql> change master to master_log_file='db01-bin.000009', master_log_pos=115781384;
mysql> start slave
You may instruct mysql to purge current relay logs and restart replication at a certain point. See the following example:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
...
Master_Log_File: db01-bin.000009
Read_Master_Log_Pos: 127484667
Relay_Log_File: ws01-relay.000032
Relay_Log_Pos: 115781533
Relay_Master_Log_File: db01-bin.000009 <-- set master_log_file to this
Slave_IO_Running: No
Slave_SQL_Running: No
...
Exec_Master_Log_Pos: 115781384 <-- set master_log_pos to this
...
1 row in set (0.92 sec)
mysql> stop slave
mysql> change master to master_log_file='db01-bin.000009', master_log_pos=115781384;
mysql> start slave
Revision [2085]
Edited on 2008-11-07 02:28:18 by WikiAdminAdditions:
log-bin=hostname-bin
relay-log=hostname-relay
relay-log=hostname-relay
Deletions:
Revision [2066]
Edited on 2008-11-03 00:13:58 by WikiAdminAdditions:
==Missing relay logs==
What if your relay logs are missing? As long as the binlogs are still here, one can do the followings and mysql will fetch fresh copies of relay logs automatically:
service mysql stop
rm -f $MYSQL_DATADIR/relay-log.info
rm -f $MYSQL_RELAYLOG/hostname-relay-bin.*
service mysql start
What if your relay logs are missing? As long as the binlogs are still here, one can do the followings and mysql will fetch fresh copies of relay logs automatically:
service mysql stop
rm -f $MYSQL_DATADIR/relay-log.info
rm -f $MYSQL_RELAYLOG/hostname-relay-bin.*
service mysql start
Revision [1917]
Edited on 2008-09-01 22:04:44 by WikiAdminAdditions:
log_slave_updates=1
read_only=1
read_only=1
Revision [1781]
Edited on 2008-06-30 08:48:38 by WikiAdminAdditions:
Some poorly designed software do uses custom functions for primary key and they may cause duplicate entry error when that function generates repeated string as the key. The following tells MySQL to ignore duplicate entry error and move on.
%%(text;my.cnf)
slave-skip-errors = 1062
%%(text;my.cnf)
slave-skip-errors = 1062
Revision [1746]
Edited on 2008-06-02 21:34:55 by WikiAdminAdditions:
MYSQL>grant replication [slave] on *.* to repl@'%' identified by 'blah';
Deletions:
Revision [1621]
Edited on 2008-04-08 00:56:02 by WikiAdminAdditions:
==Fix broken replication==
If replication is stalled because of a query does not run on slave and you are sure that query is of no significance, do these:
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
mysql> START SLAVE;
If replication is stalled because of a query does not run on slave and you are sure that query is of no significance, do these:
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
mysql> START SLAVE;
Revision [1577]
Edited on 2008-03-31 01:17:58 by WikiAdminAdditions:
Fix broken replication: http://homepage.mac.com/kelleherk/iblog/C711669388/E226281480/index.html
# master logs are applied to slave and can be purged
mysql -p$SHARED_PWD -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
# master logs are applied to slave and can be purged
mysql -p$SHARED_PWD -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
Deletions:
mysql -p$SHARED_PWD -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
Revision [1490]
Edited on 2008-03-13 02:17:36 by WikiAdminAdditions:
Do it with mysqldump: http://www.onlamp.com/pub/a/onlamp/2005/06/16/MySQLian.html
Revision [1426]
Edited on 2008-02-29 20:05:08 by WikiAdminAdditions:
# In the reversed case, where you want to exclude certain databases
# from being replicated:
replicate-ignore-db=database_tmp
replicate-ignore-db=user_tmp
# from being replicated:
replicate-ignore-db=database_tmp
replicate-ignore-db=user_tmp
Revision [1413]
Edited on 2008-02-20 20:38:13 by WikiAdminAdditions:
exit 0
Deletions:
Revision [1412]
Edited on 2008-02-20 20:37:25 by WikiAdminAdditions:
#!/bin/bash
# maintained by kfong@datapipe.com
SLAVE_LOG="" SHARED_PWD="j4s0n1"
MASTER_LOG=`mysql -p$SHARED_PWD -h$MASTER_HOST -se "show master status\G" | grep File | awk '{print $2}'`
if [ $MASTER_LOG == $SLAVE_LOG ]; then
mysql -p$SHARED_PWD -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
# maintained by kfong@datapipe.com
SLAVE_LOG="" SHARED_PWD="j4s0n1"
MASTER_LOG=`mysql -p$SHARED_PWD -h$MASTER_HOST -se "show master status\G" | grep File | awk '{print $2}'`
if [ $MASTER_LOG == $SLAVE_LOG ]; then
mysql -p$SHARED_PWD -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
Deletions:
SLAVE_LOG=""
SHARED_PWD="xxx"
MASTER_LOG=`mysql -p$SHARED_PWD -h$MASTER_HOST -se "show master status\G" | grep File | awk '{print $2}'`
if [ $MASTER_LOG == $SLAVE_LOG ]; then
mysql -pw8TnG4Tn1t -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
Revision [1393]
Edited on 2008-02-11 19:57:41 by WikiAdminAdditions:
#/bin/bash
MASTER_HOST=""
MASTER_LOG=""
SLAVE_LOG=""
SHARED_PWD="xxx"
MASTER_HOST=`mysql -p$SHARED_PWD -se "show slave status\G" | grep Master_Host | awk '{print $2}'`
MASTER_LOG=`mysql -p$SHARED_PWD -h$MASTER_HOST -se "show master status\G" | grep File | awk '{print $2}'`
SLAVE_LOG=`mysql -p$SHARED_PWD -se "show slave status\G" | grep Master_Log_File | awk '{print $2}' | head -1`
echo MASTER: $MASTER_HOST
echo MASTER_LOG: $MASTER_LOG
echo SLAVE_LOG: $SLAVE_LOG
if [ $MASTER_LOG == $SLAVE_LOG ]; then
# master logs are applied to slave and can be purged
mysql -pw8TnG4Tn1t -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
fi
exit0
MASTER_HOST=""
MASTER_LOG=""
SLAVE_LOG=""
SHARED_PWD="xxx"
MASTER_HOST=`mysql -p$SHARED_PWD -se "show slave status\G" | grep Master_Host | awk '{print $2}'`
MASTER_LOG=`mysql -p$SHARED_PWD -h$MASTER_HOST -se "show master status\G" | grep File | awk '{print $2}'`
SLAVE_LOG=`mysql -p$SHARED_PWD -se "show slave status\G" | grep Master_Log_File | awk '{print $2}' | head -1`
echo MASTER: $MASTER_HOST
echo MASTER_LOG: $MASTER_LOG
echo SLAVE_LOG: $SLAVE_LOG
if [ $MASTER_LOG == $SLAVE_LOG ]; then
# master logs are applied to slave and can be purged
mysql -pw8TnG4Tn1t -h$MASTER_HOST -se "purge master logs to '$MASTER_LOG'"
fi
exit0
Deletions:
# Get last applied log from slave
SLAVELOG=`mysql -hslave.domain.com -uroot -pXXX -Nse "show slave status\G" | grep "Master_Log_File" | head -1 | awk '{print $2}'`
echo "Purging master logs up to $SLAVELOG"
mysql -uroot -pXXX -Nse "purge master logs to '$SLAVELOG'"
exit 0
Revision [1243]
Edited on 2007-12-30 18:06:51 by WikiAdminAdditions:
replicate-do-db=database1
replicate-do-db=database2
replicate-do-db=database3
replicate-do-db=database2
replicate-do-db=database3
Deletions:
replicate-do-db=new_kayako
replicate-do-db=wpdfd