Get the App
SLTechnology News&Howtos  ›  Database  › 

[basic] mysqldump creates a slave library based on GTID

Shulou Source: shulou.com Published: 2022-06-01 15:26:32 10月02日 Update

For small databases, we can directly use the mysqldump full library export import to create a slave library.

Test environment:

CentOS6.8 x86_64

MySQL5.6.34 Community rpm Edition

Main library: node0 192.168.2.10

Slave library: node1 192.168.2.11

5.6.The parameters required for GTID replication (these three lines of parameters should be added for both master and slave libraries):

Gtid-mode=ON

Enforce_gtid_consistency = ON

Log_slave_updates=ON

Step1, export in the main library and scp transfer to node1:

Mysqldump-uroot-pwww.Mwbyd91@-A-Q-- single-transaction-- master-data=2 > / root/all.sql

Scp / root/all.sql node1:/root/

Step2, restore on node1:

Node1 newly installed does not have a password, execute mysql to log in

Source / root/all.sql

"step3, start replication on node1:"

CHANGE MASTER TO MASTER_HOST='192.168.2.10'

MASTER_USER='rpl'

MASTER_PASSWORD='rpl'

MASTER_PORT=3306

MASTER_AUTO_POSITION=1

Start slave

Show slave status\ G

# description:

Importing mysqldump in this way does not require operations like set global gtid_purged='xxxxx'; to be performed by innobackup. Because there are automatic settings in the sql exported by mysqldump. For example, the following figure is a partial screenshot of the exported all.sql:

Tags: Parameters place password screenshot data database method moderator environment community part Xin'an transmission login experiment foundation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi Linux Docker MySQL