基于 timescaledb容器搭建zabbix-7.2.4服务

本文为基于 timescale/timescaledb:2.17.4-pg17 容器运行 PostgreSQL 容器,并将其作为 Zabbix 7.2.4的后端存储启动zabbix服务器\web容器服务的样例。

一、准备数据库

1、拉取 TimescaleDB 镜像

docker pull timescale/timescaledb:2.17.2-pg17

[root@localhost ~]# docker pull timescale/timescaledb:2.17.2-pg17
2.17.2-pg17: Pulling from timescale/timescaledb
1f3e46996e29: Pull complete 
1ddaf56854cd: Pull complete 
3cf4f77660fd: Pull complete 
f562efc34463: Pull complete 
d6eaa17dfd6a: Pull complete 
fdcefadb5bb3: Pull complete 
badd2a25d9ca: Pull complete 
f699f32c0574: Pull complete 
75de42a401ce: Pull complete 
c48dc11d8978: Pull complete 
dd4095a3a943: Pull complete 
87d8d36da85f: Pull complete 
9ff86eda85f2: Pull complete 
5446aca872c7: Pull complete 
f3673278bde6: Pull complete 
5da69ab5f00b: Pull complete 
fb5928689e0a: Pull complete 
9163ad2d4a63: Pull complete 
Digest: sha256:3324f81ca7f84cdc2dc4497863b3798ababa8ce130c5b59d73f0b40e3a34148e
Status: Downloaded newer image for timescale/timescaledb:2.17.2-pg17
docker.io/timescale/timescaledb:2.17.2-pg17
[root@localhost ~]# docker images |grep timescaledb
timescale/timescaledb                           2.17.2-pg17         611f2c8c72f1   5 weeks ago     1.58GB
2、运行 TimescaleDB 容器

运行 TimescaleDB 容器,并设置数据库名称、用户名和密码:

[root@localhost ~]# docker run -d --name timescaledb -e POSTGRES_DB=zabbix -e POSTGRES_USER=zabbix -e POSTGRES_PASSWORD=zabbix -p 5432:5432 timescale/timescaledb:2.17.2-pg17            
c492f0ccb6181e6943a7e67f589cb56f7ce46431d059f6ca3ab6d49157c4cbbc
[root@localhost ~]# docker logs -f timescaledb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
....

2025-03-03 01:52:20.543 UTC [1] LOG:  database system is shut down

PostgreSQL Database directory appears to contain a database; Skipping initialization

2025-03-03 01:52:21.091 UTC [1] LOG:  starting PostgreSQL 17.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 14.2.0) 14.2.0, 64-bit
2025-03-03 01:52:21.092 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2025-03-03 01:52:21.092 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2025-03-03 01:52:21.093 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-03-03 01:52:21.097 UTC [28] LOG:  database system was shut down at 2025-03-03 01:52:20 UTC
2025-03-03 01:52:21.100 UTC [1] LOG:  database system is ready to accept connections
2025-03-03 01:52:21.103 UTC [31] LOG:  TimescaleDB background worker launcher connected to shared catalogs
3、 配置 TimescaleDB 服务 

配置前先备份配置文件

# docker cp pgdbsrv:/var/lib/postgresql/data/postgresql.conf .
# docker cp pgdbsrv:/var/lib/postgresql/data/pg_hba.conf .
# ll *.conf
-rw-------. 1 root root 5.7K Feb 24 11:35 pg_hba.conf
-rw-------. 1 root root  31K Feb 24 11:35 postgresql.conf

配置监听地址、端口、最大连接数和ssl

[root@localhost ~]# docker exec -it timescaledb /bin/bash
c492f0ccb618:/# vi /var/lib/postgresql/data/postgresql.conf 
c492f0ccb618:/# egrep  "^listen_addresses|^port|^max_connections|^ssl"  /var/lib/postgresql/data/postgresql.conf       
listen_addresses = '*'
port = 5432                             # (change requires restart)
max_connections = 2000                  # (change requires restart)
ssl = off

配置加密协议为md5 

c492f0ccb618:/# vi /var/lib/postgresql/data/pg_hba.conf      
c492f0ccb618:/# grep "host all all all" /var/lib/postgresql/data/pg_hba.conf   
#host all all all scram-sha-256
host all all all md5
c492f0ccb618:/# exit
exit
[root@localhost ~]# docker restart timescaledb           
timescaledb
4.检查数据库

