mysql5.6 added a way to not set the Log_bin file and log location, before we all need to view the Master machine information (show Master status), and then set the slave in the
Master_host= ' 10.163.213.228 ', master_user= ' repl ', master_password= ' Sangfordb ', master_log_file= ' mysql-bin.000015 ' , master_log_pos=193952;
Using mysql5.6 can be configured without this method, as long as the my.cnf file is set
Log-bin=mysql-bin
Binlog_format=row
Log_slave_updates
Gtid-mode=on
Enforce-gtid-consistency=on
Then set in slave:
Change Master to
Master_host= ' Masterip ', master_user= ' replicationuser ', master_password= ' password ', master_auto_position=1;
Where Masterip, Replicationuser, and password each correspond to your master machine's information
Problems:
1. Show slave status slave_io_state:waiting to reconnect after a failed registration on master
Workaround:
Execute on Master
Grant Replication Slave on * * to ' repl ' @ '% ' identified by ' Sangfordb ';
FLUSH privileges;
Then restart stop slave and start slave to
2. Slave_sql_running from the library to No
General in Last_sql_error: The statement of the error can be seen in the item
Slave_io_running: Connect to the main library and read logs from the main library to local, generate local log files
Slave_sql_running: Reads the local log file and executes the SQL command in the log.
At this time, many online will teach to use set global sql_slave_skip_counter=n; Settings, but the execution of this statement will be an error because the gtid-mode=on is activated.
Workaround: Skip the statement that executed the error
See the last two lines of show slave status:
Retrieved_gtid_set represents a transaction that has been pulled from master;
Executed_gtid_set indicates that a transaction has been performed
Locate records in Executed_gtid_set that match the Retrieved_gtid_set ID, such as Ca83d308-2ea5-11e4-b85f-00163e042f50 : 1-5, which means that only the fifth transaction is executed, that is, the transaction is an error, so skip this transaction. Execute the following statement in turn:
Stop slave;
Set gtid_next= 'ca83d308-2ea5-11e4-b85f-00163e042f50:6 ';
Begin;commit;
Set gtid_next= "AUTOMATIC";
Start slave;
Then check out show slave status\g
If you see the following status, you can
PS: When starting a master-slave backup, it is important to ensure that the master-slave data is consistent, because any error encountered from the library, even when the UPDATE statement is executed, a record in the main library cannot be found from the library, which will cause issue 2 to stop performing the slave update
mysql5.6 new ways to configure synchronous replication and workarounds for common problems