Query OK, 0 rows affected, 2 warnings (0.11 sec)
mysql>
这里包含的信息有主机的地址和端口、主机提供的复制帐号、主机的binlog位置信息。Master_log_file和Master_log_pos是主服务器的快照信息(就是第7不第2小步看到的值),从服务器从该binlog的相应位置开始从主服务器同步数据。
2)
启动从服务器线程就可以开始同步了:
start slave;
一旦从服务器开始同步了,就能在数据文件目录下找到2个文件master.info和relay-log.info。从服务器利用这2个文件来跟踪处理了多少master的binlog。
分别在主从服务器show processlist查看连接,就可以看到repl用户的连接,可证明复制已经生效。
从:
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.18.66
Master_User: usrep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 1264
Relay_Log_File: mysql-relay-bin.000021
Relay_Log_Pos: 283
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1264
Relay_Log_Space: 1075
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 10
Master_UUID: c03d6252-2a2f-11e4-9b48-000c291888ce
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
主:可以看到下面内容
mysql> show processlist \G
*************************** 2. row ***************************
Id: 11
User: usrep
Host: 192.168.18.67:48746
db: NULL
Command: Binlog Dump
Time: 179
State: Master has sent all binlog to slave; waiting for binlog to be updated
Info: NULL
2 rows in set (0.00 sec)
从服务器:
数据文件中相关文件如下
[root@host2 ~]# ll /var/lib/mysql/
-rw-rw----. 1 mysql mysql 128 Aug 28 11:32 master.info
-rw-rw----. 1 mysql mysql 59 Aug 28 11:32 relay-log.info
-rw-rw----. 1 mysql mysql 792 Aug 28 11:32 mysql-relay-bin.000020
-rw-rw----. 1 mysql mysql 283 Aug 28 11:32 mysql-relay-bin.000021
-rw-rw----. 1 mysql mysql 50 Aug 28 11:32 mysql-relay-bin.index
主服务器:
数据文件中相关文件如下
-rw-rw----. 1 mysql mysql 1036 Aug 28 09:32 mysql-bin.000003
-rw-rw----. 1 mysql mysql 1264 Aug 28 11:04 mysql-bin.000004
-rw-rw----. 1 mysql mysql 76 Aug 28 09:32 mysql-bin.index
到这儿就ok了
下面说一下在配置过程中遇到的问题:
问题1
1
刚搭完跑起来一看,有问题,Slave_IO_Running: Connecting,IO线程链接主服务进程没有成功
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.18.66
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 401
Relay_Log_File: host2-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
Replic