检查数据库及timescaledb插件信息

[root@localhost ~]# psql -U zabbix -h 172.17.0.2
用户 zabbix 的口令:
psql (13.12, 服务器 17.2)
警告:psql 主版本13,服务器主版本为17.
     一些psql功能可能无法正常使用.
输入 "help" 来获取帮助信息.

zabbix=# \dx
                                                      已安装扩展列表
    名称     |  版本  |  架构模式  |                                         描述                                          
-------------+--------+------------+---------------------------------------------------------------------------------------
 plpgsql     | 1.0    | pg_catalog | PL/pgSQL procedural language
 timescaledb | 2.17.2 | public     | Enables scalable inserts and complex queries for time-series data (Community Edition)
(2 行记录)
zabbix=# select version(); 
                                         version                                         
-----------------------------------------------------------------------------------------
 PostgreSQL 17.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 14.2.0) 14.2.0, 64-bit
(1 行记录)

zabbix=# show config_file;
               config_file                
------------------------------------------
 /var/lib/postgresql/data/postgresql.conf
(1 行记录)

zabbix=# \dt
没有找到任何关系.
zabbix=# select * from pg_database;
  oid  |  datname  | datdba | encoding | datlocprovider | datistemplate | datallowconn | dathasloginevt | datconnlimit | datfrozenxid | datminmxid | dattablespace | datcollate |  datctype  | datlocale | daticurules | datcollversion |
            datacl             
-------+-----------+--------+----------+----------------+---------------+--------------+----------------+--------------+--------------+------------+---------------+------------+------------+-----------+-------------+----------------+
-------------------------------
     5 | postgres  |     10 |        6 | c              | f             | t            | f              |           -1 |          731 |          1 |          1663 | en_US.utf8 | en_US.utf8 |           |             |                |
 
 16384 | zabbix    |     10 |        6 | c              | f             | t            | f              |           -1 |          731 |          1 |          1663 | en_US.utf8 | en_US.utf8 |           |             |                |
 
     1 | template1 |     10 |        6 | c              | t             | t            | f              |           -1 |          731 |          1 |          1663 | en_US.utf8 | en_US.utf8 |           |             |                |
 {=c/zabbix,zabbix=CTc/zabbix}
     4 | template0 |     10 |        6 | c              | t             | f            | f              |           -1 |          731 |          1 |          1663 | en_US.utf8 | en_US.utf8 |           |             |                |
 {=c/zabbix,zabbix=CTc/zabbix}
(4 行记录)

zabbix=# \q

二. 创建 Zabbix 数据库

1、下载并安装zabbix数据库生成脚本包
[root@localhost ~]#  wget https://mirrors.huaweicloud.com/zabbix/zabbix/7.2/stable/centos/8/x86_64/zabbix-sql-scripts-7.2.4-release1.el8.noarch.rpm
--2025-03-03 10:31:20--  https://mirrors.huaweicloud.com/zabbix/zabbix/7.2/stable/centos/8/x86_64/zabbix-sql-scripts-7.2.4-release1.el8.noarch.rpm
正在解析主机 mirrors.huaweicloud.com (mirrors.huaweicloud.com)... 120.46.2.67, 120.46.63.139, 123.249.118.101, ...
正在连接 mirrors.huaweicloud.com (mirrors.huaweicloud.com)|120.46.2.67|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 
长度:8074304 (7.7M) [application/octet-stream]
正在保存至: “zabbix-sql-scripts-7.2.4-release1.el8.noarch.rpm”

zabbix-sql-scripts-7.2.4-release1.el8.noarch.rpm           100%[=====================================================================================================================================>]   7.70M  5.12MB/s  用时 1.5s    

2025-03-03 10:31:24 (5.12 MB/s) - 已保存 “zabbix-sql-scripts-7.2.4-release1.el8.noarch.rpm” [8074304/8074304])

[root@localhost ~]# yum localinstall zabbix-sql-scripts-7.2.4-release1.el8.noarch.rpm 
Waiting for process with pid 3766 to finish.
Last metadata expiration check: 0:00:01 ago on 2025年03月03日 星期一 10时32分35秒.
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                      Architecture                                     Version                                                      Repository                                              Size
=========================================================================================================================================================================================================================================
Installing:
 zabbix-sql-scripts                                           noarch                                           7.2.4-release1.el8                                           @commandline                                           7.7 M

