MariaDB, Audit setting up log storage directories. Path 2

  • Last update: Apr 3, 2024
  • Views: 28
  • Author: Admin
MariaDB, Audit setting up log storage directories. Path 2

Colleagues hello to all.

In the last article, I told you how install audit plugin in MariaDB . After installing the plugin, it is disabled by default. In today's article, I will tell you how to enable auditing and configure the log storage path on the server.

 

Article content:

  1. List of all audit plugin variables.
  2. Create a directory to store the audit file.
  3. Setting up audit storage variables.
  4. Enable auditing.
  5. Check.
  6. Summary

 

1. List of all audit variables.

After installing the audit plugin, the variables of this plugin appear in the DBMS. To view the entire list of variables there is a command:

mariadb> SHOW GLOBAL VARIABLES LIKE 'server_audit%';

mariadb_audit_path_two

Screenshot shows a list of all audit variables.


 

2. Creating a directory to store the audit file.

The file where all actions will be recorded is called server_audit.log. By default, this file will be stored in the directory where your datadir database is stored.

 

2.1. I recommend that you create a separate directory for storing the audit.

$. mkdir /mariadb/audit

 

2.2. Assign the owner of the directory to the mysql group and user.

$. chown -R mysql:mysql /mariadb/audit

mariadb_audit_path_two


 

3. Setting up audit storage variables.

Now let's set up the audit variables themselves. The variable that is responsible for the name of the file and directory is called server_audit_file_path.

mariadb> SHOW GLOBAL VARIABLES LIKE 'server_audit_file_path';

mariadb_audit_path_two

 

3.1. Change the directory to the one we created earlier.

mariadb> SET GLOBAL server_audit_file_path = '/mariadb/audit/server_audit.log';

mariadb_audit_path_two

 

3.2. Now let's specify this variable also in the database configuration file, because if the database is restarted, the values ​​of this variable may be reset to the default values. The configuration file is located at /etc/my.cnf.d/server.cnf

$. vim /etc/my.cnf.d/server.cnf

mariadb_audit_path_two


 

4. Enable auditing.

Now that we have everything set up, we can now enable the audit itself. The plugin is disabled by default. To check if the plugin is enabled use the command:

mariadb> SHOW GLOBAL VARIABLES LIKE 'server_audit_logging';

mariadb_audit_path_two

Plugin disabled.

 

To enable the plugin, let's use the command:

mariadb> SET GLOBAL server_audit_logging = ON;

mariadb_audit_path_two

The plugin is enabled.

 

Now let's specify this variable also in the database configuration file, because if the database is restarted, the values ​​​​of this variable may be reset to the default values. The configuration file is located at /etc/my.cnf.d/server.cnf

$. vim /etc/my.cnf.d/server.cnf

mariadb_audit_path_two


 

5. Check.

After enabling the plugin, a server_audit.log file will appear in your directory where all actions that occur with the database will be recorded.

mariadb_audit_path_two

mariadb_audit_path_two


 

6. Results.

Colleagues, today we have successfully set up a storage directory for our audit files. In the next article, we will analyze how to register accounts...


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES