MySQL中master binary log和slave binary log有什么区别?如何在两台服务器上实现相同的二进制日志?

what is the difference between master binary log and slave binary log in MySQL? How can I achieve same binary logs on both servers?

我有主服务器和从服务器。复制完成。现在我确实在两台服务器上都执行了以下步骤。

mysql> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |      1608 |
+------------------+-----------+

1 rows in set (0.00 sec)

mysql> flush binary logs;

mysql> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |      1608 |
| mysql-bin.000002 |       154 |
+------------------+-----------+
2 rows in set (0.00 sec)

之后,我 运行 在我的 master 中插入查询。 然后检查我的主二进制日志。尺寸增加。但是奴隶没有变化。但我想增加与主服务器相同的从属二进制日志。 原因是我想用二进制日志从slave做增量备份

您需要启用 log-slave-updates(在 MySQL 8.0.3 之前默认禁用)以包含从主服务器接收到的更改:

Normally, a slave does not write any updates that are received from a master server to its own binary log. This option causes the slave to write the updates performed by its SQL thread to its own binary log. For this option to have any effect, the slave must also be started with the --log-bin option to enable binary logging. --log-slave-updates is used when you want to chain replication servers.