Transaction Summary
=========================================================================================================================================================================================================================================
Install  1 Package

Total size: 7.7 M
Installed size: 10 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : zabbix-sql-scripts-7.2.4-release1.el8.noarch                                                                                                                                                                    1/1 
  Verifying        : zabbix-sql-scripts-7.2.4-release1.el8.noarch                                                                                                                                                                    1/1 

Installed:
  zabbix-sql-scripts-7.2.4-release1.el8.noarch                                                                                                                                                                                           

Complete!
[root@localhost ~]# 
2、查看脚本情况
[root@localhost ~]# tree /usr/share/zabbix/sql-scripts/
/usr/share/zabbix/sql-scripts/
├── mysql
│   ├── option-patches
│   │   └── history_upgrade_prepare.sql
│   ├── proxy.sql
│   └── server.sql.gz
├── postgresql
│   ├── option-patches
│   │   └── history_upgrade_prepare.sql
│   ├── proxy.sql
│   ├── server.sql.gz
│   └── timescaledb
│       ├── option-patches
│       │   ├── with-compression
│       │   │   ├── history_upgrade_log.sql
│       │   │   ├── history_upgrade_prepare.sql
│       │   │   ├── history_upgrade.sql
│       │   │   ├── history_upgrade_str.sql
│       │   │   ├── history_upgrade_text.sql
│       │   │   ├── history_upgrade_uint.sql
│       │   │   └── trends_upgrade.sql
│       │   └── without-compression
│       │       ├── history_upgrade_log.sql
│       │       ├── history_upgrade_prepare.sql
│       │       ├── history_upgrade.sql
│       │       ├── history_upgrade_str.sql
│       │       ├── history_upgrade_text.sql
│       │       ├── history_upgrade_uint.sql
│       │       └── trends_upgrade.sql
│       └── schema.sql
└── sqlite3
    └── proxy.sql

9 directories, 22 files
3、导入数据库脚本
[root@localhost ~]# zcat /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz |psql -U zabbix  zabbix -h 172.17.0.2
用户 zabbix 的口令:
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE TABLE
CREATE INDEX
...
INSERT 0 14
INSERT 0 1315
INSERT 0 27081
INSERT 0 1
INSERT 0 339
INSERT 0 1
INSERT 0 518
INSERT 0 2228
INSERT 0 12516
DELETE 93298
COMMIT
 4、检查zabbix数据库表生成情况
[root@localhost ~]# psql -U zabbix  zabbix -h 172.17.0.2                                                             
用户 zabbix 的口令:
psql (13.12, 服务器 17.2)
警告:psql 主版本13,服务器主版本为17.
     一些psql功能可能无法正常使用.
输入 "help" 来获取帮助信息.

zabbix=# \dt
                        关联列表
 架构模式 |            名称            |  类型  | 拥有者 
----------+----------------------------+--------+--------
 public   | acknowledges               | 数据表 | zabbix
 public   | actions                    | 数据表 | zabbix
 public   | alerts                     | 数据表 | zabbix
 public   | auditlog                   | 数据表 | zabbix
 public   | autoreg_host               | 数据表 | zabbix
 public   | changelog                  | 数据表 | zabbix
 public   | conditions                 | 数据表 | zabbix
 public   | config                     | 数据表 | zabbix
 public   | config_autoreg_tls         | 数据表 | zabbix
 public   | connector                  | 数据表 | zabbix
 public   | connector_tag              | 数据表 | zabbix
 public   | corr_condition             | 数据表 | zabbix
 public   | corr_condition_group       | 数据表 | zabbix
 public   | corr_condition_tag         | 数据表 | zabbix
 public   | corr_condition_tagpair     | 数据表 | zabbix
 public   | corr_condition_tagvalue    | 数据表 | zabbix
 public   | corr_operation             | 数据表 | zabbix
 public   | correlation                | 数据表 | zabbix
 public   | dashboard                  | 数据表 | zabbix
 public   | dashboard_page             | 数据表 | zabbix
 public   | dashboard_user             | 数据表 | zabbix
 public   | dashboard_usrgrp           | 数据表 | zabbix
 public   | dbversion                  | 数据表 | zabbix
 public   | dchecks                    | 数据表 | zabbix
 public   | dhosts                     | 数据表 | zabbix
 public   | drules                     | 数据表 | zabbix
 public   | dservices                  | 数据表 | zabbix
 public   | escalations                | 数据表 | zabbix
 public   | event_recovery             | 数据表 | zabbix
 public   | event_suppress             | 数据表 | zabbix
 public   | event_symptom              | 数据表 | zabbix
 public   | event_tag                  | 数据表 | zabbix
 public   | events                     | 数据表 | zabbix
 public   | expressions                | 数据表 | zabbix
 public   | functions                  | 数据表 | zabbix
 public   | globalmacro                | 数据表 | zabbix
 public   | globalvars                 | 数据表 | zabbix
 public   | graph_discovery            | 数据表 | zabbix
 public   | graph_theme                | 数据表 | zabbix
 public   | graphs                     | 数据表 | zabbix
 public   | graphs_items               | 数据表 | zabbix
 public   | group_discovery            | 数据表 | zabbix
 public   | group_prototype            | 数据表 | zabbix
 public   | ha_node                    | 数据表 | zabbix
 public   | hgset                      | 数据表 | zabbix
 public   | hgset_group                | 数据表 | zabbix
 public   | history                    | 数据表 | zabbix
 public   | history_bin                | 数据表 | zabbix
 public   | history_log                | 数据表 | zabbix
 public   | history_str                | 数据表 | zabbix
 public   | history_text               | 数据表 | zabbix
