Assume that the data in the test database is to be synchronized, but the test. secret table is not synchronized.
A. Perform the backup operation and refresh the log on rdb1.
Mysqldump -- flush-logs-uroot-p $ pwd -- default-character-set = gbk -- database test> test. 'date + % Y % m % D'. SQL
B. Connect to the RDB1.Mysql database to query the current log file and log location information.
Mysql> show master status;
+ ------------------ + ----------- + -------------- + ------------------ +
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+ ------------------ + ----------- + -------------- + ------------------ +
| Mysql-bin.000156 | 98 |
+ ------------------ + ----------- + -------------- + ------------------ +
1 row in set
C. Configure new user authorization for RDB2 on RDB1
Grant replication slave on *. * TO backup @ 'rdb2 ip' identified by 'Password ';
D. Upload the complete data backed up from RDB1 to RDB2 through scp and import the data to the database.
Mysql-h localhost-uroot-p $ pwd test <test. 'date + % Y % m % D'. SQL
E. After the import is complete, set the synchronization parameters.
Set the databases to be synchronized, tables to be synchronized, and tables to be ignored.
For example, in the Mysql configuration file of RDB2, configure:
Replicate-do-db = test
Replicate-ignore-table = test. secret
Note: ensure that all server-IDs are not repeated. RDB1 is 1, RDB2 is 2, and the rest are arranged in sequence.
F. Restart RDB2.MYSQL to make the configuration take effect. log on to RDB2.MYSQL to set the log replication start point.
Change master to MASTER_HOST = 'rdb1 ip', MASTER_USER = 'backup ', MASTER_PASSWORD = 'Password', MASTER_LOG_FILE = 'mysql-bin.000156', MASTER_LOG_POS = 98;
Run start slave to START the synchronization service.
So far, the master-slave synchronization from RDB1 to RDB2 has been completed.