Reference: http: //blog.51cto.com/13407306/2067333
From the re-call the shots, fully synchronized ? ( This method is applicable to the main library data from large difference, or requested data situation is completely unified? )
1. Advanced White library, a lock table to prevent data writing (after it's happened remember unlock unlock tables)
use the command:?
MySQL-uroot--proot_neu -P33061 -S /tmp/mysql_33061.sock
MySQL> flush the Tables with the Read Lock; ?
Note: there is a lock for the read-only statements are not case-sensitive?
2. Data Backup?
# Mysql.bak.sql to back up data to a file?
[root@server01 mysql]# mysqldump -uroot -P33061 -S /tmp/mysql_33061.sock -proot --all-databases --default-character-set=utf8 > mysql.bak.sql?
3. The mysql database backup files to the machine, data recovery?
# Use scp command?
[Root @ server01 mysql] # scp * .sql [email protected] mysql: / root /?
4. Stop from the state library (reset master;? Reset slave; must be executed from the library, not the whole wrong)
mysql -uroot -proot_neu -P33062 -S /tmp/mysql_33062.sock
mysql> stop slave;?
mysql> reset master;?
mysql> reset slave;
5. Then to execute mysql command from the library, import data backup?
mysql> /root/source mysql.bak.sql?
6. Check the main library master status?
mysql> show master status\G;?
*************************** 1. row ***************************
? ? ? ? ? ? ?File: mysql-bin.000010
? ? ? ? ?Position: 157229134
7. Set up sync from the library, pay attention to where the synchronization point, is step 6, the main library show master status \ G information in the | File | Position two?
change master to master_host='133.813.933.183',master_port=33061,master_user='repl',master_password='*****' ,master_log_file='mysql-bin.000010', master_log_pos=157229134 FOR CHANNEL 'M1';
8. Turn sync back from the library?mysql> start slave;?
9. Check the synchronization status?
MySQL> Show Slave Status \ G View:?
Slave_IO_Running: Yes?
Slave_SQL_Running: Yes?
-uroot mysql -proot_neu -P33061 -S /tmp/mysql_33061.sock -e " CREATE DATABASE mydb; CREATE TABLE mydb.mytab (id INT AUTO_INCREMENT, port INT, PRIMARY KEY (id));"?
mysql -uroot -proot_neu -P33061 -S /tmp/mysql_33061.sock ?-e "DESC mydb.mytab;"
mysql -uroot -proot_neu -P33062 -S /tmp/mysql_33062.sock ?-e "DESC mydb.mytab;"