1 Select two servers, respectively, as a master and standby database
2 Login to the server,
Yum install MySQL;
Yum install mysql-server;
3 Starting the server
Service mysqld Start
4 separate root login MySQL to execute the following command, increase the replication user and authorization (master and Standby in the 192.168.119.* network segment, in order to facilitate the primary and standby switch, both sides are established)
GRANT REPLICATION slave,replication CLIENT on * * to [e-mail protected] ' 192.168.119.% ' identified by ' 1234 ';
5 Configuring/ETC/MY.CNF
First server (Master)
Log_bin=mysql_bin
Server_id=1
Second server (standby)
Log_bin=mysql_bin
server_id=2
Read_only=1
6 login Master (root) execution
Show Master Status\g;
Show
file:mysql-bin.000001
position:106
Login standby (Root) execution
Test whether the mysql-urepl-h192.168.119.128-p1234 can connect to the main library, do not need to check the firewall or/etc/my.cnf whether there is access restrictions, modify the configuration
Mysql-uroot Login to local repository execution:
Change MASTER to
Master_host= ' 192.168.119.128 ',
Master_user= ' Repl ',
master_password= ' 1234 ',
Master_log_file= ' mysql-bin.000001 ',
master_log_pos=106;
Start slave;
show slave status\g;
7, create a table on the main library, view on the library, and you can see
REPL CREATE table on standby, show the MySQL server is running with the--read-only option so it cannot execute this statement
Because the standby library is configured as Read_Only
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MySQL master and slave replication structure setup