mysql database master-slave synchronization method explained

Install mysql (version must be the same) on both servers

I want two versions of mysql database synchronization are mysql5.5

Main: 192.168.2.135 Port number: 3306

From: 192.168.2.35 Port number: 3306

Linux: we /etc/my.cnf

windows: my.ini

Configuration Master (primary)

Note: server-id of s capital will complain, windows can not start the mysql service 1067

Configuring slave (from the server)

If your server from below and then hung from the server, enable binary logging is mandatory!

Restart mysql service

The purpose is to use just restart the configuration to take effect, both master and slave need to restart;

linux:/etc/init.d/mysqld restart

Note: The service name is "mysqld", not a student in the article "mysql"!

windows can be initiated at the service

① Add the primary database account for synchronization:

Description: 'copyuser': synchronization of database account name;

'192.168.2.35': the address of the synchronization database;

'123456': database password synchronization, the configuration needs to be set from the library.

note:

1, here is create a user and authorize GRANT remote login privileges, instead of using the "Create User" to create;

2, is performed at a Shell command, instead of executing "mysql" client;

② query the status of master (master) of

search result:

Write pictures described here

① execute command in mysql

master_host = master IP

master_user = Backup user name created on the primary server

master_password = backup user password

File column value query master_log_file = Master (primary server) state obtained

Position column value master_log_pos =

start slave: Start replication from server

② check replication status from the server

Write pictures described here

Slave_IO and Slave_SQL process must run properly, that is YES state otherwise is wrong state (eg: NO belong to one error).

During the above operations, from the master server to complete the configuration.

I once forgot to create a backup configuration process user on the primary server, Slave_IO_Running has been in a "connect" state.

Guess you like

Origin www.cnblogs.com/mynale/p/11018700.html