AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 181705
Accepted
nelaaro
nelaaro
Asked: 2017-07-26 01:23:37 +0800 CST2017-07-26 01:23:37 +0800 CST 2017-07-26 01:23:37 +0800 CST

在 binlog 索引中找不到目标日志,从清除二进制日志 mysqld-relay-bin

  • 772

我正在尝试运行以下内容。

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
mysql binlog
  • 1 1 个回答
  • 3714 Views

1 个回答

  • Voted
  1. Best Answer
    Rick James
    2017-07-26T17:08:39+08:002017-07-26T17:08:39+08:00

    你混淆了两件事:“binlogs”和“relaylogs”

    Master 写入 Master 上的一系列 binlog。这些由 ( ) expire_logs_days、( ) 显式 PURGE、(*) 操作系统删除命令中的任何一个清除(不推荐,但可能)。

    Slave 从 Master 的 binlogs 接收数据,并立即将数据写入 Slave 上的一系列“中继日志”。“IO 线程”就是这样做的。同时,“SQL 线程”正在读取中继日志并执行操作。当它完成一个中继日志时,它会自动删除该文件。中继日志不需要手动操作。

    您所做的是尝试在relaylogs上执行binlog操作。不要那样做。

    通常,从站上会看到一个,偶尔会有两个中继日志。既然你看到了几十个,从复制肯定远远落后。这可能意味着它被卡住了。执行SHOW SLAVE STATUS;以查看原因。修复问题后,中继日志将被清理(如上所述)。

    如果您确实设法删除/清除/无论这些中继日志,您将永久中断复制。您将不得不从头开始重建奴隶。所以,不要删除这些文件。(除非你正在重建奴隶,在这一点上它们是古老的历史。)

    不过是师父??

    • 是“双主”设置吗?那是当两个服务器中的每一个都是彼此的主服务器和从服务器时。
    • 还是它曾经是一个Slave,这些日志没有清理干净?
    • 嗯...所有日志似乎都是“空的”(299 字节),好像配置错误?如...
    • 具有相同 功能的双主server_id服务器会使服务器陷入混乱的循环。

    这些中继日志之一是什么?

    • 2

相关问题

  • 是否有任何 MySQL 基准测试工具?[关闭]

  • 我在哪里可以找到mysql慢日志?

  • 如何优化大型数据库的 mysqldump?

  • 什么时候是使用 MariaDB 而不是 MySQL 的合适时机,为什么?

  • 组如何跟踪数据库架构更改?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve