如何获得一个disconected mysql奴隶的日志位置?

我们有一个系统,我们的商人有他们出差的笔记本。 他们都是mysql的奴隶,他们每隔一天就把它们连接起来,但是有时候一个人可能会连续几天没有同步。 我们过去只是删除了X天以前的bin日志,但是当销售人员正在进行长途旅行时,我们遇到了问题,并尝试在阈值之后同步。 我们需要的是使用脚本进行自动化,一旦在主服务器上应用了它们,就可以删除主服务器上的bin日志。 脚本运行时,可能会断开从站的连接。

我怎么能知道哪个是我的拓扑中最未被同步的从属的Exec_Master_Log_Pos? 或者它的Master_Log_File。 如果我知道值,我可以清除二进制日志没有任何问题。

MySQL Utilities 1.6.2(Beta)具有mysqlrplcheck实用程序,当与--show-slave-status选项--show-slave-status时,即使从属服务器的复制线程停止,也可以为您提供从属服务器的状态。

  % mysqlrplcheck --master=root:[email protected]:21891 --slave=root:[email protected]:21892 -v -s WARNING: Using a password on the command line interface can be insecure. # master on 127.0.0.1: ... connected. # slave on 127.0.0.1: ... connected. Test Description Status --------------------------------------------------------------------------- Checking for binary logging on master [pass] Are there binlog exceptions? [pass] Replication user exists? [pass] Checking server_id values [pass] master id = 1 slave id = 101 Checking server_uuid values [pass] master uuid = 00021891-1111-1111-1111-111111111111 slave uuid = 00021892-2222-2222-2222-222222222222 Is slave connected to master? [WARN] Check master information file [FAIL] Slave is stopped. Checking InnoDB compatibility [pass] Checking storage engines compatibility [pass] Checking lower_case_table_names settings [pass] Master lower_case_table_names: 0 Slave lower_case_table_names: 0 Checking slave delay (seconds behind master) [FAIL] Slave is stopped. # # Slave status: # Slave_IO_State : Master_Host : 127.0.0.1 Master_User : rsandbox Master_Port : 21891 Connect_Retry : 60 Master_Log_File : mysql-bin.000001 Read_Master_Log_Pos : 151 Relay_Log_File : mysql-relay.000003 Relay_Log_Pos : 314 Relay_Master_Log_File : mysql-bin.000001 Slave_IO_Running : No Slave_SQL_Running : No 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 : 151 Relay_Log_Space : 724 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 : None 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 Master_UUID : 00021891-1111-1111-1111-111111111111 Master_Info_File : mysql.slave_master_info SQL_Delay : 0 SQL_Remaining_Delay : None Slave_SQL_Running_State : Master_Retry_Count : 86400 Master_Bind : Last_IO_Error_Timestamp : Last_SQL_Error_Timestamp : Master_SSL_Crl : Master_SSL_Crlpath : Retrieved_Gtid_Set : Executed_Gtid_Set : Auto_Position : 0 # ...done. 

但是,如果从属服务器closures,在你的情况是真的,这是行不通的。 主节点不存储从属复制信息,但是你可能会自动化一些让你的业务员“点击”链接来执行这个脚本,并将信息存储在一个数据库或文件中,你可以检索这些信息来决定在哪个binlog上清除。