Configure Database Storage and Logging for Zabbix
Details on configuring PostgreSQL and Apache for Zabbix on OpenWrt, including the PHP configuration, on prepared storage.
Prerequisites
For PostgreSQL, as well as for robust logging, storage which is persistent, large, and can be written often is required.
See Prepare storage for a way to set this up.
Move the database from volatile storage to persistent storage
The default location for the PostgreSQL database on OpenWrt is
/var/postgresql/data is on a RAM disk (tmpfs) and goes away on every
reboot. We want to change that.
service postgresql stop- Edit
/etc/config/postgresqlso thatPGDATApoints to/srv/postgresql/data. mv /var/postgresql /srv/.service postgresql start.- Verify postgresql is running (E.g. via
ps w) andlogread.
Create the Zabbix database
NOTE This is a simplified setup. For more secure configuration review the documentation at https://www.zabbix.com/documentation/7.0/en/manual/best_practices/security/access_control/postgresql.
- Download the Zabbix source code for Zabbix 7.0
- Extract the source code on your workstation
- On the OpenWrt Zabbix server:
Create the database user
createuser -U postgres -h /var/run/postgresql --pwprompt zabbixand enter a password for the Zabbix database user. You will need this later.
Execute:
createdb -U postgres -h /var/run/postgresql -O zabbix -E Unicode -T template0 zabbixOn your workstation, in the Zabbix source code directory:
cd database/postgresql scp -O schema.sql images.sql data.sql root@<your-openwrt-zabbix-server>:On your OpenWrt Zabbix server (for more details see https://www.zabbix.com/documentation/7.0/en/manual/appendix/install/db_scripts)
cd ~ psql -U zabbix -h /var/run/postgresql zabbix < schema.sql psql -U zabbix -h /var/run/postgresql zabbix < images.sql psql -U zabbix -h /var/run/postgresql zabbix < data.sql