本文主要是介绍Docker容器化部署Zabbix6.0(史上最简单,全程粘贴复制即可完成!!),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 一、部署docker环境
- 二、部署docker-compose环境
- 三、部署Zabbix6.0(docker-compose方式)
- 四、部署Zabbix-agent
一、部署docker环境
1、前提环境准备
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
2、配置阿里云Yum源
yum -y install yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3、安装docker
yum install docker-ce docker-ce-cli containerd.io -y
4、配置国内镜像加速地址
mkdir -p /etc/dockertee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://aoewjvel.mirror.aliyuncs.com"]
}
EOF
5、启动并加入自启动
systemctl start docker
systemctl enable docker
6、查看docker版本
docker --version
二、部署docker-compose环境
1、官方下载docker-compose
curl -L "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2、赋予执行权限
chmod +x /usr/local/bin/docker-compose
3、查看版本
docker-compose --version
三、部署Zabbix6.0(docker-compose方式)
1、创建部署目录
mkdir /etc/zabbix
cd /etc/zabbix
2、添加.env
文件(如果没有需求,保持默认即可)
vi .envDEPLOY_PATH="/etc/zabbix/zabbix6.0"
MYSQL_ROOT_PASSWORD="1qaz!QAZZabbix.com"
MYSQL_USER=zabbix
MYSQL_PASSWORD="1qaz!QAZZabbix.com"
ZABBIX_NETWORK_SUBNET="10.10.10.0/24"
ZABBIX_WEB_PORT="3999"
ZABBIX_HISTORYCACHESIZE=2048M
3、添加docker-compose.yaml
文件
vi docker-compose.yamlversion: '3'
services:
# DBmysql:image: mysql:8.0container_name: mysqlvolumes:- ${DEPLOY_PATH}/data:/var/lib/mysql- ${DEPLOY_PATH}/mysql/conf:/etc/mysql/conf.d- ${DEPLOY_PATH}/mysql/logs:/var/log/mysql- /etc/localtime:/etc/localtime:rorestart: alwaysprivileged: trueenvironment:- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}- MYSQL_DATABASE=zabbix- MYSQL_USER=${MYSQL_USER}- MYSQL_PASSWORD=${MYSQL_PASSWORD}- TZ=Asia/Shanghai- LANG=en_US.UTF-8expose:- "3306"networks:zabbix-net:command: --character-set-server=utf8 --collation-server=utf8_bin# Gatewayzabbix-gateway:image: zabbix/zabbix-java-gateway:6.0-centos-latestcontainer_name: zabbix-gatewayvolumes:- /etc/localtime:/etc/localtime:rorestart: alwaysprivileged: trueports:- "10052:10052"networks:zabbix-net:# Agent
# zabbix6-agent:
# image: zabbix/zabbix-agent:centos-6.0-latest
# container_name: zabbix6-agent
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - /etc/timezone:/etc/timezone:ro
# - ${DEPLOY_PATH}/zbx_env/etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d:ro
# - ${DEPLOY_PATH}/zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro
# - ${DEPLOY_PATH}/zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro
# - ${DEPLOY_PATH}/zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro
# restart: always
# privileged: true
# environment:
# - ZBX_HOSTNAME=Zabbix server
# - ZBX_SERVER_HOST=zabbix-server
# - ZBX_SERVER_PORT=10051
# ports:
# - "10050:10050"
# networks:
# zabbix-net:
#
# SNMP(可选)
# zabbix-snmptraps:
# image: zabbix/zabbix-snmptraps:6.0-centos-latest
# container_name: zabbix-snmptraps
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - ${DEPLOY_PATH}/snmptraps:/var/lib/zabbix/snmptraps
# - ${DEPLOY_PATH}/mibs:/var/lib/zabbix/mibs
# restart: always
# privileged: true
# ports:
# - "1162:1162/udp"
# networks:
# zabbix-net:# Serverzabbix-server:image: zabbix/zabbix-server-mysql:6.0-centos-latestcontainer_name: zabbix-servervolumes:- /etc/localtime:/etc/localtime:ro- ${DEPLOY_PATH}/snmptraps:/var/lib/zabbix/snmptraps- ${DEPLOY_PATH}/mibs:/var/lib/zabbix/mibs- ${DEPLOY_PATH}/alertscripts:/usr/lib/zabbix/alertscripts- ${DEPLOY_PATH}/externalscripts:/usr/lib/zabbix/externalscriptsrestart: alwaysprivileged: trueenvironment:- ZBX_LISTENPORT=10051- DB_SERVER_HOST=mysql- DB_SERVER_PORT=3306- MYSQL_DATABASE=zabbix- MYSQL_USERx-server=${MYSQL_USER}- MYSQL_PASSWORD=${MYSQL_PASSWORD}- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}- ZBX_CACHESIZE=1G- ZBX_HISTORYCACHESIZE=${ZABBIX_HISTORYCACHESIZE}- 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=1ports:- "10051:10051"networks:zabbix-net:links:- mysql- zabbix-gateway# WEBzabbix-web:image: zabbix/zabbix-web-nginx-mysql:6.0-centos-latestcontainer_name: zabbix-webvolumes:- ${DEPLOY_PATH}/font/simfang.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf- /etc/localtime:/etc/localtimerestart: alwaysprivileged: trueenvironment:- 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=${MYSQL_USER}- MYSQL_PASSWORD=${MYSQL_PASSWORD}- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}- PHP_TZ=Asia/Shanghaiports:- "${ZABBIX_WEB_PORT}:8080"networks:zabbix-net:links:- mysql- zabbix-servernetworks:zabbix-net:driver: bridgeipam:config:- subnet: ${ZABBIX_NETWORK_SUBNET}
4、解决图形乱码问题
yum -y install wqy-microhei-fonts.noarch
mkdir /etc/zabbix/font
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /etc/zabbix/font/simfang.ttf
5、启动(第一次需要下载镜像,请耐心等待…)
docker-compose up -d
6、访问验证
浏览器访问:http://IP:3999
注意:如果访问到提示"Database error",如下图所示,不要担心,这是Zabbix还没初始化完成,耐心等待后即可正常访问到了!
默认账号密码:Admin/zabbix
四、部署Zabbix-agent
注意:由于不是每台服务器都有docker环境,所以zabbix-agent不走容器部署比较方便
1、下载Zabbix-agent
wget https://cdn.zabbix.com/zabbix/binaries/stable/6.0/6.0.30/zabbix_agent-6.0.30-linux-3.0-i386-static.tar.gz --no-check-certificatetar zxf zabbix_agent-6.0.30-linux-3.0-i386-static.tar.gz -C /usr/local/
2、修改配置文件,10.10.10.0/24
是容器的网段
vi /usr/local/conf/zabbix_agentd.conf
# 修改Server
Server=10.10.10.0/24
3、启动Zabbix-agent
useradd -M zabbix
cd /usr/local/sbin/
su - zabbix -c "./zabbix_agentd -c ../conf/zabbix_agentd.conf"
添加完成之后,正常在WEB页面添加主机即可,这里不在赘述
OK,至此结束
这篇关于Docker容器化部署Zabbix6.0(史上最简单,全程粘贴复制即可完成!!)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!