...
zabbix=# \q
5、启用时序插件适配
[root@localhost ~]# cat /usr/share/zabbix/sql-scripts/postgresql/timescaledb/schema.sql |psql -U zabbix  zabbix -h 172.17.0.2
用户 zabbix 的口令:
CREATE FUNCTION
NOTICE:  function base36_decode(pg_catalog.varchar) does not exist, skipping
DROP FUNCTION
NOTICE:  PostgreSQL version 17.2 is valid
NOTICE:  TimescaleDB extension is detected
NOTICE:  TimescaleDB version 2.17.2 is valid
WARNING:  column type "character varying" used for "source" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "value" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "auditid" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "username" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "ip" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "resource_cuid" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "resourcename" does not follow best practices
提示:  Use datatype TEXT instead.
WARNING:  column type "character varying" used for "recordsetid" does not follow best practices
提示:  Use datatype TEXT instead.
NOTICE:  TimescaleDB is configured successfully
DO
[root@localhost ~]# 

 三、准备Zabbix 镜像

通过以下命令拉取zabbix最新版7.2.4的服务器和前端web镜像:

docker pull zabbix/zabbix-server-pgsql:alpine-7.2-latestalpine-7.2-latest
docker pull zabbix/zabbix-web-apache-pgsql:alpine-7.2.4

[root@localhost ~] # docker pull zabbix/zabbix-server-pgsql:alpine-7.2-latest
...
[root@localhost ~] # docker pull zabbix/zabbix-web-apache-pgsql:alpine-7.2.4
...
[root@localhost ~] # docker images|grep alpine
zabbix/zabbix-web-apache-pgsql                  alpine-7.2.4        34dd3dccf372   5 days ago      222MB
zabbix/zabbix-server-pgsql                      alpine-7.2-latest   56a9240ac35b   5 days ago      63.8MB

四、运行 Zabbix Server 容器

1、运行Zabbix Server 容器

运行Zabbix Server 容器,并连接到 TimescaleDB 容器:

docker run -d \
  --name zabbix-server \
  -e DB_SERVER_HOST=172.17.0.2 \
  -e POSTGRES_USER=zabbix \
  -e POSTGRES_PASSWORD=zabbix \
  -e POSTGRES_DB=zabbix \
  -p 10051:10051 \
zabbix/zabbix-server-pgsql:alpine-7.2-latest

