Ad Widget

Collapse

Proxy 7.2 container fails to open a SQLite3 file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    Proxy 7.2 container fails to open a SQLite3 file

    I recently ran a Zabbix Proxy (7.0) container on a Mikrotik router (arm64). Then decided to update the container (to 7.2), so I removed the old container and added a new one with the new tag version. Now it won't start anymore.
    When I start the container, it stops right after.
    Checking the logs, I found that the proxy fails to initialize because it cannot open the SQLite3 database.
    Code:
    20:13:05 container,info,debug 1:20241224:231305.579 Starting Zabbix Proxy (active) [mikrotik]. Zabbix 7.2.1 (revision 67f3c83).
    20:13:05 container,info,debug 1:20241224:231305.579 **** Enabled features ****
    20:13:05 container,info,debug 1:20241224:231305.579 SNMP monitoring: YES
    20:13:05 container,info,debug 1:20241224:231305.579 IPMI monitoring: YES
    20:13:05 container,info,debug 1:20241224:231305.579 Web monitoring: YES
    20:13:05 container,info,debug 1:20241224:231305.579 VMware monitoring: YES
    20:13:05 container,info,debug 1:20241224:231305.579 ODBC: YES
    20:13:05 container,info,debug 1:20241224:231305.579 SSH support: YES
    20:13:05 container,info,debug 1:20241224:231305.579 IPv6 support: YES
    20:13:05 container,info,debug 1:20241224:231305.579 TLS support: YES
    20:13:05 container,info,debug 1:20241224:231305.579 **************************
    20:13:05 container,info,debug 1:20241224:231305.579 using configuration file: /etc/zabbix/zabbix_proxy.conf
    20:13:05 container,info,debug 1:20241224:231305.580 cannot open database file "/var/lib/zabbix/db_data/mikrotik.sqlite": [2] No such file or directory
    20:13:05 container,info,debug 1:20241224:231305.580 creating database ...
    20:13:05 container,info,debug 1:20241224:231305.580 [Z3001] connection to database '/var/lib/zabbix/db_data/mikrotik.sqlite' failed: [0] unable to open atabase file
    20:13:05 container,info,debug 1:20241224:231305.580 cannot initialize database: cannot open database
    The actual SQLite3 file (/var/lib/zabbix/db_data/mikrotik.sqlite) should be created dynamically when the proxy starts, as it is not a permanent database.
    If the Proxy fails to open the database file, it's usually due to lack of permissions on the directory, but this doesn't seem to be the case this time.


    For testing, I then tried to start a new Proxy container on a fresh Docker installation running on a x86 Linux.
    Code:
    docker run --name zproxy \
    --restart no \
    --dns-search "domain.name" \
    --dns "192.168.8.5" \
    -p 10051:10051 \
    -w /var/lib/zabbix \
    -v ./zabbix_proxy/enc:/var/lib/zabbix/enc \
    -e ZBX_HOSTNAME="mikrotik" \
    -e ZBX_SERVER_HOST="zabbix.server" \
    -e ZBX_PROXYMODE=0 \
    -e ZBX_TIMEOUT=4 \
    -e ZBX_ENABLEREMOTECOMMANDS=1 \
    -e ZBX_PROXYOFFLINEBUFFER=720 \
    -e ZBX_STARTVMWARECOLLECTORS=1 \
    -e ZBX_TLSCONNECT="psk" \
    -e ZBX_TLSPSKFILE="/var/lib/zabbix/enc/zabbix_proxy.psk" \
    -e ZBX_TLSPSKIDENTITY="keyId" \
    -e ZBX_PROXYCONFIGFREQUENCY=60 \
    -d zabbix/zabbix-proxy-sqlite3:l-7.2-latest
    The problem was the same. The container is created, but stops because it fails to create the SQLite database, despite the "creating database" message.
    Code:
    [root@test ~]# docker logs zproxy
    Preparing Zabbix proxy
    Starting Zabbix Proxy (active) [mikrotik]. Zabbix 7.2.1 (revision 67f3c83).
    Press Ctrl+C to exit.
    
    1:20241227:200805.603 Starting Zabbix Proxy (active) [mikrotik]. Zabbix 7.2.1 (revision 67f3c83).
    1:20241227:200805.603 **** Enabled features ****
    1:20241227:200805.603 SNMP monitoring: YES
    1:20241227:200805.603 IPMI monitoring: YES
    1:20241227:200805.603 Web monitoring: YES
    1:20241227:200805.603 VMware monitoring: YES
    1:20241227:200805.603 ODBC: YES
    1:20241227:200805.603 SSH support: YES
    1:20241227:200805.603 IPv6 support: YES
    1:20241227:200805.603 TLS support: YES
    1:20241227:200805.603 **************************
    1:20241227:200805.603 using configuration file: /etc/zabbix/zabbix_proxy.conf
    1:20241227:200805.603 cannot open database file "/var/lib/zabbix/db_data/mikrotik.sqlite": [2] No such file or directory
    1:20241227:200805.604 creating database ...
    1:20241227:200805.604 [Z3001] connection to database '/var/lib/zabbix/db_data/mikrotik.sqlite' failed: [0] unable to open database file
    1:20241227:200805.604 cannot initialize database: cannot open database

    This is strange because the database volume should be writable inside the container.
    It works for version 7.0, but fails for 7.2.

    So, I'm not sure why it fails to open the SQLite file.

    Has anyone seen this problem before?​
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #2
    I tested a clean setup for the Zabbix Proxy 7.2 on a fresh Oracle Linux 9.5 and found the same error.
    Again, it failed because it couldn't start the SQLite3 database file.

    So, it seems that this is not an isolated container problem.

    Here's the steps to reproduce it:
    1. Install the default Zabbix Proxy from packages.
    2. Edit the configuration file "/etc/zabbix/zabbix_proxy.conf" and set the "DBName" parameter as instructed in the documentation.
    3. Start the Proxy. The start should fail.

    SystemCTL:
    Code:
    $ sudo systemctl start zabbix-proxy.service
    Job for zabbix-proxy.service failed because the service did not take the steps required by its unit configuration.
    See "systemctl status zabbix-proxy.service" and "journalctl -xeu zabbix-proxy.service" for details.

    Zabbix Proxy log:
    Code:
    42656:20241231:121203.761 Starting Zabbix Proxy (active) [host]. Zabbix 7.2.1 (revision 67f3c838b2a).
    42656:20241231:121203.761 **** Enabled features ****
    42656:20241231:121203.761 SNMP monitoring: YES
    42656:20241231:121203.761 IPMI monitoring: YES
    42656:20241231:121203.761 Web monitoring: YES
    42656:20241231:121203.761 VMware monitoring: YES
    42656:20241231:121203.761 ODBC: YES
    42656:20241231:121203.761 SSH support: YES
    42656:20241231:121203.761 IPv6 support: YES
    42656:20241231:121203.761 TLS support: YES
    42656:20241231:121203.761 **************************
    42656:20241231:121203.761 using configuration file: /etc/zabbix/zabbix_proxy.conf
    42656:20241231:121203.762 cannot open database file "/var/lib/zabbix/zabbix_proxy.db": [2] No such file or directory
    42656:20241231:121203.762 creating database ...
    42656:20241231:121203.762 [Z3001] connection to database '/var/lib/zabbix/zabbix_proxy.db' failed: [0] unable to open database file
    42656:20241231:121203.762 cannot initialize database: cannot open database

    JournalCTL:
    Code:
    The job identifier is 2174.
    Dec 31 12:06:58 [HOST] systemd[1]: zabbix-proxy.service: Can't open PID file /run/zabbix/zabbix_proxy.pid (yet?) after start: Operation not permitted
    Dec 31 12:06:58 [HOST] systemd[1]: zabbix-proxy.service: Failed with result 'protocol'.
    Subject: Unit failed
    Defined-By: systemd
    The unit zabbix-proxy.service has entered the 'failed' state with result 'protocol'.
    Dec 31 12:06:58 [HOST] systemd[1]: Failed to start Zabbix Proxy.
    Subject: A start job for unit zabbix-proxy.service has failed

    Zabbix Proxy configuration file:
    Code:
    Server=192.168.8.12
    Hostname=zproxy
    LogFile=/var/log/zabbix/zabbix_proxy.log
    LogFileSize=10
    PidFile=/run/zabbix/zabbix_proxy.pid
    SocketDir=/run/zabbix
    DBName=/etc/zabbix/zabbix_proxy.db
    DBUser=zabbix
    ProxyBufferMode=hybrid
    ProxyMemoryBufferSize=16M
    SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
    Timeout=4
    LogSlowQueries=3000
    Include=/etc/zabbix/zabbix_proxy.d/*.conf
    StatsAllowedIP=127.0.0.1

    The directory "/var/lib/zabbix" is owned by the Zabbix user and should be writable by the Proxy.
    Code:
    $ ls -lahd /var/lib/zabbix
    drwxr-xr-x 2 zabbix zabbix 6 Dec 31 11:49 /var/lib/zabbix

    I did enable debug logging, but it didn't show anything helpful.
    So, I'm not sure why the Proxy won't start the SQLite3 file.

    Version 7.0 works, but 7.2 does not.

    Is anyone having this issue?

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #3
      There's a report on ZBX-25782 for this issue.
      I've tested on a Debian 12 and Ubuntu 24 system, and the Proxy works on them.

      So, it seems that the problem may be related to the Fedora (RHEL) family.
      Last edited by markfree; 02-01-2025, 01:48.

      Comment

      • markfree
        Senior Member
        • Apr 2019
        • 868

        #4
        The SQLite3 DB file can be created manually as a workaround as this issue is limited to the DB file creation
        It requires the "zabbix-sql-scripts" and "sqlite" packages to be installed.
        Code:
        sqlite3 /var/lib/zabbix/proxy.db < /usr/share/zabbix/sql-scripts/sqlite3/proxy.sql
        Zabbix Proxy 7.2.2rc1 is already available in the "unstable" branch with a fix for this issue.
        Last edited by markfree; 03-01-2025, 14:24.

        Comment

        Working...