Mysql 复制已启用,但卡在“等待 binlog 更新”

chr*_*ris 11 mysql replication

我已经在现有数据库 (server-id=23) 和新数据库 (server-id=51) 之间设置了复制。

我已按照此 stackoverflow 问题中的步骤进行操作,但没有进行复制。

在主人身上:

State: Has sent all binlog to slave; waiting for binlog to be updated
Run Code Online (Sandbox Code Playgroud)

当我显示从属主机时:

+-----------+------+------+-------------------+-----------+
| Server_id | Host | Port | Rpl_recovery_rank | Master_id |
+-----------+------+------+-------------------+-----------+
|        51 |      | 3306 |                 0 |        23 |
+-----------+------+------+-------------------+-----------+
1 row in set (0.01 sec)
Run Code Online (Sandbox Code Playgroud)

在奴隶上:

State: Slave has read all relay log; waiting for the slave I/O thread to update it
Run Code Online (Sandbox Code Playgroud)

显示从机状态

           Slave_IO_State: Waiting for master to send event
 ...snip...
         Master_Log_File: mysql-bin.000001
      Read_Master_Log_Pos: 98
           Relay_Log_File: mysqld-relay-bin.000002
            Relay_Log_Pos: 244
    Relay_Master_Log_File: mysql-bin.000001
         Slave_IO_Running: Yes
        Slave_SQL_Running: Yes
Run Code Online (Sandbox Code Playgroud)

我需要做些什么来进行复制吗?

Rol*_*DBA 11

MySQL 复制运行得很好。我怎么知道 ?

Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Run Code Online (Sandbox Code Playgroud)

这表明两个复制线程是活动的。

要验证这一点,请在 Slave 上运行以下命令:

SELECT COUNT(1) ReplicationThreadCount FROM information_schema.processlist
WHERE user = 'system user';
Run Code Online (Sandbox Code Playgroud)

如果ReplicationThreadCount> 1,则复制运行良好。

您还可以运行SHOW PROCESSLIST;并查找用户为的两个连接system user

您提到的 Master 和 Slave 的两种状态对于正在运行的复制状态是正常的

当你向 Master 添加数据时,你可以通过查看数据来知道数据正在进入 Slave

  • Read_Master_Log_Pos
  • Exec_Master_Log_Pos
  • Relay_Log_Space

在 的输出中SHOW SLAVE STATUS\G。这些数字会发生变化,这表明它正在发挥作用。