How to implement one-way master-slave backup for MySql Databases on Windows Server

Source: Internet
Author: User

I. Purpose: To synchronize the MySql database on the master server to the slave server, so that operations on the master server can be instantly updated to the slave server, this prevents the primary server from being unable to be used due to an environment or network exception to achieve the backup effect.

II. Environment:

The Master/Slave Server OS and database versions are the same, as shown in the following code:
Operating System: Windows 2003 Server R2
MySql database version: 5.0.51b
Master server (replaced by A) IP Address: 192.168.4.100
Slave server (replaced by B) IP Address: 192.168.4.101

Iii. configuration process:

1. Create A remote access backup account in.
Create A backup account in MySql database A. The command is as follows:
Copy codeThe Code is as follows:
Mysql> grant replication slave, RELOAD, super on *. * TO July @ '192. 168.4.101 'identified BY '20140901 ';
Mysql> Flush privileges;
Mysql> Quit;


Statement explanation:

In the first sentence *. * Indicates all databases. If you want to back up a database, replace it with "some" if the database name is "some. *, where TO July @ '100. 168.4.101 ', July is the remote access user name, IP address is the remote access IP address, and BY '123' 123456 is the remote access password;
After the second statement is executed, the remote access user creation takes effect;

Execution instructions:

After executing the preceding statement, if you want to check whether the remote access user has been created successfully, run the following statement:
Mysql> use mysql;
Mysql> select host, user from user;
One more entry in the user list
+ ------------------------------------ + ------------------ +
| Host | user |
+ ------------------------------------ + ------------------ +
| 192.168.4.101 | July |
+ ------------------------------------ + ------------------ +
This indicates that the remote access user has been created successfully.
2. Disable MySql service A and copy data to B.
Disable Mysql service A and copy the data in server A to server B, so that the initial data of server A and server B is completely the same, and the database write operation on the server is prohibited before the synchronous backup, to ensure that the initial data of server A and server B is identical.
3. modify my. ini configuration information in.
Open the my. ini file and add the following content under [mysqld] (# The content is a comment ):
# Server-id: ID of server
Server-id = 10
# Log-bin: Binary change log
Log-bin = c: \ log/log-bin.log
4. Restart server.
5. Disable server B and configure my. ini of server B.
Note:
Because the slave configuration information is set, mysql generates master.info in the database data directory. Therefore, if you want to modify the related slave configuration, delete the file first. Otherwise, the modified configuration cannot take effect.
Open the my. ini configuration file of B and add the following content to [mysqld:
# Server B ID
Server-id = 11
# Remote access IP Address
Master-host = 192.168.4.100
# Remote Access Username
Master-user = July
# Remote Access User Password
Masters-password = 123456
# Master server port (the default value is 3306. Check whether the master server port is disabled because of the firewall)
Master-port = 3306
# The synchronization interval is 60 seconds.
Master-connect-retry = 60
# Set the database to be backed up synchronously. The database here is some
Replicate-do-db = some
6. Restart server B. The master-slave backup has been completed. If there is an error, you can view it through mysql_error.log.

Note.

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.