AB replication: Synchronizes the data from the server and the primary server database.
You need to shut down the firewall at both ends.
Primary server:
First, modify the master configuration file of the primary server to produce a permanent log.
#vim/etc/my.cnf
Log-bin=masterlog
Server-id=1
Restart Service:
#systemctl Restart Mysqld
Create user
mysql> Grant replication Slave,reload,super on * * to ' slave ' @ ' percent ' identified by ' 123 ';
mysql> flush Privileges;
% write the IP directly from the server in the working environment.
Restart Service:
#/etc/init.d/mysqld Restart (rhel6)
#systemtcl Restart Mysqld
Note: If you do not delete the previous Binlog log successfully
NOTE: replication slave:
With this permission, you can view the binary logs from the server and read from the primary server.
Super Privilege:
Allows the user to use the SET statement that modifies the global variable and the change master statement
Reload Permissions:
You must have reload permission to perform flush [tables | logs | privileges]
From the server:
Modify I config file: Server-id cannot be the same as the primary server
#vim/etc/my.cnf
[Mysqld]
server-id=2
Log-bin=salvelog//write not read the requirements (double master must write, use Gtid mode must write)
Restart Service
#systemctl Restart Mysqld
Specify primary server information:
To view the primary server information:
Mysql>show Master status;
From the server:
Mysql>change MASTER to
Master_host= ' master2.example.com ',//home Server IP
Master_user= ' replication ',//master server user
Master_password= ' PASSWORD ',//user password
master_port=3306,//Port
Master_log_file= ' master2-bin.001 ',//binlog log file name
master_log_pos=4,//log location
master_connect_retry=10; If the number of attempts to synchronize failed
To start the slave service:
Mysql>start slave;
Mysql>show slave Status\g
If startup fails, stop slave. Delete Binlog log, reset
Mysqlab Replication and Gtid replication