본문 바로가기

Technical/DBMS

MySQL replication 수동 복구(Slave 동기화) #2

반응형

Full dump 파일이 100MB 이상 되면 slave 에서 로드하다보면 제대로 되는지 확인이 안되서
시간은 급한데 억장이 무너진다면 아래의 방법을 써본다.

* Master: 10.10.0.200, Slave: 10.10.0.201

1. Master database read lock
# mysql -uroot -prootpass
<Master> flush logs;
<Master> flush tables with read lock;

2. Rsync from master to slave(Slave)
# mysqladmin -uroot -prootpass shutdown
# rm -rf /user/services/mysql/data/*
# rsync -r -p -v root@10.10.0.200:/user/service/mysql/data /user/service/mysql/

* Check my.cnf
server-id=2 (or other number, not 1)
master-host=10.10.0.200
master-user=root
master-password=rootpass

# chown -R mysql.mysql /user/service/mysql/data
# mysqld_safe --user=mysql --log-bin-trust-function-creators=1 --skip-slave --relay-log=mysql-relay-bin &
# mysql -uroot -prootpass
<Slave> stop slave;
<Slave> reset slave;

3. Reset master & start slave thread
<Master> unlock tables;
<Master> reset master; -- purge all log-bins
<Master> show master status;
<Slave> start slave;
<Slave> show slave status;

* Slave_IO_State : Waiting for master to send event, Master_Host : master_ip, ... => Successful 


- Barracuda -


반응형