zabbix / zabbix-docker

Official Zabbix Dockerfiles
https://www.zabbix.com
GNU Affero General Public License v3.0
2.33k stars 1.36k forks source link

zabbix-server-pgsql run failed #1270

Closed qinweizhen1 closed 6 months ago

qinweizhen1 commented 6 months ago

when I buid image by zabbix-docker-6.4\Dockerfiles\build-pgsql\ubuntu\DockerFile. try run image error info:/usr/sbin/zabbix_server: error while loading shared libraries: libnetsnmp.so.35: cannot open shared object file: No such file or directory

dotneft commented 6 months ago

how did you build? Please share steps.

qinweizhen1 commented 6 months ago

step 1:I build and make in wsl(ubuntu 20.04) with the zabbix-server source code(6.4.12): ./configure --datadir=/usr/lib --libdir=/usr/lib/zabbix --prefix=/usr --sysconfdir=/etc/zabbix --enable-agent --enable-agent2 --enable-ipv6 --enable-proxy --enable-server --enable-webservice --with-ldap --with-libcurl --with-libmodbus --with-libpcre2 --with-libxml2 --with-net-snmp --with-openipmi --with-openssl --with-postgresql --with-ssh --with-unixodbc --enable-java --silent &&\
make step 2: build image :docker build -t zabbix-server . Dockerfile Info :

ARG MAJOR_VERSION=6.4 ARG ZBX_VERSION=${MAJOR_VERSION}.12

FROM ubuntu:jammy

ARG MAJOR_VERSION ARG ZBX_VERSION ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git

ENV TERM=xterm \ ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \ MIBDIRS=/var/lib/mibs/ietf:/var/lib/mibs/iana:/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL \ NMAP_PRIVILEGED=""

LABEL org.opencontainers.image.authors="Alexey Pustovalov alexey.pustovalov@zabbix.com" \ org.opencontainers.image.description="Zabbix server with PostgreSQL database support" \ org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" \ org.opencontainers.image.licenses="GPL v2.0" \ org.opencontainers.image.source="${ZBX_SOURCES}" \ org.opencontainers.image.title="Zabbix server (PostgreSQL)" \ org.opencontainers.image.url="https://zabbix.com/" \ org.opencontainers.image.vendor="Zabbix LLC" \ org.opencontainers.image.version="${ZBX_VERSION}"

STOPSIGNAL SIGTERM

COPY ["src/zabbix_server/zabbix_server", "/usr/sbin/zabbix_server"] COPY ["src/zabbix_get/zabbix_get", "/usr/bin/zabbix_get"] COPY ["src/zabbix_sender/zabbix_sender", "/usr/bin/zabbix_sender"] COPY ["conf/zabbix_server.conf", "/etc/zabbix/zabbix_server.conf"] COPY ["database/postgresql/create_server.sql.gz", "/usr/share/doc/zabbix-server-postgresql/create.sql.gz"] COPY ["database/postgresql/timescaledb/schema.sql", "/usr/share/doc/zabbix-server-postgresql/timescaledb.sql"] COPY ["database/postgresql/timescaledb/option-patches/with-compression/.sql", "/usr/share/doc/zabbix-server-postgresql/option-patches/with-compression/"] COPY ["database/postgresql/timescaledb/option-patches/without-compression/.sql", "/usr/share/doc/zabbix-server-postgresql/option-patches/without-compression/"]

RUN --mount=type=cache,target=/var/lib/apt/,sharing=locked \ set -eux && \ echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d && \ INSTALL_PKGS="bash \ tini \ traceroute \ nmap \ tzdata \ ca-certificates \ iputils-ping \ traceroute \ fping \ libcurl4 \ libevent-2.1 \ libevent-pthreads-2.1 \ libopenipmi0 \ libpcre2-8-0 \ libpq5 \ libsnmp40 \ libssh-4 \ libssl3 \ libxml2 \ postgresql-client \ snmp-mibs-downloader \ gzip \ unixodbc" && \ apt-get -y update && \ DEBIAN_FRONTEND=noninteractive apt-get -y \ --no-install-recommends install \ ${INSTALL_PKGS} && \ groupadd \ --system \ --gid 1995 \ zabbix && \ useradd \ --system \ --comment "Zabbix monitoring system" \ -g zabbix \ -G dialout \ --uid 1997 \ --shell /sbin/nologin \ --home-dir /var/lib/zabbix/ \ zabbix && \ chgrp zabbix /usr/bin/nmap && \ setcap cap_net_raw+eip /usr/bin/nmap && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ mkdir -p /usr/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ mkdir -p /var/lib/zabbix/mibs && \ mkdir -p /var/lib/zabbix/modules && \ mkdir -p /var/lib/zabbix/snmptraps && \ mkdir -p /var/lib/zabbix/ssh_keys && \ mkdir -p /var/lib/zabbix/ssl && \ mkdir -p /var/lib/zabbix/ssl/certs && \ mkdir -p /var/lib/zabbix/ssl/keys && \ mkdir -p /var/lib/zabbix/ssl/ssl_ca && \ mkdir -p /usr/share/doc/zabbix-server-postgresql && \ chown --quiet -R zabbix:root /etc/zabbix/ /var/lib/zabbix/ && \ chgrp -R 0 /etc/zabbix/ /var/lib/zabbix/ && \ chmod -R g=u /etc/zabbix/ /var/lib/zabbix/ && \ apt-get -y autoremove && \ apt-get -y clean

EXPOSE 10051/TCP

WORKDIR /var/lib/zabbix

VOLUME ["/var/lib/zabbix/snmptraps", "/var/lib/zabbix/export"]

COPY ["docker-entrypoint.sh", "/usr/bin/"]

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/bin/docker-entrypoint.sh"]

USER 1997

CMD ["/usr/sbin/zabbix_server", "--foreground", "-c", "/etc/zabbix/zabbix_server.conf"]

step 3: run image -- docker run -e DB_SERVER_HOST= -e POSTGRES_USER= -e POSTGRES_PASSWORD=*** -p 10051:10051 zabbix-server

step 4: show docker log:

2024-03-01 11:53:52 Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSKeyFile": ''...removed 2024-03-01 11:53:52 Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSPSKIdentity": ''...removed 2024-03-01 11:53:52 Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSPSKFile": ''...removed 2024-03-01 11:53:52 Updating '/etc/zabbix/zabbix_server.conf' parameter "ServiceManagerSyncFrequency": ''...removed 2024-03-01 11:53:52 Updating '/etc/zabbix/zabbix_server.conf' parameter "HANodeName": ''...removed 2024-03-01 11:53:52 Updating '/etc/zabbix/zabbix_server.conf' parameter "NodeAddress": ''...removed 2024-03-01 11:53:52 ** Updating '/etc/zabbix/zabbix_server.conf' parameter "User": 'zabbix'...added 2024-03-01 11:53:52 /usr/sbin/zabbix_server: error while loading shared libraries: libnetsnmp.so.35: cannot open shared object file: No such file or directory

dotneft commented 6 months ago

20.04 is not ubuntu:jammy. You build server on old version of Ubuntu...

qinweizhen1 commented 6 months ago

zabbix-server source code is can not build in ubuntu:20.04??, If I change Dockfile base image to FROM ubuntu:20.04, is can work??

dotneft commented 6 months ago

You can, but in this case you need to use appropriate Dockerfile for final image. It must corresponding your system where built sources.

qinweizhen1 commented 6 months ago

it Can work normally, thank you very much