我正在尝试运行以下内容。
mysql > purge binary logs to 'mysqld-relay-bin.000075';
ERROR 1373 (HY000): Target log not found in binlog index
# cat ./mysqld-relay-bin.index
/srv/mysql/logs/mysqld-relay-bin.000010
....
/srv/mysql/logs/mysqld-relay-bin.000075
/srv/mysql/logs/mysqld-relay-bin.000076
/srv/mysql/logs/mysqld-relay-bin.000077
/srv/mysql/logs/mysqld-relay-bin.000078
/srv/mysql/logs/mysqld-relay-bin.000079
我该怎么做才能手动清除删除这些中继日志。
MariaDB [(none)]> show slave status;
Empty set (0.00 sec)
MariaDB [(none)]> show master status;
+---------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+-----------+--------------+------------------+
| binary.000141 | 487953618 | | |
+---------------+-----------+--------------+------------------+
ls -lrt /var/lib/mysql/logs/
total 4616604
-rw-rw---- 1 mysql mysql 299 Jun 7 15:04 mysqld-relay-bin.000010
-rw-rw---- 1 mysql mysql 299 Jun 7 15:19 mysqld-relay-bin.000011
-rw-rw---- 1 mysql mysql 299 Jun 7 15:21 mysqld-relay-bin.000012
....
-rw-rw---- 1 mysql mysql 299 Jul 23 01:15 mysqld-relay-bin.000075
-rw-rw---- 1 mysql mysql 299 Jul 23 01:15 mysqld-relay-bin.000076
-rw-rw---- 1 mysql mysql 268 Jul 24 09:17 mysqld-relay-bin.000077
作为我运行的备份脚本的一部分。我每天晚上都刷新日志,这会不会有影响。
复制日志堆积的主服务器。
MariaDB [(none)]> SHOW VARIABLES LIKE 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 1000 |
+---------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> SHOW VARIABLES LIKE '%relay%';
+-----------------------+----------------------------------------+
| Variable_name | Value |
+-----------------------+----------------------------------------+
| max_relay_log_size | 1073741824 |
| relay_log | /srv/mysql/logs/mysqld-relay-bin |
| relay_log_basename | /srv/mysql/logs/mysqld-relay-bin |
| relay_log_index | /srv/mysql/logs/mysqld-relay-bin.index |
| relay_log_info_file | relay-log.info |
| relay_log_purge | ON |
| relay_log_recovery | OFF |
| relay_log_space_limit | 0 |
| sync_relay_log | 10000 |
| sync_relay_log_info | 10000 |
+-----------------------+----------------------------------------+
连接到主站的从站。
MariaDB [(none)]> SHOW VARIABLES LIKE 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 1002 |
+---------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> SHOW SLAVE STATUS\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.21.228.81
Master_User: db.replicator
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: binary.000141
Read_Master_Log_Pos: 540479720
Relay_Log_File: mysqld-relay-bin.000358
Relay_Log_Pos: 540480005
Relay_Master_Log_File: binary.000141
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 540479720
Relay_Log_Space: 540480344
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: 0
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: 1000
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
1 row in set (0.00 sec)
ERROR: No query specified
你混淆了两件事:“binlogs”和“relaylogs”
Master 写入 Master 上的一系列 binlog。这些由 ( ) expire_logs_days、( ) 显式 PURGE、(*) 操作系统删除命令中的任何一个清除(不推荐,但可能)。
Slave 从 Master 的 binlogs 接收数据,并立即将数据写入 Slave 上的一系列“中继日志”。“IO 线程”就是这样做的。同时,“SQL 线程”正在读取中继日志并执行操作。当它完成一个中继日志时,它会自动删除该文件。中继日志不需要手动操作。
您所做的是尝试在relaylogs上执行binlog操作。不要那样做。
通常,从站上会看到一个,偶尔会有两个中继日志。既然你看到了几十个,从复制肯定远远落后。这可能意味着它被卡住了。执行
SHOW SLAVE STATUS;
以查看原因。修复问题后,中继日志将被清理(如上所述)。如果您确实设法删除/清除/无论这些中继日志,您将永久中断复制。您将不得不从头开始重建奴隶。所以,不要删除这些文件。(除非你正在重建奴隶,在这一点上它们是古老的历史。)
不过是师父??
server_id
服务器会使服务器陷入混乱的循环。这些中继日志之一是什么?