我有一个有效的mySQL master-slave复制,最近我注意到它已经失败了几分钟前。
这是SHOW SLAVE STATUS\G
的结果:
*************************** 1. row ***************************
Slave_IO_State: Waiting for source to send event
Master_Host: 185.128.xxx.xxx
Master_User: replica
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 2456753
Relay_Log_File: mysql-relay-bin.000003
Relay_Log_Pos: 1595182
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
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: 1049
Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ANONYMOUS' at source log mysql-bin.000002, end_log_pos 1595341. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
Skip_Counter: 0
Exec_Master_Log_Pos: 1594966
Relay_Log_Space: 2457347
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
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1049
Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ANONYMOUS' at source log mysql-bin.000002, end_log_pos 1595341. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 42e23b0a-9fec-11ea-a6a6-00163e051c80
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 230810 13:58:36
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Master_public_key_path:
Get_master_public_key: 0
Network_Namespace:
1 row in set, 1 warning (0.00 sec)
根据一些研究,错误代码1049
表示"Unknown Database";但老实说,我不知道如何调试?
我现在应该怎么做?我应该STOP SLAVE
吗?和START SLAVE
?还是如何知道称为哪个数据库的未知数据库?
主人上的配置:
bind-address = 185.128.xxx.xxx
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = my_db_name
从属上的配置:
server-id = 2
max_binlog_size = 100M
# log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = my_db_name
relay-log = /var/log/mysql/mysql-relay-bin.log
分析解答
how to know which database is called that has been unknown?
至少这很容易:
echo "show databases;" | mysql -h dbhost1 >dbsOnDb1
echo "show databases;" | mysql -h dbhost2 >dbsOnDb2
diff dbsOnDb1 dbsOnDb2
(在Linux/Unix上)
然后,只需在从设备上创建数据库,然后重新启动从属过程即可。
但是您确实应该调查为什么CREATE DATABASE语句不在Binlog中。 --replicate-do-db或--replicate-ignore-db最近是否被搅动了?有一个奇怪的范围范围,如果(例如)您排除了名为“本地”的数据库,并且这样做:
USE local;
CREATE DATABASE newdb;
然后,由于语句在本地数据库中执行(即使其效果在该数据库之外)将不会复制。