近期將zabbix平臺從V6.2.6升級到7.2.4,遇到問題“PostgresoL server is not available. Waiting 5seconds”,容器無法訪問Postgres V17數據庫,本文記錄問題解決過程。
一、系統環境
1、數據庫版本
數據庫版本:postgres-17.4-timescale-2.17.2,如下:
# psql -U zabbix zabbix -h 192.168.128.111
Password for user zabbix:
psql (13.3, server 17.4)
WARNING: psql major version 13, server major version 17.Some psql features might not work.
Type "help" for help.zabbix=> \dxList of installed extensionsName | Version | Schema | Description -------------+---------+------------+-------------------------------------------------------------------------------
--------plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural languagetimescaledb | 2.17.2 | public | Enables scalable inserts and complex queries for time-series data (Community E
dition)
(2 rows)zabbix=> \q
2、zabbix服務器容器版本
zabbix/zabbix-web-apache-pgsql:centos-7.2.4
zabbix/zabbix-server-pgsql:centos-7.2.4
二、報錯信息
zabbix服務器連接數據庫報錯:“PostgresoL server is not available. Waiting 5seconds”
三、問題分析
1、數據庫版本是否兼容
?從zabbix官網,可以看到相關數據庫版本在兼容清單的
support for PostgreSQL versions:- 17.X??
support for TimescaleDB versions:?2.17.X?
?2、測試數據庫外部連接情況
# psql -U zabbix zabbix -h 192.168.128.111
Password for user zabbix:
psql (13.3, server 17.4)
WARNING: psql major version 13, server major version 17.Some psql features might not work.
Type "help" for help.zabbix=> \dxList of installed extensionsName | Version | Schema | Description -------------+---------+------------+-------------------------------------------------------------------------------
--------plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural languagetimescaledb | 2.17.2 | public | Enables scalable inserts and complex queries for time-series data (Community E
dition)
(2 rows)zabbix=> \q
?可以看到,數據庫外部訪問正常,可以查詢到庫的信息,可以排除數據庫自身的問題。
3、問題定位
經過本人全面檢查,最終查到本問題是因為zabbix服務器官方容器包的問題。
原因為zabbix使用--list來檢查數據庫服務是否存活,在容器外本地使用該命令,反饋信息如下:
# psql -U zabbix zabbix -h 192.168.128.111 --list
Password for user zabbix: List of databasesName | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+-----------+---------+-------+-----------------------postgres | postgres | SQL_ASCII | C | C | template0 | postgres | SQL_ASCII | C | C | =c/postgres +| | | | | postgres=CTc/postgrestemplate1 | postgres | SQL_ASCII | C | C | =c/postgres +| | | | | postgres=CTc/postgreszabbix | zabbix | UTF8 | C | C |
(4 rows)
登入zabbix服務器容器,可以看到容器內封裝的PostgreSQL客戶端版本為16.6,該命令執行反饋信息報錯“column d.daticulocale does not exist”:
# docker exec -it zbxsrv /bin/bash
bash-5.1$ psql -V
psql (PostgreSQL) 16.6
bash-5.1$ psql -h 192.168.128.111 -U zabbix -d zabbix --list
Password for user zabbix:
psql: ERROR: column d.daticulocale does not exist
LINE 8: d.daticulocale as "ICU Locale",^
HINT: Perhaps you meant to reference the column "d.datlocale".
bash-5.1$ cat /etc/centos-release
CentOS Stream release 9
?且zabbix官方Centos、ubuntu系統容器包都存在此問題。
四、解決辦法
使用zabbix官方alpine系統平臺的服務器容器鏡像。
zabbix/zabbix-server-pgsql:alpine-7.2-latestalpine-7.2-latest(目前實際是7.2.4)
zabbix/zabbix-web-apache-pgsql:alpine-7.2.4
如下:
[root@localhost ~]# docker pull zabbix/zabbix-server-pgsql:alpine-7.2-latest
alpine-7.2-latest: Pulling from zabbix/zabbix-server-pgsql
f18232174bc9: Already exists
145118636fb4: Pull complete
2e36442cfc45: Pull complete
90bbfafe739a: Pull complete
ff10713dcc30: Pull complete
39a26e625a05: Pull complete
4f4fb700ef54: Pull complete
db0d9b0bdf27: Pull complete
Digest: sha256:c8db24a3fc509ea4b1a3d9f4ef197e1ee46f2656f586c3c5f9014ca6de61804b
Status: Downloaded newer image for zabbix/zabbix-server-pgsql:alpine-7.2-latest
docker.io/zabbix/zabbix-server-pgsql:alpine-7.2-latest
[root@localhost ~]# docker pull zabbix/zabbix-web-apache-pgsql:alpine-7.2.4
alpine-7.2.4: Pulling from zabbix/zabbix-web-apache-pgsql
f18232174bc9: Already exists
0068142ce15f: Pull complete
a2c25e127afd: Pull complete
0f6189e461cd: Pull complete
4f4fb700ef54: Pull complete
5d085b3ca5ae: Pull complete
Digest: sha256:3e91ca4aad3bd051ed33cdfa343fb9711b9dd5a33518798926af862a9bae4c41
Status: Downloaded newer image for zabbix/zabbix-web-apache-pgsql:alpine-7.2.4
docker.io/zabbix/zabbix-web-apache-pgsql:alpine-7.2.4
運行容器,可以看到,服務器已正常連接:
?問題得到解決。