Mysqlab Replication and Gtid replication

Source: Internet
Author: User
Tags flush

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.