master_server:192.168.159.10
slave_server:192.168.159.111. Test Remote Account LoginMaster_server: #给backup用户授权mysql> Grant Replication Slave on * * to ' backup ' @ ' 192.168.159.11 ' identified by ' 123 '; #检查 authentication_string equivalent to mysql5.5 before password mysql> Select host,user,authentication_string from Mysql.user;
| host | user | authentication_string |
+----------------+------------------+------------------------------------------- +
| localhost | root | *3DB01AD4E54E8FE9429FA016DB24E4E725247513 |
| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | debian-sys-maint | *C9A3938D4184835A2096D4F76879FFCEA1383C22 |
| 192.168. 159.11 | backup | *23ae809ddacaf96af0fd78ed04b6a265e05aa257 |
+----------------+------------------+------------------------------------------- +
Slave_server:mysql-ubackup-p-H ' 192.168.159.10 ' #Enter password test to login =========================================If you cannot log in, troubleshoot the problem:1) Check if the master_server is only listening on the native 3306 portNetstat-an|grep 3306[email protected]:~# netstat-an|grep 3306TCP6 0 0::: 3306:::* LISTENtcp6 0 0 192.168.159.10:3306 192.168.159.11:53918 established#如果只出现127.0.0.1:3306 Modify MY.CNF to unbind the IPvim/etc/mysql/mysql.conf.d/mysqld.cnf
comment out # bind-address = 127.0.0.1whether the test succeeds2) Turn off firewall/telnet 3306 detect port can access==========================================2. Start configuring master/Slavefirst determine the MySQL version, mysql5.17 after the master and slave configuration information is not supported in the configuration file,1) master_server configuration file turn on binary log: Log_bin =/var/log/mysql/mysql-bin.logEnter Mysql,show Master status,Note File,positin mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 611 | | | | +------------------+----------+--------------+------------------+-------------------+2) slave_server configuration fileModify Server-id:Server-id = 2go to MySQL Mysql>change Master to master_host= ' 192.168.159.10 ',>master_user= ' backup ',>master_password= ' 123 ',>master_log_file= ' mysql-bin.000001 ',>master_log_pos=611;MySQL>start slave; 3) detection is successfulmysql> show Slave status\gSlave_io_running:yesSlave_sql_running:yes==========================================Issue: Configuration complete Slave_io_running:no, view Error.log,The slave I/O thread stops because master and slave have equal MySQL server UUIDs; These uuids must is different for R Eplication to workFIX: Because our virtual machine does clone, causes the master and slave to read the UUID exactly the same, view show variables like ' server%id% '; Modify UUID:VIM/VAR/LIB/MYSQL/AUTO.CNF #改成一样的就可以了
(ii) MySQL master-slave synchronization setup Steps