如何调试MySQL复制错误1049?

问题描述 投票:0回答:1

我有一个正在运行的 MySQL 主从复制,最近我注意到它在几分钟前失败了。

这是

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
表示“未知数据库”;但说实话我不知道如何调试?

我现在应该做什么?我应该

STOP SLAVE
吗?又是
START SLAVE
?或者如何知道一直未知的数据库被调用了?


Master上的配置:

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
sql mysql database-replication
1个回答
0
投票

如何知道一直未知的数据库被调用了?

这至少很容易:

echo "show databases;" | mysql -h dbhost1 >dbsOnDb1
echo "show databases;" | mysql -h dbhost2 >dbsOnDb2
diff dbsOnDb1 dbsOnDb2

(在 Linux/Unix 上)

然后只需在从站上创建数据库并重新启动从站进程即可。

但是您确实应该调查为什么 CREATE DATABASE 语句不在二进制日志中。最近是否更改了 --replicate-do-db 或 --replicate-ignore-db ?有一个奇怪的范围界定问题,如果(例如)您排除名为“local”的数据库并且执行以下操作:

USE local;
CREATE DATABASE newdb;

那么该语句将不会被复制,因为它是在本地数据库中执行的(即使它的效果在该数据库之外)。

© www.soinside.com 2019 - 2024. All rights reserved.