简介
本文是以docker容器方式安装和部署zabbixserver服务端,各组件也是以容器方式运行,因此需要准备好一个docker-ce环境.
本文的环境清单如下:
os:CentOS Linux release 7.9.2009 (Core)
os内核:Linux VMW40136 3.10.0-1160.88.1.el7.x86_64
docker-ce:Docker version 23.0.1
docker-compose:docker-compose version 1.27.0, build 980ec85b(不要低于此版本)
mysql:8.0.29
zabbix-java-gateway:6.0-centos-latest
zabbix-snmptraps:6.0-centos-latest
zabbix-server-mysql:6.0-centos-latest
zabbix-web-nginx-mysql:6.0-centos-latest
安装DOCKERCOMPOSE
下载二进制文件
安装zabbix5.0储存库(二进制安装方式)
wget https://github.com/docker/compose/releases/download/1.27.0/docker-compose-Linux-x86_64
上传服务器
cp -a docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
修改权限
chmod +x /usr/local/bin/docker-compose
检查
docker-compose -version
安装ZABBIX-SERVER
准备镜像
能访问外网环境直接拉取相关镜像
docker pull mysql:8.0.29
docker pull zabbix/zabbix-java-gateway:6.0-centos-latest
docker pull zabbix/zabbix-snmptraps:6.0-centos-latest
docker pull zabbix/zabbix-server-mysql:6.0-centos-latest
docker pull zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
离线环境需要手工导入镜像文件
docker load < 镜像文件
创建相关目录
此步骤与docker-compose.yaml文件相关联,请按自己的实际需求调整:
mkdir -p /dockerdata/zabbix-server-tds/mysql/data
mkdir -p /dockerdata/zabbix-server-tds/mysql/conf
mkdir -p /dockerdata/zabbix-server-tds/mysql/logs
mkdir -p /dockerdata/zabbix-server-tds/snmptraps
mkdir -p /dockerdata/zabbix-server-tds/mibs
mkdir -p /dockerdata/zabbix-server-tds/alertscripts
mkdir -p /dockerdata/zabbix-server-tds/externalscripts
mkdir -p /dockerdata/zabbix-server-tds/font
上传字符集,以免中文乱码
将windows系统的字符集[C:\Windows\Fonts\simfang.ttf]上传至服务器的/dockerdata/zabbix-server-tds/font/
创建DOCKER-COMPOSE配置文件
本文设置docker-compose的工作目录为/dockerdata/zabbix-server-tds
创建docker-compose.yaml配置文件,此步骤应按实际需求去配置镜像名称,端口,容器卷映射,容器子网络和密码等细致配置.
cd /dockerdata/zabbix-server-tds
vi docker-compose.yaml
version: ‘1.0’
services:
mysql:
image: mysql:8.0.29
container_name: mysql
volumes:
- /dockerdata/zabbix-server-tds/mysql/data:/var/lib/mysql
- /dockerdata/zabbix-server-tds/mysql/conf:/etc/mysql/conf.d
- /dockerdata/zabbix-server-tds/mysql/logs:/var/log/mysql
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- MYSQL_ROOT_PASSWORD=数据库用户root的密码
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=数据库用户zabbix的密码
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
expose:
- “3306”
networks:
zabbix-net:
command: --character-set-server=utf8 --collation-server=utf8_bin
zabbix-gateway:
image: zabbix/zabbix-java-gateway:6.0-centos-latest
container_name: zabbix-gateway
volumes:
- /etc/localtime:/etc/localtime
restart: always
privileged: true
ports:
- “10052:10052”
networks:
zabbix-net:
zabbix-snmptraps:
image: zabbix/zabbix-snmptraps:6.0-centos-latest
container_name: zabbix-snmptraps
volumes:
- /etc/localtime:/etc/localtime
- /dockerdata/zabbix-server-tds/snmptraps:/var/lib/zabbix/snmptraps
- /dockerdata/zabbix-server-tds/mibs:/var/lib/zabbix/mibs
restart: always
privileged: true
ports:
- “1162:1162/udp”
networks:
zabbix-net:
zabbix-server:
image: zabbix/zabbix-server-mysql:6.0-centos-latest
container_name: zabbix-server
volumes:
- /etc/localtime:/etc/localtime
- /dockerdata/zabbix-server-tds/snmptraps:/var/lib/zabbix/snmptraps
- /dockerdata/zabbix-server-tds/mibs:/var/lib/zabbix/mibs
- /dockerdata/zabbix-server-tds/alertscripts:/usr/lib/zabbix/alertscripts
- /dockerdata/zabbix-server-tds/externalscripts:/usr/lib/zabbix/externalscripts
restart: always
privileged: true
environment:
- ZBX_LISTENPORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=数据库用户zabbix的密码
- MYSQL_ROOT_PASSWORD=数据库用户root的密码
- ZBX_CACHESIZE=1G
- ZBX_HISTORYCACHESIZE=512M
- ZBX_HISTORYINDEXCACHESIZE=16M
- ZBX_TRENDCACHESIZE=256M
- ZBX_VALUECACHESIZE=256M
- ZBX_STARTPINGERS=64
- ZBX_IPMIPOLLERS=1
- ZBX_ENABLE_SNMP_TRAPS=true
- ZBX_STARTTRAPPERS=1
- ZBX_JAVAGATEWAY_ENABLE=true
- ZBX_JAVAGATEWAY=zabbix-gateway
- ZBX_STARTJAVAPOLLERS=1
ports:
- “10051:10051”
networks:
zabbix-net:
links:
- mysql
- zabbix-gateway
zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
container_name: zabbix-web
volumes:
- /dockerdata/zabbix-server-tds/font/simfang.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- ZBX_SERVER_NAME=Zabbix 6.0
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=数据库用户zabbix的密码
- MYSQL_ROOT_PASSWORD=数据库用户root的密码
- PHP_TZ=Asia/Shanghai
ports:
- “80:8080”
networks:
zabbix-net:
links:
- mysql
- zabbix-server
networks:
zabbix-net:
driver: bridge
ipam:
config:
- subnet: 10.10.10.0/24
gateway: 10.10.10.1
启动服务
启动服务
切换至工作目录
cd /dockerdata/zabbix-server-tds
启动
docker-compose up -d
查看容器状态
docker-compose ps
docker ps
查看容器日志
docker-compose logs 容器名
docker logs 容器名
浏览器访问zabbix
默认用户和密码
Admin/zabbix
<?xml version="1.0" ?>
<cherrytree>
<node custom_icon_id="0" foreground="" is_bold="False" name="简介" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679208604.16" ts_lastsave="1679209968.1" unique_id="7">
<rich_text>本文是以docker容器方式安装和部署zabbixserver服务端,各组件也是以容器方式运行,因此</rich_text>
<rich_text foreground="#ffff00000000" weight="heavy">需要准备好一个docker-ce环境</rich_text>
<rich_text>.
本文的环境清单如下:
os:CentOS Linux release 7.9.2009 (Core)
os内核:Linux VMW40136 3.10.0-1160.88.1.el7.x86_64
docker-ce:Docker version 23.0.1
docker-compose:docker-compose version 1.27.0, build 980ec85b(不要低于此版本)
mysql:8.0.29
zabbix-java-gateway:6.0-centos-latest
zabbix-snmptraps:6.0-centos-latest
zabbix-server-mysql:6.0-centos-latest
zabbix-web-nginx-mysql:6.0-centos-latest</rich_text>
</node>
<node custom_icon_id="0" foreground="" is_bold="False" name="安装dockercompose" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679191813.16" ts_lastsave="1679209019.85" unique_id="1">
<rich_text>下载二进制文件
</rich_text>
<rich_text foreground="#61aeee">wget</rich_text>
<rich_text foreground="#abb2bf"> </rich_text>
<rich_text foreground="#abb2bf" link="webs https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64">https://github.com/docker/compose/releases/download/1.27.0/docker-compose-Linux-x86_64</rich_text>
<rich_text>
上传服务器
cp -a docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
修改权限
chmod +x /usr/local/bin/docker-compose
检查
docker-compose -version
</rich_text>
</node>
<node custom_icon_id="0" foreground="" is_bold="False" name="安装zabbix-server" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679194706.63" ts_lastsave="1679209039.79" unique_id="2">
<rich_text></rich_text>
<node custom_icon_id="0" foreground="" is_bold="False" name="准备镜像" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679194719.26" ts_lastsave="1679209791.45" unique_id="3">
<rich_text>能访问外网环境直接拉取相关镜像
docker pull mysql:8.0.29
docker pull zabbix/zabbix-java-gateway:6.0-centos-latest
docker pull zabbix/zabbix-snmptraps:6.0-centos-latest
docker pull zabbix/zabbix-server-mysql:6.0-centos-latest
docker pull zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
离线环境需要手工导入镜像文件
docker load < 镜像文件</rich_text>
</node>
<node custom_icon_id="0" foreground="" is_bold="False" name="创建相关目录" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679195193.6" ts_lastsave="1679209058.63" unique_id="5">
<rich_text>此步骤与docker-compose.yaml文件相关联,请按自己的实际需求调整:
mkdir -p /dockerdata/zabbix-server-tds/mysql/data
mkdir -p /dockerdata/zabbix-server-tds/mysql/conf
mkdir -p /dockerdata/zabbix-server-tds/mysql/logs
mkdir -p /dockerdata/zabbix-server-tds/snmptraps
mkdir -p /dockerdata/zabbix-server-tds/mibs
mkdir -p /dockerdata/zabbix-server-tds/alertscripts
mkdir -p /dockerdata/zabbix-server-tds/externalscripts
mkdir -p /dockerdata/zabbix-server-tds/font
上传字符集,以免中文乱码
将windows系统的字符集[</rich_text>
<rich_text link="file QzpcV2luZG93c1xGb250c1xzaW1mYW5nLnR0Zg==">C:\Windows\Fonts\simfang.ttf</rich_text>
<rich_text>]上传至服务器的/dockerdata/zabbix-server-tds/font/</rich_text>
</node>
<node custom_icon_id="0" foreground="" is_bold="False" name="创建docker-compose配置文件" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679194864.81" ts_lastsave="1679210136.04" unique_id="4">
<rich_text>本文设置docker-compose的工作目录为/dockerdata/zabbix-server-tds
创建docker-compose.yaml配置文件,</rich_text>
<rich_text foreground="#ffff00000000" weight="heavy">此步骤应按实际需求去配置镜像名称,端口,容器卷映射,容器子网络和密码等细致配置</rich_text>
<rich_text>.
cd /dockerdata/zabbix-server-tds
vi docker-compose.yaml
---
version: '1.0'
services:
mysql:
image: mysql:8.0.29
container_name: mysql
volumes:
- /dockerdata/zabbix-server-tds/mysql/data:/var/lib/mysql
- /dockerdata/zabbix-server-tds/mysql/conf:/etc/mysql/conf.d
- /dockerdata/zabbix-server-tds/mysql/logs:/var/log/mysql
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- MYSQL_ROOT_PASSWORD=数据库用户root的密码
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=数据库用户zabbix的密码
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
expose:
- "3306"
networks:
zabbix-net:
command: --character-set-server=utf8 --collation-server=utf8_bin
zabbix-gateway:
image: zabbix/zabbix-java-gateway:6.0-centos-latest
container_name: zabbix-gateway
volumes:
- /etc/localtime:/etc/localtime
restart: always
privileged: true
ports:
- "10052:10052"
networks:
zabbix-net:
zabbix-snmptraps:
image: zabbix/zabbix-snmptraps:6.0-centos-latest
container_name: zabbix-snmptraps
volumes:
- /etc/localtime:/etc/localtime
- /dockerdata/zabbix-server-tds/snmptraps:/var/lib/zabbix/snmptraps
- /dockerdata/zabbix-server-tds/mibs:/var/lib/zabbix/mibs
restart: always
privileged: true
ports:
- "1162:1162/udp"
networks:
zabbix-net:
zabbix-server:
image: zabbix/zabbix-server-mysql:6.0-centos-latest
container_name: zabbix-server
volumes:
- /etc/localtime:/etc/localtime
- /dockerdata/zabbix-server-tds/snmptraps:/var/lib/zabbix/snmptraps
- /dockerdata/zabbix-server-tds/mibs:/var/lib/zabbix/mibs
- /dockerdata/zabbix-server-tds/alertscripts:/usr/lib/zabbix/alertscripts
- /dockerdata/zabbix-server-tds/externalscripts:/usr/lib/zabbix/externalscripts
restart: always
privileged: true
environment:
- ZBX_LISTENPORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=数据库用户zabbix的密码
- MYSQL_ROOT_PASSWORD=数据库用户root的密码
- ZBX_CACHESIZE=1G
- ZBX_HISTORYCACHESIZE=512M
- ZBX_HISTORYINDEXCACHESIZE=16M
- ZBX_TRENDCACHESIZE=256M
- ZBX_VALUECACHESIZE=256M
- ZBX_STARTPINGERS=64
- ZBX_IPMIPOLLERS=1
- ZBX_ENABLE_SNMP_TRAPS=true
- ZBX_STARTTRAPPERS=1
- ZBX_JAVAGATEWAY_ENABLE=true
- ZBX_JAVAGATEWAY=zabbix-gateway
- ZBX_STARTJAVAPOLLERS=1
ports:
- "10051:10051"
networks:
zabbix-net:
links:
- mysql
- zabbix-gateway
zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
container_name: zabbix-web
volumes:
- /dockerdata/zabbix-server-tds/font/simfang.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- ZBX_SERVER_NAME=Zabbix 6.0
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=数据库用户zabbix的密码
- MYSQL_ROOT_PASSWORD=数据库用户root的密码
- PHP_TZ=Asia/Shanghai
ports:
- "80:8080"
networks:
zabbix-net:
links:
- mysql
- zabbix-server
networks:
zabbix-net:
driver: bridge
ipam:
config:
- subnet: 10.10.10.0/24
gateway: 10.10.10.1</rich_text>
</node>
<node custom_icon_id="0" foreground="" is_bold="False" name="启动服务" prog_lang="custom-colors" readonly="False" tags="" ts_creation="1679195859.93" ts_lastsave="1679210025.94" unique_id="6">
<rich_text scale="h1">启动服务</rich_text>
<rich_text>
切换至工作目录
cd /dockerdata/zabbix-server-tds
启动
docker-compose up -d
查看容器状态
docker-compose ps
docker ps
查看容器日志
docker-compose logs 容器名
docker logs 容器名
</rich_text>
<rich_text scale="h1">浏览器访问zabbix</rich_text>
<rich_text>
默认用户和密码
Admin/zabbix
</rich_text>
</node>
</node>
</cherrytree>