欧拉部署zabbix监控教程

1.实验环境

  • 系统版本:openEuler-22.03-LTS-x86_64
  • 内核版本: 5.10.0-60.18.0.50.oe2203.x86_64

2.安装必要软件

yum install tar vim wqy-microhei-fonts

docker安装以下两种方式任选其一

2.1 软件源安装

yum install docker 
# 安装docker
systemctl start docker.service
# 启动服务
systemctl enable docker.service
# 设置开机自启

2.2 二进制文件安装

docker地址:https://download.docker.com/linux/static/stable/x86_64/

mkdir -p /home/docker
cd /home/docker
wget https://download.docker.com/linux/static/stable/x86_64/docker-28.2.2.tgz
tar -xvf docker-28.2.2.tgz
cp -rf docker/* /usr/bin/

可以运行docker -v验证

设置开机自启文件

vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
# 重载配置
systemctl start docker.service
# 启动服务
systemctl enable docker
# 设置开机自启
systemctl status docker
# 查看状态

● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2025-06-24 11:27:39 CST; 1min 32s ago
       Docs: https://docs.docker.com
   Main PID: 144167 (dockerd)
      Tasks: 17 (limit: 8946)
     Memory: 30.5M
     CGroup: /system.slice/docker.service
             ├─144167 /usr/bin/dockerd
             └─144175 containerd --config /var/run/docker/containerd/containerd.toml

6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.179471444+08:00" level=warning msg="Error (>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.268809644+08:00" level=info msg="Loading co>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.275957238+08:00" level=info msg="Docker dae>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.276109461+08:00" level=info msg="Initializi>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.277105650+08:00" level=warning msg="CDI set>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.277115743+08:00" level=warning msg="CDI set>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.286711317+08:00" level=info msg="Completed >
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.291674156+08:00" level=info msg="Daemon has>
6月 24 11:27:39 localhost.localdomain dockerd[144167]: time="2025-06-24T11:27:39.292300120+08:00" level=info msg="API listen>
6月 24 11:27:39 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
lines 1-21/21 (END)

2.3 设置docker镜像加速

vim /etc/docker/daemon.json
{"registry-mirrors": ["https://docker.m.daocloud.io", "https://docker.imgdb.de", "https://docker-0.unsee.tech", "https://docker.hlmirror.com", "https://cjie.eu.org"]}
systemctl restart docker

3.安装zabbix

3.1 创建专用于 Zabbix 组件容器的网络

docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 zabbix-net

3.2 启动空的 MySQL 服务器实例

docker run --name mysql-server -t \
    -e MYSQL_DATABASE="zabbix" \
    -e MYSQL_USER="zabbix" \
    -e MYSQL_PASSWORD="1qaz2wsx.." \
    -e MYSQL_ROOT_PASSWORD="zaq1xsw2.." \
    -v /data/zabbix_mysql/conf/my.cnf:/etc/mysql/my.cnf \
    -v /data/zabbix_mysql/logs:/logs \
    -v /data/zabbix_mysql/mysql:/var/lib/mysql \
    --network=zabbix-net \
    --restart unless-stopped \
    -d mysql:8.0 \
    --character-set-server=utf8 --collation-server=utf8_bin \
    --default-authentication-plugin=mysql_native_password

环境变量注释:

DB_SERVER_HOST:
这个变量指的是 MySQL 或 PostgreSQL 的 IP 或 DNS, 默认情况下,这个值根据 MySQL 和 PostgreSQL,分别为mysql-server 或 postgres-server
MYSQL_USER: MySQL 数据库用户
MYSQL_DATABASE: zabbix数据库库名
MYSQL_ROOT_PASSWORD: zabbix数据库root用户的密码
MYSQL_PASSWORD: zabbix数据库zabbix用户的密码
-v /data/zabbix_mysql/conf/my.cnf:/etc/mysql/my.cnf 数据库配置文件绑定到宿主机的/data/zabbix_mysql/conf/my.cnf路径
-v /data/zabbix_mysql/logs:/logs 日志目录绑定到宿主机相应路径
-v /data/zabbix_mysql/mysql:/var/lib/mysql 数据库文件的存放路径绑定

3.3 启动 Zabbix Java 网关实例

docker run --name zabbix-java-gateway -t \
      --network=zabbix-net \
      --restart unless-stopped \
      -d zabbix/zabbix-java-gateway:alpine-5.4-latest

3.4 启动 Zabbix server 实例,并将其关联到已创建的 MySQL server 实例

mkdir -p /etc/zabbix_server
touch /etc/zabbix_server/zabbix_server.conf
docker run --name zabbix-server-mysql -t \
        -e DB_SERVER_HOST="mysql-server" \
        -e MYSQL_DATABASE="zabbix" \
        -e MYSQL_USER="zabbix" \
        -e MYSQL_PASSWORD="1qaz2wsx.." \
        -e MYSQL_ROOT_PASSWORD="zaq1xsw2.." \
        -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
        --network=zabbix-net \
        -v /etc/zabbix_server/zabbix_server.conf:/etc/zabbix/zabbix_server.conf \
        -p 10051:10051 \
        --restart unless-stopped \
        -d zabbix/zabbix-server-mysql:alpine-5.4-latest
docker run --name zabbix-server-mysql -t \
        -e DB_SERVER_HOST="mysql-server" \
        -e MYSQL_DATABASE="zabbix" \
        -e MYSQL_USER="zabbix" \
        -e MYSQL_PASSWORD="1qaz2wsx.." \
        -e MYSQL_ROOT_PASSWORD="zaq1xsw2.." \
        -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
        --network=zabbix-net \
        -p 10051:10051 \
        --restart unless-stopped \
        -d zabbix/zabbix-server-mysql:alpine-5.4-latest

3.5 启动 Zabbix Web 界面,并将其关联到已创建的 MySQL server 和 Zabbix server 实例

docker run --name zabbix-web-nginx-mysql -t \
    -e ZBX_SERVER_HOST="zabbix-server-mysql" \
    -e DB_SERVER_HOST="mysql-server" \
    -e MYSQL_DATABASE="zabbix" \
    -e MYSQL_USER="zabbix" \
    -e MYSQL_PASSWORD="1qaz2wsx.." \
    -e MYSQL_ROOT_PASSWORD="zaq1xsw2.." \
    --network=zabbix-net \
    -p 80:8080 \
    --restart unless-stopped \
    -d zabbix/zabbix-web-nginx-mysql:alpine-5.4-latest

4.防火墙设置

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=10051/tcp --permanent
firewall-cmd --reload

5.验证

打开一个web窗口,输入访问地址ip
输入默认用户名Admin,密码zabbix登录成功

最后修改:2025 年 08 月 05 日
如果觉得我的文章对你有用,请随意赞赏