MySQL Replication – Is `log_bin` Necessary on Slave?

MySQLmysql-5.7replication

I'm running out of disk space on a slave due to MySQL binary logs (mysql-bin.000xxx) being stored on the slave.

Here's the relevant portion of the slave's my.cnf:

binlog_format  = mixed
log_bin        = /var/log/mysql/mysql-bin.log
sync_binlog    = 1

I'm currently catching up to Master, so I expect to see a bunch of mysql-relay-bin.00xxxx's on Slave, but I'm not sure why it also needs mysql-bin.000xxx's.

The Master also has a lot of mysql-bin.000xxx's, but I expect it there.

Best Answer

If the slave is not a master to other slaves, then you do not need binary logging on the slave

To reclaim the space of those logs on the Slave immediately, run this

mysql> STOP SLAVE;
mysql> RESET MASTER;
mysql> START SLAVE;

This will hose all binary logs on the Slave.

You could then remove or comment out log_bin from the my.cnf of the Slave and restart mysqld