Menu

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.

  1. service postgresql stop
  2. Edit /etc/config/postgresql so that PGDATA points to /srv/postgresql/data.
  3. mv /var/postgresql /srv/.
  4. service postgresql start.
  5. Verify postgresql is running (E.g. via ps w) and logread.

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.

  1. Download the Zabbix source code for Zabbix 7.0
  2. Extract the source code on your workstation
  3. On the OpenWrt Zabbix server:
    1. Create the database user

      createuser -U postgres -h /var/run/postgresql --pwprompt zabbix
      

      and enter a password for the Zabbix database user. You will need this later.

    2. Execute:

      createdb -U postgres -h /var/run/postgresql -O zabbix -E Unicode -T template0 zabbix
      
    3. On your workstation, in the Zabbix source code directory:

      cd database/postgresql
      scp -O schema.sql images.sql data.sql root@<your-openwrt-zabbix-server>:
      
    4. 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