mysqldatabase-replicationmysql-backupbinary-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?


I have master and slave servers. Replication done. Now I did follow the below steps 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)

After that I ran insert query in my master. Then checked my master binary logs. size incresed. But there is no change in slave. But I wants to increase the same in slave binary log as master. The reason is I wants to take incremental backup from slave by using binary logs.


Solution

  • You need to enable log-slave-updates (which is disabled by default before MySQL 8.0.3) to include changes that are received from the master:

    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.