Zabbix

Zabbix版本及下载

Zabbix server 5.0 (tags: alpine-5.0-latest, ubuntu-5.0-latest, ol-5.0-latest)
Zabbix server 5.0.* (tags: alpine-5.0.*, ubuntu-5.0.*, ol-5.0.*)
Zabbix server 6.0 (tags: alpine-6.0-latest, ubuntu-6.0-latest, ol-6.0-latest)
Zabbix server 6.0.* (tags: alpine-6.0.*, ubuntu-6.0.*, ol-6.0.*)
Zabbix server 6.4 (tags: alpine-6.4-latest, ubuntu-6.4-latest, ol-6.4-latest)
Zabbix server 6.4.* (tags: alpine-6.4.*, ubuntu-6.4.*, ol-6.4.*)
Zabbix server 7.0 (tags: alpine-7.0-latest, ubuntu-7.0-latest, ol-7.0-latest, alpine-latest, ubuntu-latest, ol-latest, latest)
Zabbix server 7.0.* (tags: alpine-7.0.*, ubuntu-7.0.*, ol-7.0.*)
Zabbix server 7.2 (tags: alpine-trunk, ubuntu-trunk, ol-trunk)
ZABBIX_AGENT_IMAGE=zabbix/zabbix-agent
ZABBIX_AGENT2_IMAGE=zabbix/zabbix-agent2
ZABBIX_JAVA_GATEWAY_IMAGE=zabbix/zabbix-java-gateway
ZABBIX_SNMPTRAPS_IMAGE=zabbix/zabbix-snmptraps
ZABBIX_WEB_SERVICE_IMAGE=zabbix/zabbix-web-service

docker pull zabbix/zabbix-server-mysql:alpine-7.0-latest
docker pull zabbix/zabbix-web-nginx-mysql:alpine-7.0-latest
docker pull zabbix/zabbix-web-service:alpine-7.0-latest
docker pull zabbix/zabbix-snmptraps:alpine-7.0-latest

docker run --name some-zabbix-server-mysql 
-e DB_SERVER_HOST="some-mysql-server" \
-e MYSQL_USER="some-user" \
-e MYSQL_PASSWORD="some-password" \
--init -d \
zabbix/zabbix-server-mysql:alpine-6.4-latest

docker相关

no 默认策略,在容器退出时不重启容器
on-failure 在容器非正常退出时(退出状态非0),才会重启容器
on-failure:3 指定启动的次数,在容器非正常退出时重启容器,最多重启3次
always 在容器退出时总是重启容器
unless-stopped 在容器退出时总是重启容器,但是不考虑在Docker守护进程启动时就已经停止了的容器
# 一直下载失败
#curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

pip3 download docker-compose

在Ubuntu 24.04上用apt安装python3-pip,运行时提示与系统组件可能有冲突,之后用apt remove,并把python3也remove了,之后重启系统网络就无法工作,网卡一直为down状态,systemd-networkd-wait-online.service报timeout。

最终只能从github上直接下载新版本,解压到/usr/local/bin目录下就可以使用(6xMB的包,已经打包为执行文件。,自带了python支持)。

直接docker run

https://www.zabbix.com/documentation/6.4/zh/manual/installation/containers

初次运行zabbix-server,会自动从create.sql.gz(4.1MB,160万行)中导入初始化数据到mysql中,需要几分钟时间,这期间访问zabbix-web会提示没有可选配置。导入完成后才会启动服务进程,以及网络端口侦听,这时再去启动zabbix-web容器。

进入zabbix-server容器,可以看到初始化的进程:

PID   USER     TIME  COMMAND
    1 zabbix    0:00 {docker-entrypoi} /bin/bash /usr/bin/docker-entrypoint.sh /usr/sbin/zabbix_serve
   22 zabbix    0:00 gzip -cd /usr/share/doc/zabbix-server-mysql/create.sql.gz
   23 zabbix    0:07 mysql --silent --skip-column-names --default-character-set=utf8mb4 -h mysql-serv
   24 zabbix    0:00 /bin/bash
   44 zabbix    0:00 ps aux

安装zabbix-agent

在被监控主机安装zabbix-agent。

docker-compose方式

https://github.com/zabbix/zabbix-docker 下载docker-compose配置,根据需要项调整。

docker-compose/
├── .env                                                        # 环境参数,指定数据目录、运行版本信息
├── .env.def                                                    # 备份默认配置
├── compose.yaml -> docker-compose_v3_alpine_mysql_latest.yaml  # ln到主文件
├── compose_databases.yaml                                      # 数据库配置
├── compose_zabbix_components.yaml                              # zabbix组件定义文件
├── docker-compose_v3_alpine_mysql_latest.yaml                  # 主compose文件
└── env_vars                                                    # 容器环境参数、密码配置
    ├── .MYSQL_PASSWORD
    ├── .MYSQL_ROOT_PASSWORD
    ├── .MYSQL_ROOT_USER
    ├── .MYSQL_USER
    ├── .POSTGRES_PASSWORD
    ├── .POSTGRES_USER
    ├── .env_agent
    ├── .env_db_mysql
    ├── .env_db_mysql_proxy
    ├── .env_db_pgsql
    ├── .env_java
    ├── .env_prx
    ├── .env_prx_mysql
    ├── .env_prx_sqlite3
    ├── .env_snmptraps
    ├── .env_srv
    ├── .env_web
    ├── .env_web_service
    ├── chrome_dp.json
    └── mysql_init
        └── init_proxy_db.sql
docker-compose up -d

[+] Running 7/7
 ✔ Network docker-compose_database                    Creat...                                   0.1s
 ✔ Network docker-compose_backend                     Create...                                  0.1s
 ✔ Network docker-compose_frontend                    Creat...                                   0.2s
 ✔ Network docker-compose_tools_frontend              Created                                    0.2s

 ✔ Container docker-compose-mysql-server-1            Started                                    0.7s
 ✔ Container docker-compose-zabbix-web-nginx-mysql-1  Started                                    1.9s
 ✔ Container docker-compose-zabbix-server-1           Started                                    2.5s

docker-compose ps
NAME                                      IMAGE                                             COMMAND                  SERVICE                  CREATED          STATUS                    PORTS
docker-compose-mysql-server-1             mysql:8.0                                         "docker-entrypoint.s…"   mysql-server             37 seconds ago   Up 36 seconds
docker-compose-zabbix-server-1            zabbix/zabbix-server-mysql:alpine-7.0-latest      "/usr/bin/docker-ent…"   zabbix-server            36 seconds ago   Up 35 seconds             0.0.0.0:20051->10051/tcp
docker-compose-zabbix-web-nginx-mysql-1   zabbix/zabbix-web-nginx-mysql:alpine-7.0-latest   "docker-entrypoint.sh"   zabbix-web-nginx-mysql   36 seconds ago   Up 35 seconds (healthy)   0.0.0.0:20080->8080/tcp, 0.0.0.0:20443->8443/tcp

docker-compose images
CONTAINER                                 REPOSITORY                      TAG                 IMAGE ID            SIZE
docker-compose-mysql-server-1             mysql                           8.0                 9f4b39935f20        590MB
docker-compose-zabbix-server-1            zabbix/zabbix-server-mysql      alpine-7.0-latest   aa80bfaed00e        138MB
docker-compose-zabbix-web-nginx-mysql-1   zabbix/zabbix-web-nginx-mysql   alpine-7.0-latest   7e5d8d917c40        300MB