MySQL synchronization Configuration

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.