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 / 问题 / 71821
Accepted
HTF
HTF
Asked: 2014-07-19 01:35:31 +0800 CST2014-07-19 01:35:31 +0800 CST 2014-07-19 01:35:31 +0800 CST

MySQL 5.6:Slave_IO 线程停止工作

  • 772

标准复制无故中断。

mysql> SELECT @@version, @@version_comment;
+---------------+----------------------------------------------------------------------------+
| @@version | @@version_comment |
+---------------+----------------------------------------------------------------------------+
| 5.6.15-56-log | Percona XtraDB Cluster (GPL), Release 25.5, Revision 759, wsrep_25.5.r4061 |
+---------------+----------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SHOW VARIABLES LIKE 'wsrep_on';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wsrep_on | OFF |
+---------------+-------+
1 row in set (0.00 sec)

启用崩溃安全复制:

master_info_repository = TABLE
relay_log_info_repository = TABLE
relay_log_recovery = 1

从机运行良好:

# mysql -e "SHOW SLAVE STATUS\G" | grep "Slave"
               Slave_IO_State: Waiting for master to send event
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

但一段时间后,MASTER 上没有连接的从属服务器和 IO 线程从 MASTER 中消失:

mysql> SELECT * FROM information_schema.processlist WHERE command = 'Binlog Dump';
Empty set (0.10 sec)

mysql> SHOW SLAVE HOSTS;
Empty set (0.00 sec)

掌握:

mysql> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 568210 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

奴隶:

# mysql -e "SHOW SLAVE STATUS\G" | grep "Master_Log"
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 568210
        Relay_Master_Log_File: mysql-bin.000003
          Exec_Master_Log_Pos: 568210

掌握:

mysql> CREATE DATABASE IF NOT EXISTS repl_test; SHOW MASTER STATUS;
Query OK, 1 row affected (0.00 sec)

+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 568333 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

从站没有变化:

# mysql -e "SHOW SLAVE STATUS\G" | grep "Master_Log"
    Master_Log_File: mysql-bin.000003
    Read_Master_Log_Pos: 568210
    Relay_Master_Log_File: mysql-bin.000003
    Exec_Master_Log_Pos: 568210

slave 在 IO_THREAD 重新启动后获取更改:

# mysql -e "STOP SLAVE IO_THREAD; START SLAVE IO_THREAD;"
# mysql -e "SHOW SLAVE STATUS\G" | grep "Master_Log"
    Master_Log_File: mysql-bin.000003
    Read_Master_Log_Pos: 568333
    Relay_Master_Log_File: mysql-bin.000003
    Exec_Master_Log_Pos: 568333

更新:2014 年 7 月 18 日星期五 14:15:59 BST

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: $IP
                  Master_User: repluser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000007
          Read_Master_Log_Pos: 433
               Relay_Log_File: mysql-relay.000265
                Relay_Log_Pos: 283
        Relay_Master_Log_File: mysql-bin.000007
             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: 433
              Relay_Log_Space: 710
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: Yes
           Master_SSL_CA_File: /etc/mysql/ca-cert.pem
           Master_SSL_CA_Path: 
              Master_SSL_Cert: /etc/mysql/client-cert.pem
            Master_SSL_Cipher: 
               Master_SSL_Key: /etc/mysql/client-key.pem
        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: 1124732721
                  Master_UUID: 4412a455-e1d0-11e3-835a-5254007fe78d
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: /etc/mysql/ca-cert.pem
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
1 row in set (0.00 sec)
mysql replication
  • 2 2 个回答
  • 12770 Views

2 个回答

  • Voted
  1. Best Answer
    Michael - sqlbot
    2014-07-19T06:04:18+08:002014-07-19T06:04:18+08:00

    您所遇到的情况很容易在低流量情况下发生,尤其是当两台服务器被防火墙或其他实施状态数据包检测的设备隔开时。(例如,在 Amazon EC2/VPC 中可能会出现这种情况)。中间网络硬件可以“忘记”服务器之间的 TCP 连接,因为当没有数据被复制时,连接处于空闲状态。

    mysql> STOP SLAVE;
    Query OK, 0 rows affected (0.09 sec)
    
    mysql> CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD = 60;
    Query OK, 0 rows affected (0.13 sec)
    
    mysql> START SLAVE;
    Query OK, 0 rows affected (0.00 sec)
    

    当 slave 连接到 master 时,它会要求 master 每 60 秒向 binlog 流中注入一条心跳消息,但前提是在这段时间内没有复制事件 - 所以当有流量很大,但是当流量少时,会发送心跳事件,并且连接会保持活动状态。

    请注意,这CHANGE MASTER TO通常是一个破坏性命令,可以重置您的复制配置。在这种情况下,如果MASTER_HEARTBEAT_PERIOD是唯一提供的参数,则从配置不会被重置。

    http://dev.mysql.com/doc/refman/5.6/en/change-master-to.html

    还可以考虑将全局变量设置为slave_net_timeout比默认值更短的值,但不小于您用于主心跳周期的值的两​​倍。如果在配置的时间段内复制流上没有任何反应,这将导致从站断开并重试与主站的连接。

    • 8
  2. jynus
    2014-07-19T02:51:49+08:002014-07-19T02:51:49+08:00

    编辑:在我的第一个假设之后,我的下一个赌注是网络问题。使用迈克尔的建议,他们有我的赌注和投票。

    可能您的问题是wsrep_on = OFF+的组合DDL。在这种情况下,二进制日志可能会发生奇怪的事情(也就是它们可能没有被正确记录)。即使您只有一个节点,或者使用 galera-aware 命令隔离它,也要确保启用它。

    确保您也激活了log_slave_updates.

    master 和 slave 是同一个 Galera 集群的一部分吗?

    • 1

相关问题

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

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

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

  • PostgreSQL 9.0 Replication 和 Slony-I 有什么区别?

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

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