Reset db slave

Some old data were missingon db slave server

copy data from master db01.lalife.net to slave db02.lalife.net and reset slave

On Master:

Lock table

mysql> FLUSH TABLES WITH READ LOCK;

mysql> show master status;

+——————+———-+————–+——————+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+——————+———-+————–+——————+

| db01-bin.000901 | 84861692 |              |                  |

+——————+———-+————–+——————+

cd /var/lib

tar cvfz  TARFILE_NAME.tgz mysql/

mysql > unlock tables;

On Slave:

cd /var/tmp/

tar -zxvf db01_bk.tar.gz

service mysql stop

##backup old db

mv /www/mysql /www/mysql0603

mv /var/tmp/www/mysql/ /www/

service mysql start

mysql>STOP SLAVE;

mysql>RESET SLAVE;

mysql> CHANGE MASTER TO MASTER_HOST=’db001.lalife.net’, MASTER_USER=’replication’, MASTER_PASSWORD=’xxxxx’, MASTER_LOG_FILE=’db01-bin.000900′, MASTER_LOG_POS=13482116;

mysql>START SLAVE;

How to get master bin file and position:

On master server

mysql> show master status;
+——————+———–+————–+——————+
| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———–+————–+——————+
| db01-bin.000900 | 437292441 |              |                  |
+——————+———–+————–+——————+

Leave a Reply

Your email address will not be published.