Skip to content

Commit a54a39f

Browse files
authored
Merge pull request #581 from percona/ps-10217-8.4
PS-10217 [DOCS] - Audit log filter installation cannot be done with I…
2 parents ff0424d + 884e0cf commit a54a39f

File tree

1 file changed

+115
-10
lines changed

1 file changed

+115
-10
lines changed

docs/install-audit-log-filter.md

Lines changed: 115 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,129 @@
1-
# Install the Audit Log Filter
1+
# Install the audit log filter
22

3-
The `plugin_dir` system variable defines the component library location. If needed, at server startup, set the `plugin_dir` variable.
3+
## Installation script
44

5-
In the `share` directory, locate the `audit_log_filter_linux_install.sql ` script.
5+
The recommended way to install the component is to use the `audit_log_filter_linux_install.sql` script, located in the `share` directory, which creates the required tables before installing the component.
66

7-
At the time you run the script, you can select the database used to store the JSON filter tables.
7+
### Prerequisites
88

9-
* If the component is loaded, the installation script takes the database name from the `audit_log_filter.database` variable
10-
* If the component is not loaded, but passes the `-D db_name` to the mysql client when the installation script runs, uses the `db_name`.
11-
* If the component is not loaded and the `-D` option is not provided, the installation script creates the required tables in the default database name `mysql`.
9+
The `plugin_dir` system variable defines the component library location. If needed, set the `plugin_dir` variable at server startup.
10+
11+
### Database selection
12+
13+
The script determines the target database using the following priority:
14+
15+
* If the component is already loaded, the script uses the database name from the `audit_log_filter.database` variable
16+
17+
* If the component is not loaded, but you pass the `-D db_name` option to the mysql client when running the script, it uses the specified `db_name`
18+
19+
* If the component is not loaded and no `-D` option is provided, you must specify the `mysql` database when running the script
1220

1321
You can also designate a different database with the `audit_log_filter.database` system variable. The database name cannot be NULL or exceed 64 characters. If the database name is invalid, the audit log filter tables are not found.
1422

15-
To install the component, run the following command:
23+
### Install the component
24+
25+
To install the component using the script, you must specify the `mysql` database. You can do this in two ways:
26+
27+
* Option 1: Run the script from the command line with the `-D mysql` option:
28+
29+
```{.bash data-prompt="$"}
30+
mysql -u root -p -D mysql < /path/to/mysql/share/audit_log_filter_linux_install.sql
31+
```
32+
33+
* Option 2: Connect to `mysql` database and run the script interactively:
34+
35+
```{.bash data-prompt="mysql>"}
36+
mysql> use mysql;
37+
mysql> source /path/to/mysql/share/audit_log_filter_linux_install.sql;
38+
```
39+
40+
Replace `/path/to/mysql/share/` with the actual path to your MySQL installation's share directory.
41+
42+
### Verify installation
43+
44+
After running the script, verify that the required tables are created:
45+
46+
```{.bash data-prompt="mysql>"}
47+
mysql> show tables in mysql like 'aud%';
48+
```
49+
50+
??? example "Expected output"
51+
52+
```{.text .no-copy}
53+
+------------------------+
54+
| Tables_in_mysql (aud%) |
55+
+------------------------+
56+
| audit_log_filter |
57+
| audit_log_user |
58+
+------------------------+
59+
2 rows in set (0.00 sec)
60+
```
61+
62+
## Alternative: INSTALL COMPONENT method
63+
64+
You can also install the component using the `INSTALL COMPONENT` command, but this method does not create the required tables and will cause filter operations to fail.
65+
66+
### Verify component installation
67+
68+
Check that the component is properly installed:
1669
1770
```{.bash data-prompt="mysql>"}
18-
mysql> INSTALL COMPONENT 'file://component_audit_log_filter';
71+
mysql> select * from mysql.component;
1972
```
2073
21-
Find more information in the [INSTALL COMPONENT](install-component.md) document.
74+
??? example "Expected output"
75+
76+
```{.text .no-copy}
77+
+--------------+--------------------+------------------------------------+
78+
| component_id | component_group_id | component_urn |
79+
+--------------+--------------------+------------------------------------+
80+
| 1 | 1 | file://component_percona_telemetry |
81+
| 2 | 2 | file://component_audit_log_filter |
82+
+--------------+--------------------+------------------------------------+
83+
2 rows in set (0.00 sec)
84+
```
85+
86+
### Test filter functionality
87+
88+
Test that the audit log filter is working correctly:
89+
90+
```{.bash data-prompt="mysql>"}
91+
mysql> SELECT audit_log_filter_set_filter('log_all', '{"filter": {"log": true}}');
92+
```
93+
94+
??? example "Expected output"
95+
96+
```{.text .no-copy}
97+
+---------------------------------------------------------------------+
98+
| audit_log_filter_set_filter('log_all', '{"filter": {"log": true}}') |
99+
+---------------------------------------------------------------------+
100+
| ERROR: Failed to check filtering rule name existence |
101+
+---------------------------------------------------------------------+
102+
1 row in set (0.00 sec)
103+
```
104+
105+
!!! note
106+
107+
This error occurs when the component is installed without the required tables. Using the SQL script prevents this issue.
108+
109+
### Fix missing tables
110+
111+
If you have already installed the audit log component but are missing the required tables, you can run the `audit_log_filter_linux_install.sql` script to create the audit tables in the `mysql` database:
112+
113+
```{.bash data-prompt="$"}
114+
mysql -u root -p -D mysql < /path/to/mysql/share/audit_log_filter_linux_install.sql
115+
```
116+
117+
Or interactively:
118+
119+
```{.bash data-prompt="mysql>"}
120+
mysql> use mysql;
121+
mysql> source /path/to/mysql/share/audit_log_filter_linux_install.sql;
122+
```
123+
124+
This operation creates the missing tables without reinstalling the component.
125+
126+
## Additional information
22127
23128
To upgrade from `audit_log_filter` plugin in Percona Server 8.4 to `component_audit_log_filter` component in Percona Server {{vers}}, do the [manual upgrade](upgrade-components.md).
24129

0 commit comments

Comments
 (0)