我们有一个系统,在这个系统中,我们的业务人员有笔记本,他们可以在商务旅行中使用。它们都是mysql的奴隶,它们每隔一天就将它们插入以同步它们,但有时一个人可能几天内无法同步。我们过去只需要删除超过X天的回收站日志,但是当销售人员正在进行一次长时间的旅行并试图在阈值之后同步时,我们就出现了问题。我们需要的是用脚本实现自动化,这个过程可以在所有从服务器上应用之后删除主日志上的bin日志。脚本运行时,可以断开奴隶的连接。
我怎么知道哪个是拓扑中最不同步的从站的Exec_Master_Log_Pos?或者它的Master_Log_File。如果我知道这些值,我就可以清除二进制日志,而不会有任何问题。
发布于 2015-12-31 05:52:18
MySQL实用程序1.6.2 (Beta)具有mysqlrplcheck实用程序,当与--show-slave-status选项一起使用时,即使停止了从线程的复制,也会为您提供从线程的状态。
% mysqlrplcheck --master=root:msandbox@127.0.0.1:21891 --slave=root:msandbox@127.0.0.1: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.但是,如果从服务器处于关机状态(在您的情况下为true ),则此操作不起作用。主节点不存储从复制信息,但是您可能会自动执行一些允许您的biz用户“单击”链接来执行此脚本并将信息存储在db或文件中的内容,您可以检索这些信息来决定要清除哪个绑定日志。
https://serverfault.com/questions/746071
复制相似问题