Using MySQL dual-machine hot standby under Windows

Source: Internet
Author: User
Tags mysql version

I. Preparatory work

1. Prepare two servers (computers), access the LAN, make each other ping each other

2. Two servers are installed mysql-server-5.1, you must ensure that the MySQL version is consistent

3. Assume that server a:192.168.0.2, server b:192.168.0.3

Two. Create and test sync users

1. To establish a connection account on the primary server for the slave server, the account must be granted replication slave permissions. Because Server A and Server B are primarily from each other, a synchronous user is created separately.

Server A:

 on * * to ' replicate ' @ ' 192.168.0.3 ' identified by ' 123456 '; MySQL> Flush privileges;

Server B:

 on * * to ' replicate ' @ ' 192.168.0.2 ' identified by ' 123456 '; MySQL> Flush privileges;

2. After creating a sync Connection account, we can use the replicate account on the slave server (slave) to access the primary server (master) database to see if the connection is successful.

Server A:

C:\users\administrator> mysql-h192.168.0.3-ureplicate-p123456

Server B:

C:\users\administrator> mysql-h192.168.0.2-ureplicate-p123456

If the "Welcome to the MySQL monitor" appears. "And so on, indicates the ability to log in successfully, indicating that the two servers can be dual-machine hot standby operation.

Three. Modify the configuration file My.ini

1. Open the "MySQL installation path \my.ini" file on pc A and add the following configuration at the end of the file:

Server A:

Server-id=1Log-bin=backuplogsync_binlog=1binlog_format== 2= 1  Max_binlog_size=512mexpire_logs_days=1binlog_do_db=oabinlog_ignore_db=  mysqlbinlog_ignore_db=information_schemareplicate_do_db=oareplicate_wild_ignore_table =oa. logslave_skip_errors=all

Server B:

server-id=2Log-bin=backuplogsync_binlog=1binlog_format== 2= 2  Max_binlog_size=512mexpire_logs_days=1binlog_do_db=oabinlog_ignore_db=  mysqlbinlog_ignore_db=information_schemareplicate_do_db=oareplicate_wild_ignore_table =oa. logslave_skip_errors=all

2. Restart the MySQL service on Server A and Server B, respectively, and if successful, there is no problem.

net stop MySQL; C: Net start MySQL;

  

3. The Master command allows you to view the primary server status of server A and Server B, respectively

Mysql> Show Master Status\g;

Using MySQL dual-machine hot standby under Windows

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.