herohope 2020-03-06
[mysqld] log-bin=mysql-bin #/ [必须]启用二进制日志 server-id=1 # [必须]服务器唯一ID
[mysqld] log-bin=mysql-bin # [非必须]Slave可以不启用二进制日志,配置二进制日志可以便于Master和Slave交换角色 server-id=2 # [必须]服务器唯一ID
mysql> GRANT REPLICATION SLAVE ON *.* to 'lover'@'%' identified by 'kiss'; mysql> FLUSH PRIVILEGES;
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000002 | 6584 | thisonedb | mysql | | +------------------+----------+--------------+------------------+-------------------+
mysql> change master to master_host='127.0.0.1',master_user='lover',master_password='kiss',master_log_file='mysql-bin.000002',master_log_pos=6584 ; mysql> start slave;
mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.16.13.128 Master_User: username Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000002 Read_Master_Log_Pos: 6584 Relay_Log_File: bx-13-129-relay-bin.000003 Relay_Log_Pos: 6797 Relay_Master_Log_File: mysql-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes