MysqlCHANGEMASTERTOMASTER_HOSTserver1,
Mysql change master to MASTER_HOST = 'server1',-MASTER_USER = 'repl',-MASTER_PASSWORD = 'p4ssword',-MASTER_LOG_FILE = 'mysql-bin.000001 ',-MASTER_LOG_POS = 0; MASTER_LOG_POS is 0 because it is the start position of the log. You can use the show slave status statement to query
Mysql> change master to MASTER_HOST = 'server1 ',
-> MASTER_USER = 'repl ',
-> MASTER_PASSWORD = 'p4ssword ',
-> MASTER_LOG_FILE = 'mysql-bin.000001 ',
-> MASTER_LOG_POS = 0;
The value of MASTER_LOG_POS is 0 because it is the start position of the log.
You can use the show slave status statement to check whether the slave settings are correct:
Mysql> show slave status \ G
* *************************** 1. row ***************************
Slave_IO_State:
Master_Host: server1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: mysql-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: No
Slave_ SQL _Running: No
... Omitted...
Seconds_Behind_Master: NULL
Slave_IO_State, Slave_IO_Running, and Slave_ SQL _Running are No
It indicates that the replication process has not started. The log location is 4 rather than 0, because 0 is the start position of the log file, not the log location. In fact, MySQL knows that the first event is located at 4.
To start replication, you can run:
Mysql> start slave;
Run show slave status to view the output result:
Mysql> show slave status \ G
* *************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: server1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 164
Relay_Log_File: mysql-relay-bin.000001
Relay_Log_Pos: 164
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_ SQL _Running: Yes
... Omitted...
Seconds_Behind_Master: 0