mysql master - Master - from - from

Build instructions

4 from the master machine from the main building, to build two mutual master-slave, i.e. master master mode. Two structures are then synchronized from the master data two

mysql primary master mode structures

Main master model is two mutual backup

According binglog logs from the previously -gtid main configuration mode (See main article from building -gtid), the main change from the main Lord, let the Lord be synchronized from the

Because before all equipped with the following configuration

log-bin
server-id=2/1
gtid_mode=ON
enforce_gtid_consistency=1
View Code

Notice

At this time, the main authorization is required to go from the above synchronization log, because prior to performing the grant replication slave on * * to rep @ in the main. ' 192.168.231%. ' IDENTIFIED by ' 1qaz WSX @ ' ; 

master-slave synchronization, so from With the above authorization also above information, due to 192. 168.231 .% authorized network, so no need to authorize once. 

If it were authorized is fixed Ip, you need to authorize once again, this time should be authorized to operate in the main, because execution will not be synchronized from the master to lead to inconsistencies from the Lord.
View Code

After successful authorization, the following operation can be performed on the primary

MySQL> Change to Master
     -> MASTER_HOST = ' 192.168.231.101 ' , # from the IP
     -> MASTER_PORT = 3306 ,
     -> MASTER_USER = ' REP ' ,
     -> master_password = ' 1qaz WSX @ ' ,
     -> = master_auto_position . 1 ; #binlog log location automatic negotiation 

MySQL > Start Slave; 
MySQL > Show Slave Status \ G
View Code

mysql built from slave mode

Two slave configuration

VI / etc / the my.cnf 
    Server - ID = . 3 
    gtid_mode = the ON 
    enforce_gtid_consistency = . 1 
    Master - info -repository = TABLE                                         
    #MASTER info stored in the information table inside 
    Relay -log- info -repository = TABLE # 
    # log stored in the relay table which 

are synchronized to the two primary, two machines are configured to do the following 
mysql > Source / opt / 2019 - 07 - 18 is - all.sql     

synchronizing a master configuration 
mysql> Change to Master
     -> MASTER_HOST = ' 192.168.231.100 ' ,
     -> MASTER_PORT = 3306 ,
     -> MASTER_USER = ' REP ' ,
     -> master_password = ' 1qaz WSX @ ' ,
     -> = master_auto_position . 1  for Channel ' Master1-Channel ' ; #channel name of the custom 

synchronization master configuration 2 
    MySQL > Change to master
     -> MASTER_HOST = ' 192.168.231.101 ' ,
     -> MASTER_PORT = 3306 ,
    -> master_user='rep',
    ->  master_password='1qaz@WSX',
    -> master_auto_position=1 for channel 'master2-channel';    #channel 名称自定义
    -> start slave;
    -> show slave status\G
View Code

FAQ

show slave status \ G 

being given: 
    Last_IO_Error: Got fatal error 1236 from Master When Reading Data from binary 
    log: ' of The Slave IS Connecting the using the CHANGE the MASTER the TO 
    MASTER_AUTO_POSITION = . 1 , But The Master has Purged binary logs 
    containing GTIDs that 

solution: reset master; 
     stop slave; 
    back up the database on the master, from the re-execution Source / opt / 2019 - 07 - 18 is - all.sql 
    again change master to perform the above operation.
View Code

Guess you like

Origin www.cnblogs.com/fanggege/p/11221374.html