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

Mysql series (15) mysql master-slave configuration

黄舟
Release: 2017-01-22 17:07:58
Original
1074 people have browsed it

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
Copy after login

This name is arbitrary

Remember to restart

From S Add the configuration file:

server-id=2
Copy after login


The configuration file is completed

Execute on the main M client:

>show master status;
Copy after login

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;
Copy after login

Open from S:

>start slave;
Copy after login


View slave S status:

>show processlist;
Copy after login


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)!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template