Ad Widget

Collapse

Deploy Zabbix in Debian using Podman

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jose Garcia
    Junior Member
    • Apr 2022
    • 9

    #1

    Deploy Zabbix in Debian using Podman

    Hi everyone.

    I found a problem while deploying Zabbix with Podman. I deployed several times Zabbix using Podman in Debian and never had this issue before. I tried everything I know, and I'm still lost. Maybe someone could share some light about this problem.

    Versions are:
    • Debian v12.7
    • Podman v4.3.1
    • Lastest images for Zabbix server, Nginx frontend and PostgreSQL database.
    I used these commands (I followed official instructions):

    Code:
    podman run \
      --name postgres-server -t \
      -e POSTGRES_USER="zabbix" \
      -e POSTGRES_PASSWORD="zabbix_pwd" \
      -e POSTGRES_DB="zabbix" \
      --restart unless-stopped \
      -d postgres:latest
    
    podman run \
      --name zabbix-server-pgsql -t \
      -e DB_SERVER_HOST="postgres-server" \
      -e POSTGRES_USER="zabbix" \
      -e POSTGRES_PASSWORD="zabbix_pwd" \
      -e POSTGRES_DB="zabbix" \
      -p 10051:10051 \
      --restart unless-stopped \
      -d docker.io/zabbix/zabbix-server-pgsql:latest
    
    podman run \
      --name zabbix-web-nginx-pgsql -t \
      -e ZBX_SERVER_HOST="zabbix-server-pgsql" \
      -e DB_SERVER_HOST="postgres-server" \
      -e POSTGRES_USER="zabbix" \
      -e POSTGRES_PASSWORD="zabbix_pwd" \
      -e POSTGRES_DB="zabbix" \
      -p 8443:8443 \
      -p 8080:8080 \
      --restart unless-stopped \
      -d docker.io/zabbix/zabbix-web-nginx-pgsql:latest
    Every container is up and running:

    Code:
    podman ps
    
    CONTAINER ID  IMAGE                                           COMMAND               CREATED      STATUS            PORTS                                           NAMES
    6089ee1e15a7  docker.io/library/postgres:latest               postgres              2 hours ago  Up 2 minutes ago                                                  postgres-server
    26f0b71f989d  docker.io/zabbix/zabbix-server-pgsql:latest     /usr/sbin/zabbix_...  2 hours ago  Up 2 minutes ago  0.0.0.0:10051->10051/tcp                        zabbix-server-pgsql
    4a21dac97036  docker.io/zabbix/zabbix-web-nginx-pgsql:latest                        2 hours ago  Up 2 minutes ago  0.0.0.0:8080->8080/tcp, 0.0.0.0:8443->8443/tcp  zabbix-web-nginx-pgsql
    The first problem I detected was both server and frontend can not connect to database:

    Code:
    podman logs zabbix-web-nginx-pgsql
    podman logs zabbix-server-pgsql
    
    **** PostgreSQL server is not available. Waiting 5 seconds...
    I checked and there was a Zabbix database created, but no tables:

    Code:
    podman exec postgres-server psql -U zabbix zabbix -c "\dt"
    So I created everything and checked again, and I see no problems with the database, everything was ready to accept connections:

    Code:
    podman logs postgres-server
    
    PostgreSQL Database directory appears to contain a database; Skipping initialization
    
    2024-11-01 18:14:27.888 UTC [1] LOG:  starting PostgreSQL 17.0 (Debian 17.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
    2024-11-01 18:14:27.889 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
    2024-11-01 18:14:27.889 UTC [1] LOG:  listening on IPv6 address "::", port 5432
    2024-11-01 18:14:27.900 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
    2024-11-01 18:14:27.914 UTC [24] LOG:  database system was shut down at 2024-11-01 18:14:27 UTC
    2024-11-01 18:14:27.927 UTC [1] LOG:  database system is ready to accept connections
    Still, the problem persists and containers can not connect to database.

    The problem when I try to connect to the front end is:​

    Code:
    curl http://192.168.1.138:8080
    curl: (56) Recv failure: Connection reset by remote host
    I also try to use this script:



    But the same problems appeared.

    Someone has the same troubles?

    Thanks everyone.
  • Jose Garcia
    Junior Member
    • Apr 2022
    • 9

    #2
    Hello everyone.

    I don't have much experience with Podman, but I think I have found an applicable solution to deploy Zabbix on Debian using this technology.

    Although Zabbix documentation says that version 7.0.6 works with PostgreSQL version 17, when using that version of containers, Zabbix doesn't work. However, you can use version 16, and everything works.

    I leave a solution here in case it is of help for someone.

    Code:
    #!/bin/bash
    
    # -- Pod -- #
    
    POD_NAME='zabbix'
    
    # -- Database -- #
    
    CONTAINER_DB_SERVER_HOST='postgresql-server-01'
    POSTGRES_DB='zabbix_db'
    POSTGRES_USER='zabbix'
    POSTGRES_PASSWORD='zabbix'
    POSTGRES_PATH='/var/lib/postgresql/data'
    POSTGRES_DATA_DIRECTORY='/home/user/postgresql/data'
    
    # -- Server -- #
    
    CONTAINER_ZABBIX_SERVER='zabbix-server-pgsql-01'
    ZABBIX_SERVER_AUTOHANODENAME='hostname'
    ZABBIX_SERVER_HANODENAME='zabbix-node-01'
    
    # -- Frontend -- #
    
    CONTAINER_ZABBIX_FRONTEND='zabbix-web-nginx-pgsql-01'
    PHP_TZ='ETC/UTC'
    
    # -- Zabbix Agent2-- #
    
    CONTAINER_ZABBIX_AGENT2='zabbix-agent2-01'
    ZBX_SERVER_HOST="$CONTAINER_ZABBIX_SERVER"
    
    # ---------------------------------------------------------------------------- #
    
    podman pod create \
      --name "$POD_NAME" \
      -p 8080:8080 \
      -p 10051:10051
    
    # ---------------------------------------------------------------------------- #
    
    podman run \
      -dt \
      --log-level=debug \
      --restart unless-stopped \
      --pod="$POD_NAME" \
      --name "$CONTAINER_DB_SERVER_HOST" \
      -e POSTGRES_DB="$POSTGRES_DB" \
      -e POSTGRES_USER="$POSTGRES_USER" \
      -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
      docker.io/postgres:16.6-alpine
    
    # --- #
    
    podman run \
      -dt \
      --log-level=debug \
      --restart unless-stopped \
      --pod="$POD_NAME" \
      --name "$CONTAINER_ZABBIX_SERVER" \
      -e DB_SERVER_HOST="$CONTAINER_DB_SERVER_HOST" \
      -e POSTGRES_DB="$POSTGRES_DB" \
      -e POSTGRES_USER="$POSTGRES_USER" \
      -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
      -e ZBX_AUTOHANODENAME="$ZABBIX_SERVER_AUTOHANODENAME" \
      -e ZBX_HANODENAME="$ZABBIX_SERVER_HANODENAME" \
      docker.io/zabbix/zabbix-server-pgsql:7.0-alpine-latest
    
    # --- #
    
    podman run \
      -dt \
      --log-level=debug \
      --restart unless-stopped \
      --pod="$POD_NAME" \
      --name "$CONTAINER_ZABBIX_FRONTEND" \
      -e DB_SERVER_HOST="$CONTAINER_DB_SERVER_HOST" \
      -e POSTGRES_DB="$POSTGRES_DB" \
      -e POSTGRES_USER="$POSTGRES_USER" \
      -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
      -e ZBX_SERVER_HOST="$ZBX_SERVER_HOST" \
      -e PHP_TZ="$PHP_TZ" \
      docker.io/zabbix/zabbix-web-nginx-pgsql:7.0-alpine-latest
    
    # --- #
    
    podman run \
      -dt \
      --log-level=debug \
      --restart=always \
      --pod="$POD_NAME" \
      --name "$CONTAINER_ZABBIX_AGENT2" \
      -e ZBX_SERVER_HOST="$ZBX_SERVER_HOST" \
      docker.io/zabbix/zabbix-agent2:7.0-alpine-latest
    
    # ---------------------------------------------------------------------------- #
    I hope it will be useful.

    Comment

    Working...