mysql5.7 Gtid-based master-slave replication

Source: Internet
Author: User
Tags uuid

Basic Environment

Version 5.7.14

Main Library ip:192.168.1.100 port:3306

From library ip:102.168.1.101 port:3306

Building considerations

Main Library Configuration

Gtid-mode=on

Enforce-gtid-consistency=1

Binlog_format==row

server-id=3306100

Log-bin=/data/mysql/mysql3306/logs/mysql-bin

binlog_cache_size=4m

Skip_slave_start=1

Configure from Library

Gtid-mode=on

Enforce-gtid-consistency=1

Server-id=3306101

Binlog_format=row

Log-bin=/data/mysql/mysql3306/logs/mysql-bin

Skip_slave_start=1

Configure the reboot to make the configuration file effective

/etc/init.d/mysqld restart

Viewing in the main library

Show global variables like "%server%";

can view server_uuid number

Show master status;

Now it's empty, found no Gtid record.

Create a table

CREATE TABLE G1;

Check Again

Show master status;

You can view the information in the Executed_gtid_set

Primary Library Backup

Mysqldump-uroot-p--single-transaction--master-data=2-a >backup.sql

The backup file contains a statement that needs to be noted

SET @ @global. gtid_purged= "A57a3eb0-5d40-11e6-9609-080027f7e774:1-3"

It was passed from 4 onwards.

Then transfer the backup file to the vault from the Library for recovery

Mysql-uroot-p <backup.sql

(If you back up again, you will get an error and if you need to back up again, you can do a reset master from the library)

Then synchronize the change to Operation

Change Master to master_host= "192.168.1.100", master_port=3306,master_user= ' Repl ',

Master_password= ' Repl4slave ', master_auto_position=1;

Then you can test it

Extended

In the execution from the library

Show global variables like "%server%"; You can see the UUID number from the vault.

If you are performing an operation from a library

Through show master status;

You can also see the uuid+ thing number from the library.

mysql5.7 Gtid-based master-slave 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.