MariaDB, Audit log rotation, status check

MariaDB, Audit log rotation, status check

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.

 

Article content:

  1. Audit status.
  2. Audit log rotation.
  3. Total

 

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%';

mariadb_audit_path_3

We can see a lot of interesting things in this small result.

Parameter designations:

  • 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';

mariadb_audit_path_3

 

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

mariadb_audit_path_3

Save and restart the database.

 

Checking the result of adding parameters.

mariadb_audit_path_3

mariadb_audit_path_3

As you can see in the screenshot, we have 5 audit log files in total.


 

3. 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.

 

SIMILAR ARTICLES

MariaDB - ERROR Incorrect definition of table
MariaDB - ERROR Incorrect definition of table
MARIADB
Read more
Mariabackup backup - gzip compression
Mariabackup backup - gzip compression
MARIADB
Read more
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
MARIADB
Read more