Home  >  Article  >  Database  >  Mysql series (15) mysql master-slave configuration

Mysql series (15) mysql master-slave configuration

黄舟
黄舟Original
2017-01-22 17:07:581001browse

There can be many slave libraries. We assume one master M and one slave S.

Add the main M configuration file:

server-id=1
bin-log=logbin

This name is arbitrary

Remember to restart

From S Add the configuration file:

server-id=2


The configuration file is completed

Execute on the main M client:

>show master status;

Record the file and location (File, Position), for example: logbin.000001 120

Execute from the S client:

>change master to master_host='Master S's host address',master_user='Account with synchronous replication permission',master_password='Password',master_log_file='logbin.000001',master_log_pos=120;

The synchronous replication permission is Refers to: REPLICATION SLAVE.

Authorization example sql for the user account (password is pwd) connected from localhost:

>grant replication slave on *.* to 'user'@'localhost' identified by 'pwd';
>flush privileges;

Open from S:

>start slave;


View slave S status:

>show processlist;


Completed.

Master-slave backup means that the instructions executed by the master M machine are automatically executed on the slave S machine. Therefore, if M already has a library that S does not have, the operations you do on the library will cause Synchronous replication failed. Therefore, it is recommended to use a clean MySQL instance for master-slave backup.

Stop slave backup in slave S: stop slave; cleanup: reset slave;

The above is the content of mysql master-slave configuration in Mysql series (fifteen). For more related content, please pay attention to PHP Chinese Net (www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn