You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* first commit for docker support
* organizing files for use with docker
* script changes for docker compatibility
* reducing manual actions
* final adjustments
* update readme
MAKE SURE TO UNCOMMENT THE CORRECT LINES FOR THE VERSION YOU NEED. Check the blog post for more information.
106
+
That's it! You are now done and you have setup MySQL partitioning. We could execute the script manually with:
87
107
```
88
-
# MySQL 5.5
89
-
# MySQL 5.6 + MariaDB
90
-
# MySQL 8.x (NOT MariaDB!)
108
+
perl /usr/share/zabbix/mysql_zbx_part.pl
91
109
```
92
110
93
-
Uncomment the following line for Zabbix 5.4 and OLDER:
111
+
Then we can check and see if it worked with:
94
112
```
95
-
# $dbh->do("DELETE FROM auditlog_details WHERE NOT EXISTS (SELECT NULL FROM auditlog WHERE auditlog.auditid = auditlog_details.auditid)");
113
+
journalctl -t mysql_zbx_part
96
114
```
97
115
98
-
Comment the following line for Zabbix 6.4 and OLDER:
116
+
### Run in a Docker container
117
+
118
+
#1 Assuming you are in the root directory of this Git repository.
119
+
120
+
Edit the Dockerfile and uncomment the `ZABBIX_REPOSITORY` argument line according to your Docker host architecture (x86_64 or arm64), then build the Docker image:
That's it! You are now done and you have setup MySQL partitioning. We could execute the script manually with:
126
+
Create log directory. This folder will be mounted as a volume in the container, thus persisting the logs for future reference.
127
+
104
128
```
105
-
perl /usr/lib/zabbix/mysql_zbx_part.pl
129
+
mkdir logs
130
+
sudo chgrp 999 logs/
131
+
chmod 775 logs/
106
132
```
107
133
108
-
Then we can check and see if it worked with:
134
+
Create the `.env` file based on the [template](docker/.env.example) and edit it as per your environment.
135
+
109
136
```
110
-
journalctl -t mysql_zbx_part
137
+
cp docker/.env.example .env
138
+
sudo chown root: .env
139
+
sudo chmod 400 .env
140
+
```
141
+
142
+
The command below runs the container to perform the partitioning tasks and, when the perl script finishes executing, the container is automatically stopped and deleted.
143
+
144
+
```
145
+
sudo docker run --rm \
146
+
--name zabbix-db-partitioning \
147
+
-v ./logs:/logs \
148
+
--env-file ./.env \
149
+
zabbix-db-partitioning
150
+
```
151
+
152
+
After running the container, you can check the logs:
153
+
```
154
+
cat logs/mysql_zbx_part.log
155
+
```
156
+
157
+
Edit `root` user crontab:
158
+
159
+
```
160
+
crontab -e
111
161
```
112
162
163
+
Add the line in the crontab, adjusting the schedule. Change `project_dir` to the root directory of this Git repository on your file system.
- Import the [zbx_mysql_partitioning_template.yaml](docker/zbx_mysql_partitioning_template.yaml) template into your Zabbix;
172
+
- Add the template to an existing host or create a new host;
173
+
- Uncomment and configure the `zabbix_sender` variables in the `.env` file;
174
+
175
+
With that the container will send the result of executing the Perl script to your Zabbix and a trigger will be fired if an error occurs or if the script has not been executed in the last 2 days.
176
+
113
177
### Partitioning by week
114
178
NOTE: See version 2.1 for older (before 20-09-2021) partitioned databases. Otherwise use 3.0+ upwards (recommended to use current).
description: 'Checks if the script that performs the daily maintenance of the partitions of the "history" and "trends" tables in the MySQL database of Zabbix is being executed.'
name: 'Database tables partitioning script was not executed'
38
+
priority: AVERAGE
39
+
description: 'This means that, if not fixed, new partitions will not be created and Zabbix may stop logging metrics due to lack of partitions. See problem information in the partitioning script log.'
0 commit comments