8. mysql dual-host Master/Slave, mysql dual-host

Source: Internet
Author: User

8. mysql dual-host Master/Slave, mysql dual-host

In this era of data explosion, data backup is the most important thing for every company. As a data storage warehouse, the importance of database is self-evident. Major databases include: 1. Large database oracle 2. Medium SQL server 3. Small database mysql. It can be said that each has its own advantages, and I will not go into details here.

Mysql dual-host master/backup is to write all the data in the primary database to the backup database to achieve hot backup of the mysql database.

I. preparation:

To implement dual-host master/backup, the versions of the two machines must be the same, or the version of the master machine is low. Otherwise, the two machines cannot succeed. Therefore, the same version of mysql is installed on the two machines.

1. 192.168.1.111 master

2. 192.168.1.112 from

Ii. Configuration:

Modify the mysql configuration file: when the path here is/etc/mysql/my. cnf

1. Master

[Mysqld]

Server-id = 1

Log-bin = mysql-bin

Binlog-do-db = test // database to be backed up

Binlog-ignore-db = mysql // database that is not backed up

2. Slave

[Mysqld]

Server-id = 2 // another server is 3, which cannot be the same

Log-bin = mysql-bin

Replicate-do-db = test // database to be backed up

Replicate-ignore-db = mysql // do not back up the database

3. Both the master and slave mysql instances must be restarted.

Iii. Synchronization:

1. Master

Log on to the master using root,

Mysql> grant replication slave on *. * to 'Here is the Login User' @ 192.168.1.20.identified by 'your password'

Mysql> flush privileges;

Mysql> show master status; displays the following


2. Slave

Log On with root

Mysql> stop slave; // stop slave first

Mysql> change master

> Master_host = '1970. 168.1.111 ',

> Master_user = 'your logon account ',

> Master_password = 'Password ',

> Master_log_file = 'mysql-bin.000199 ',

> Master_log_pos = 1321;

Mysql> start slave;

Mysql> show slave status \ G // display as follows


YES indicates that the operation is successful!

3. Note:

The data tables in the master and slave databases must be the same. If the data tables are different, the operation fails. (You need to synchronize the data table first)

Iv. test:

Test it on your own!


Suggestion: you are welcome to give some suggestions or comments!

Related Article

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.