我已经为生产数据库设置了一个从属db服务器,但是当我检查show slave的状态时,我发现它比master落后几秒钟。
这是输出:
Slave_IO_State: Waiting for master to send event
Master_Host: 1.2.3.4
Master_User: replicator
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000173
Read_Master_Log_Pos: 15909435
Relay_Log_File: mysqld-relay-bin.000079
Relay_Log_Pos: 91173356
Relay_Master_Log_File: mysql-bin.000093
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: 91173210
Relay_Log_Space: 8179978166
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: 486330
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: 1
1 row in set (0.00 sec)
ERROR:
No query specified
然后,当我运行SHOW PROCESSLIST时,我看到线程的时间与后面几秒中指示的时间匹配:
mysql> SHOW PROCESSLIST;
| 40 | system user | | NULL | Connect | 66530 | Waiting for master to send event | NULL |
| 41 | system user | | NULL | Connect | 486330 | Reading event from the relay log | NULL |
| 45 | root | localhost | NULL | Query | 0 | NULL | SHOW PROCESSLIST |
那个时间在慢慢地减少。Read_Master_Log_Pos,Relay_Log_Pos,Exec_Master_Log_Pos和Relay_Log_Space一直在变化。
我还检查了时间/日期,并且两台服务器都处于同步状态。
在主端:
mysql> SHOW PROCESSLIST;
| 66739 | replicator | 1.2.3.5:52884 | NULL | Binlog Dump | 65671 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL
并显示奴隶主机看起来是空的...
mysql> SHOW SLAVE HOSTS;
+-----------+------+------+-----------+
| Server_id | Host | Port | Master_id |
+-----------+------+------+-----------+
| 2 | | 3306 | 1 |
+-----------+------+------+-----------+
1 row in set (0.00 sec)
mysql>
那么,这里到底发生了什么?看起来从站实际上已经连接并且正在工作,但是非常慢吗?有人可以给我一些有关如何对此进行更多调试的提示吗?服务器处于95%的空闲状态。