MariaDB/MySQL Binary Logs Purge
When you use replication (Master/Slave) in MariaDB it will create log files, usually in the /var/lib/mariadb folder. These can grow to be a significant size and will require regular maintenance.
These files are kept to allow programatic rollback should the need arise, but if you're already replicating to a slave then its fairly safe to purge them back to a point.
IMPORTANT: DO NOT DELETE THEM MANUALLY
Since replication will be using one of these files we need to identify which…. On the SLAVE run
- SHOW SLAVE STATUS\G
You should see something like this:
Master_Log_File: master1-bin.000153 Read_Master_Log_Pos: 577376951 Relay_Log_File: master1-relay-bin.000005 Relay_Log_Pos: 577359099 Relay_Master_Log_File: master1-bin.000153 Slave_IO_Running: Yes Slave_SQL_Running: Yes
We're interested in the "Relay_Master_Log_File: master1-bin.000153" which tells us which log the slave is receiving statements from. We can purge UP TO THIS but not including this. To purge all the previous logfiles you can issue a command (substituting your Relay_Master_log_file):
- PURGE BINARY LOGS TO 'master1-bin.000153';
And as if by magic, all the previous log-files will be purged.