在我们的数据中心停电之后,从MySQL数据库陷入困境。
这是其中一个奴隶的原木:
100118 10:05:56 [Note] Slave I/O thread: connected to master 'repl@db1:3306', replication started in log 'bin-log.004712' at position 724207814
100118 10:05:56 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)
100118 10:05:56 [ERROR] Got fatal error 1236: 'Client requested master to start replication from impossible position' from master when reading data from binary log
100118 10:05:56 [Note] Slave I/O thread exiting, read up to log 'bin-log.004712', position 724207814控制台显示了更多细节:
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: db1
Master_User: repl
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: bin-log.004712
Read_Master_Log_Pos: 724207814
Relay_Log_File: mysqld-relay-bin.000105
Relay_Log_Pos: 98
Relay_Master_Log_File: bin-log.004712
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB: mmplive1,mmpjcr,fui
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: 724207814
Relay_Log_Space: 98
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: NULL
1 row in set (0.00 sec)
ERROR:
No query specified看看主机上的回收站日志,我们有:
-rw-rw---- 1 mysql mysql 724200412 Jan 18 09:22 bin-log.004712
-rw-rw---- 1 mysql mysql 1904 Jan 18 09:27 bin-log.index
-rw-rw---- 1 mysql mysql 5046830 Jan 18 11:22 slow-log
-rw-rw---- 1 mysql mysql 198249613 Jan 18 11:24 bin-log.004713修复奴隶的最好方法是什么?
我正在考虑的选择:
更新:
我忽略了另一个选项:将每个从执行的位置指向回一点,这样它就可以尝试复制它已经从bin-log.004712处理过的命令。
发布于 2010-01-19 13:33:39
我选择了第一个选择。
这导致奴隶开始尝试执行与主键冲突的插入操作。正如前面提到的,奴隶所做的工作比主bin-log所坚持的要多。我没有预料到的一个方面是,奴隶包含不在主服务器中的数据;也就是说,在主服务器没有持久的断电之前,奴隶坚持了一些事务。
因为就我的情况而言,这些事务与支付无关或类似,所以我选择从从服务器中删除数据(因此丢失了一些已发生的数据,但这些数据在主服务器中不存在),然后让复制再次运行。这使奴隶们完全跟上了时代。如果数据是更重要的,我们有足够的自动增量偏移,给我们一些扭动空间,手动纠缠数据,并确保参考完整性不受损害。谢天谢地,在这种情况下,我们不需要这样做。
对于处于这种困境中的(被动)主机配置中的机器,我选择了一种类似的方法。所谓被动主-母版,我的意思是我们有一个主动主(serverA),它是所有写的地方,以及一个被动的主(serverB),它允许模式更新在零停机时间内进行。active master (serverA)中的数据被选择为真正的值,尽管我们知道这意味着我们丢失了一些被认为不重要的持久化事务。
发布于 2010-01-18 14:15:22
这将取决于奴隶是主人的复制品有多重要。你的第一个选择将在一定程度上起作用,但奴隶很可能丢失了主人的信息。如果你能接受这一点,因为数据是短暂的或者其他什么的,那就去做吧。如果奴隶是正确的复制品是很重要的,那么第二个选项可能是您唯一的选择。不幸的是,MySQL复制对任何类型的意外中断都不友好,我发现这种问题比我想要的复制体系结构更频繁。
https://serverfault.com/questions/103729
复制相似问题