MariaDB, Audit log rotation, status check
Last updated: May 25, 2022
Colleagues hello to all.
In previous articles, we installed the audit plugin on MariaDB, then we set up a directory to store the audit files. In today's last article on this topic, we will analyze all the other features of this plugin.
- Audit status.
- Audit log rotation.
1. Audit status.
As you already know, no system can do without errors, and the MariaDB DBMS is no exception. The audit plugin can also make some mistakes with the failure to record events that happen to the database. To view the audit status, there is check status command.
mariadb> SHOW STATUS LIKE 'server_audit%';
We can see a lot of interesting things in this small result.
- Server_audit_active - Values ON means that auditing is enabled. If the value is OFF, then auditing is disabled.
- Server_audit_current_log - Points to the location of the audit file in which various events related to the database are recorded.
- Server_audit_last_error - If there is any error with logging, here will be a brief description of the problem.
- Server_audit_writes_failed - The number of entries that were written to the log with an error.
2. Rotation of audit logs.
Audit log rotation is disabled by default. Command to check rotation:
mariadb> SHOW VARIABLES LIKE 'server_audit_file_rotate_now';
If you want to enable log file rotation, then I would recommend enabling it with additional variables.
- server_audit_file_rotate_now - Enables rotation.
- server_audit_file_rotate_size - The maximum size of the log file by the given number of bytes. The default is 10 megabytes.
- server_audit_file_rotations - Number of audit logs to keep. By default, 9 logs will be kept, then they will be overwritten one by one. You can specify 0 if you don't want the logs to be overwritten.
Let's turn on the rotation. To do this, add all the parameters to the configuration file.
$. vim /etc/my.cnf.d/server.cnf
Save and restart the database.
Checking the result of adding parameters.
As you can see in the screenshot, we have 5 audit log files in total.
As a result, colleagues, we successfully installed and configured the audit plugin on the MariaDB database server. Enjoy.
Thank you all, I hope that my article helped you in some way.