[root@localhost ~]# docker run -d \
>  --name zabbix-server \
>  -e DB_SERVER_HOST=172.17.0.2 \
>  -e POSTGRES_USER=zabbix \
>  -e POSTGRES_PASSWORD=zabbix \
>  -e POSTGRES_DB=zabbix \
>  -p 10051:10051 \
> zabbix/zabbix-server-pgsql:alpine-7.2-latest
fc0d42b5f633bca7f392ee1da1924127ed5375158a5b3b37efc226d013e66a55
[root@localhost ~]# docker logs -f zabbix-server
** Preparing Zabbix server
** Preparing database
** Using POSTGRES_USER variable from ENV
** Using POSTGRES_PASSWORD variable from ENV
********************
* DB_SERVER_HOST: 172.17.0.2
* DB_SERVER_PORT: 5432
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_SCHEMA: public
********************
** Database 'zabbix' already exists. Please be careful with database owner!
** Table 'zabbix.dbversion' already exists.
Starting Zabbix Server. Zabbix 7.2.4 (revision c34078a).
Press Ctrl+C to exit.

     1:20250303:030632.926 Starting Zabbix Server. Zabbix 7.2.4 (revision c34078a).
     1:20250303:030632.926 ****** Enabled features ******
     1:20250303:030632.926 SNMP monitoring:           YES
     1:20250303:030632.926 IPMI monitoring:           YES
     1:20250303:030632.926 Web monitoring:            YES
     1:20250303:030632.926 VMware monitoring:         YES
     1:20250303:030632.926 SMTP authentication:       YES
     1:20250303:030632.926 ODBC:                      YES
     1:20250303:030632.926 SSH support:               YES
     1:20250303:030632.926 IPv6 support:              YES
     1:20250303:030632.926 TLS support:               YES
     1:20250303:030632.926 ******************************
     1:20250303:030632.926 using configuration file: /etc/zabbix/zabbix_server.conf
     1:20250303:030633.114 current database version (mandatory/optional): 07020000/07020000
     1:20250303:030633.114 required mandatory version: 07020000
    25:20250303:030633.151 starting HA manager
    25:20250303:030633.292 HA manager started in active mode
     1:20250303:030633.294 server #0 started [main process]
    26:20250303:030633.295 server #1 started [service manager #1]
    27:20250303:030633.296 server #2 started [configuration syncer #1]
    28:20250303:030633.981 server #3 started [alert manager #1]
    29:20250303:030633.982 server #4 started [alerter #1]
    30:20250303:030633.982 server #5 started [alerter #2]
    31:20250303:030633.983 server #6 started [alerter #3]
    33:20250303:030633.983 server #8 started [lld manager #1]
    34:20250303:030633.983 server #9 started [lld worker #1]
    35:20250303:030633.984 server #10 started [lld worker #2]
    36:20250303:030633.985 server #11 started [housekeeper #1]
    37:20250303:030633.986 server #12 started [timer #1]
    38:20250303:030633.986 server #13 started [http poller #1]
    39:20250303:030633.987 server #14 started [browser poller #1]
    40:20250303:030633.990 server #15 started [discovery manager #1]
    41:20250303:030633.993 server #16 started [history syncer #1]
    42:20250303:030633.994 server #17 started [history syncer #2]
    43:20250303:030633.995 server #18 started [history syncer #3]
    45:20250303:030633.995 server #20 started [escalator #1]
    46:20250303:030633.998 server #21 started [proxy poller #1]
    47:20250303:030634.001 server #22 started [self-monitoring #1]
    48:20250303:030634.001 server #23 started [task manager #1]
    49:20250303:030634.001 server #24 started [poller #1]
    32:20250303:030634.002 server #7 started [preprocessing manager #1]
    50:20250303:030634.003 server #25 started [poller #2]
    44:20250303:030634.004 server #19 started [history syncer #4]
    54:20250303:030634.004 server #29 started [unreachable poller #1]
    67:20250303:030634.006 server #42 started [availability manager #1]
    71:20250303:030634.007 server #46 started [agent poller #1]
    72:20250303:030634.007 server #47 started [snmp poller #1]
    73:20250303:030634.008 server #48 started [configuration syncer worker #1]
    74:20250303:030634.008 server #49 started [internal poller #1]
    75:20250303:030634.013 server #50 started [proxy group manager #1]
    51:20250303:030634.033 server #26 started [poller #3]
    52:20250303:030634.040 server #27 started [poller #4]
    53:20250303:030634.040 server #28 started [poller #5]
    55:20250303:030634.044 server #30 started [trapper #1]
    56:20250303:030634.045 server #31 started [trapper #2]
    57:20250303:030634.046 server #32 started [trapper #3]
    58:20250303:030634.048 server #33 started [trapper #4]
    59:20250303:030634.049 server #34 started [trapper #5]
    60:20250303:030634.051 server #35 started [icmp pinger #1]
    61:20250303:030634.051 server #36 started [alert syncer #1]
    63:20250303:030634.051 server #38 started [history poller #2]
    62:20250303:030634.054 server #37 started [history poller #1]
    64:20250303:030634.059 server #39 started [history poller #3]
    65:20250303:030634.061 server #40 started [history poller #4]
    66:20250303:030634.069 server #41 started [history poller #5]
    68:20250303:030634.071 server #43 started [trigger housekeeper #1]
    69:20250303:030634.076 server #44 started [odbc poller #1]
    70:20250303:030634.106 server #45 started [http agent poller #1]
    70:20250303:030634.106 thread started
    71:20250303:030634.107 thread started
    72:20250303:030634.107 thread started
    32:20250303:030634.759 [1] thread started [preprocessing worker #1]
    32:20250303:030634.759 [2] thread started [preprocessing worker #2]
    32:20250303:030634.759 [3] thread started [preprocessing worker #3]
    32:20250303:030634.759 [5] thread started [preprocessing worker #5]
    32:20250303:030634.760 [9] thread started [preprocessing worker #9]
    32:20250303:030634.760 [12] thread started [preprocessing worker #12]
    32:20250303:030634.760 [4] thread started [preprocessing worker #4]
    32:20250303:030634.760 [6] thread started [preprocessing worker #6]
    32:20250303:030634.760 [7] thread started [preprocessing worker #7]
    32:20250303:030634.760 [8] thread started [preprocessing worker #8]
    32:20250303:030634.760 [10] thread started [preprocessing worker #10]
    32:20250303:030634.760 [11] thread started [preprocessing worker #11]
    32:20250303:030634.760 [13] thread started [preprocessing worker #13]
    32:20250303:030634.760 [14] thread started [preprocessing worker #14]
    32:20250303:030634.760 [15] thread started [preprocessing worker #15]
    32:20250303:030634.760 [16] thread started [preprocessing worker #16]
    40:20250303:030634.763 thread started [discovery worker #1]
    40:20250303:030634.763 thread started [discovery worker #2]
    40:20250303:030634.763 thread started [discovery worker #3]
    40:20250303:030634.763 thread started [discovery worker #4]
    40:20250303:030634.763 thread started [discovery worker #5]
    71:20250303:030637.009 Zabbix agent item "vfs.fs.get" on host "Zabbix server" failed: first network error, wait for 15 seconds
    49:20250303:030639.009 forced reloading of the snmp cache on [poller #1]
    54:20250303:030639.011 forced reloading of the snmp cache on [unreachable poller #1]
    51:20250303:030639.045 forced reloading of the snmp cache on [poller #3]
    52:20250303:030639.046 forced reloading of the snmp cache on [poller #4]
    50:20250303:030639.046 forced reloading of the snmp cache on [poller #2]
    53:20250303:030639.046 forced reloading of the snmp cache on [poller #5]
    41:20250303:030641.061 item "Zabbix server:zabbix[process,ipmi poller,avg,busy]" became not supported: No "ipmi poller" processes started.
    41:20250303:030642.063 item "Zabbix server:zabbix[process,java poller,avg,busy]" became not supported: No "java poller" processes started.
    41:20250303:030647.071 item "Zabbix server:zabbix[process,snmp trapper,avg,busy]" became not supported: No "snmp trapper" processes started.
    41:20250303:030647.071 item "Zabbix server:zabbix[process,ipmi manager,avg,busy]" became not supported: No "ipmi manager" processes started.
    41:20250303:030648.073 item "Zabbix server:zabbix[process,vmware collector,avg,busy]" became not supported: No "vmware collector" processes started.
    71:20250303:030652.009 Zabbix agent item "system.localtime" on host "Zabbix server" failed: another network error, wait for 15 seconds
    41:20250303:030655.084 item "Zabbix server:zabbix[vmware,buffer,pused]" became not supported: No "vmware collector" processes started.
    41:20250303:030658.089 item "Zabbix server:zabbix[process,report writer,avg,busy]" became not supported: No "report writer" processes started.
    41:20250303:030659.090 item "Zabbix server:zabbix[process,report manager,avg,busy]" became not supported: No "report manager" processes started.
    71:20250303:030707.009 Zabbix agent item "vm.memory.size[total]" on host "Zabbix server" failed: another network error, wait for 15 seconds
    71:20250303:030722.010 temporarily disabling Zabbix agent checks on host "Zabbix server": interface unavailable
    41:20250303:030728.138 item "Zabbix server:zabbix[connector_queue]" became not supported: connector is not initialized: please check "StartConnectors" configuration parameter
    41:20250303:030729.140 item "Zabbix server:zabbix[process,connector manager,avg,busy]" became not supported: No "connector manager" processes started.
    41:20250303:030730.143 item "Zabbix server:zabbix[process,connector worker,avg,busy]" became not supported: No "connector worker" processes started.

2、 运行 Zabbix Web 容器

docker run -d \
  --name zabbix-web \
  -e DB_SERVER_HOST=172.17.0.2 \
  -e POSTGRES_USER=zabbix \
  -e POSTGRES_PASSWORD=zabbix \
  -e POSTGRES_DB=zabbix \
  -p 8080:8080 \
zabbix/zabbix-web-apache-pgsql:alpine-7.2.4

运行 Zabbix Web 容器,并连接到 TimescaleDB 容器:

[root@localhost ~]# docker run -d \
>   --name zabbix-web \
>   -e DB_SERVER_HOST=172.17.0.2 \
>   -e POSTGRES_USER=zabbix \
>   -e POSTGRES_PASSWORD=zabbix \
>   -e POSTGRES_DB=zabbix \
>   -p 8080:8080 \
> zabbix/zabbix-web-apache-pgsql:alpine-7.2.4
dbf1a0c9d8d7adf62b7c0511f2a752c0bc42b12373f1abe7f06f6f9a357e4def
[root@localhost ~]# docker logs -f zabbix-web
** Deploying Zabbix web-interface (Apache) with PostgreSQL database
** Using POSTGRES_USER variable from ENV
** Using POSTGRES_PASSWORD variable from ENV
********************
* DB_SERVER_HOST: 172.17.0.2
* DB_SERVER_PORT: 5432
* DB_SERVER_PORT: 5432
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_SCHEMA: public
********************
** Preparing PHP configuration
** Adding Zabbix virtual host (HTTP)
**** Impossible to enable SSL support for Apache2. Certificates are missed.
########################################################
** Executing supervisord
2025-03-03 03:21:12,447 INFO Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2025-03-03 03:21:12,447 INFO Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2025-03-03 03:21:12,458 INFO RPC interface 'supervisor' initialized
2025-03-03 03:21:12,458 INFO RPC interface 'supervisor' initialized
2025-03-03 03:21:12,458 INFO supervisord started with pid 1
2025-03-03 03:21:12,458 INFO supervisord started with pid 1
2025-03-03 03:21:13,463 INFO spawned: 'httpd' with pid 14
2025-03-03 03:21:13,463 INFO spawned: 'httpd' with pid 14
2025-03-03 03:21:13,471 INFO spawned: 'php-fpm83' with pid 15
2025-03-03 03:21:13,471 INFO spawned: 'php-fpm83' with pid 15
[Mon Mar 03 03:21:13.617296 2025] [mpm_event:notice] [pid 14:tid 14] AH00489: Apache/2.4.62 (Unix) configured -- resuming normal operations
[Mon Mar 03 03:21:13.617395 2025] [core:notice] [pid 14:tid 14] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[03-Mar-2025 03:21:13] NOTICE: fpm is running, pid 15
[03-Mar-2025 03:21:13] NOTICE: ready to handle connections
2025-03-03 03:21:15,745 INFO success: httpd entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
2025-03-03 03:21:15,745 INFO success: httpd entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
2025-03-03 03:21:15,746 INFO success: php-fpm83 entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
2025-03-03 03:21:15,746 INFO success: php-fpm83 entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
3、访问 Zabbix Web 界面

打开浏览器,访问 http://localhost:8080,使用默认用户名 Admin 和密码 zabbix 登录 Zabbix Web 界面。

可以看到,系统已能正常使用了。 

[root@zabbix conf]# file -i /usr/local/zabbix-7.2.4/ui/*.php /usr/local/zabbix-7.2.4/ui/api_jsonrpc.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/api_scim.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/browserwarning.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/chart2.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/chart3.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/chart4.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/chart6.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/chart7.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/chart.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/graphs.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/history.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/host_discovery.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/hostinventoriesoverview.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/hostinventories.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/host_prototypes.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/httpconf.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/httpdetails.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/image.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/imgstore.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/index_http.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/index_mfa.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/index.php: text/x-php; charset=us-ascii /usr/local/zabbix-7.2.4/ui/index_sso.php: text/x-php; c
03-17
<think>好的,用户想检查Zabbix 7.2.4 UI目录下的PHP文件的MIME类型和字符编码。我需要先理清步骤,确保回答正确且符合用户需求。 首先,用户提到的Zabbix 7.2.4可能是指某个特定版本,但根据引用[3],提到的是CentOS Stream 8编译安装PHP 7.2.4,这可能是指PHP版本,而Zabbix的版本可能不同。需要确认用户是否混淆了版本号。但用户的问题明确提到Zabbix 7.2.4,可能是一个笔误,但按照用户的问题来处理。 接下来,用户需要检查PHP文件的MIME类型和字符编码。通常,PHP文件在服务器端的MIME类型是text/html或application/x-php,但实际传输给客户端时可能由服务器配置决定,比如Apache的默认处理方式。字符编码则通常在文件头部或meta标签中指定。 根据引用[2],用户需要找到UI目录的位置。Zabbix的Web前端通常安装在类似/usr/share/zabbix/的目录下。用户可以使用find命令查找,如find / -name "*.php"来定位PHP文件的位置。 检查MIME类型可以通过服务器配置查看,比如Apache的mime.types文件,或者使用curl命令检查响应头。例如,curl -I http://localhost/zabbix/index.php可以查看Content-Type头部信息,其中包含MIME类型和可能的字符编码。 字符编码也可以在PHP文件内部查看,通常在<?php标签之后或HTML的meta标签中指定,如header('Content-Type: text/html; charset=utf-8');或者<meta charset="UTF-8">。 另外,引用[3]提到了php.ini的配置,可能涉及到默认字符设置,如default_charset = "UTF-8",这也可能影响PHP输出的编码。 需要提醒用户,直接检查文件内容和服务器的响应头是最直接的方法。同时,注意Zabbix版本是否正确,因为7.2.4可能不存在,需要用户确认是否为PHP版本,或者是否有其他误解。 最后,生成相关问题时要围绕Zabbix配置、PHP设置、MIME类型检查和字符编码问题展开,帮助用户进一步解决问题。</think>### 检查Zabbix UI目录下PHP文件的MIME类型和字符编码 #### 1. 定位Zabbix UI目录 根据引用[2]的路径查找方法,Zabbix Web前端文件通常位于以下路径: ```bash find / -name "zabbix.conf.php" 2>/dev/null # 典型路径为/usr/share/zabbix/ ``` 若使用默认安装(引用[1]),可能路径为: `/usr/share/zabbix/` 或 `/var/www/html/zabbix/` #### 2. 检查PHP文件的MIME类型 PHP文件的MIME类型通常由Web服务器配置决定: - **Apache**:默认处理`.php`为`text/html`,但实际类型取决于`AddType`指令(检查`/etc/httpd/conf.d/zabbix.conf`) - **Nginx**:在引用[1]的配置中,检查`/etc/nginx/conf.d/zabbix.conf`是否包含: ```nginx location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php-fpm; } ``` 默认会通过FastCGI处理PHP文件,响应头中的MIME类型为`text/html; charset=UTF-8` #### 3. 验证实际响应类型 使用`curl`检查HTTP响应头: ```bash curl -I http://localhost/zabbix/index.php ``` 输出应包含: ``` Content-Type: text/html; charset=UTF-8 ``` #### 4. 检查PHP文件字符编码 通过以下方式验证编码: - **文件元数据**:使用`file`命令检测编码: ```bash file -i /usr/share/zabbix/index.php # 输出示例:charset=us-ascii ``` - **代码声明**:查看PHP文件头部是否包含编码定义: ```php <?php header('Content-Type: text/html; charset=utf-8'); ?> ``` 或在HTML部分检查: ```html <meta charset="UTF-8"> ``` - **PHP配置**:根据引用[3],检查`/usr/local/php/lib/php.ini`中的配置: ```ini default_charset = "UTF-8" ``` #### 5. 关键配置文件参考 - **Zabbix Web配置**:`/etc/zabbix/web/zabbix.conf.php`(影响全局设置) - **PHP-FPM配置**:`/etc/php-fpm.d/zabbix.conf`(可能包含`php_value[default_charset]`) ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代先生.重庆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值