docker无脑部署zabbix6.0+agent

文章目录


前言

随着监控的不断发展,zabbix这门技术也越来越重要,很多人都开启了zabbix学习,本文就介绍了zabbix安装的基础内容。


一、安装docker-compose

下载二进制文件

bash 复制代码
cd /usr/src/
wget https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64

移动文件到/usr/local/bin下

bash 复制代码
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

赋予可执行权限

bash 复制代码
chmod +x /usr/local/bin/docker-compose

创建软链接

bash 复制代码
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

测试

bash 复制代码
docker-compose --version

二、部署Zabbix Server 6.0+agent

1.创建父目录

bash 复制代码
mkdir /zabbix-server
c 复制代码
cd /root
cd /zabbix-server
mkdir -p ./mysql/data
#映射数据库数据目录
mkdir -p ./mysql/conf
#映射数据库配置文件
mkdir -p ./mysql/logs
#映射数据库日志文件
mkdir -p ./font
mkdir -p ./snmptraps
mkdir -p ./mibs
mkdir -p ./alertscripts
mkdir -p ./externalscripts

2.拉取镜像

c 复制代码
docker pull mysql:8.0
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 pull zabbix/zabbix-agent:centos-6.0-latest

3.编辑docker-compose.yml文件

bash 复制代码
vim /zabbix-server/docker-compose.yml

编辑以下内容

bash 复制代码
##author:yanpu
version: '3'
services:
  mysql:
    image: mysql:8.0
    container_name: mysql
    volumes:
      - ./mysql/data:/var/lib/mysql
      - ./mysql/conf:/etc/mysql/conf.d
      - ./mysql/logs:/var/log/mysql
      - /etc/localtime:/etc/localtime
    restart: always
    privileged: true
    environment:
      - MYSQL_ROOT_PASSWORD=myrootpass
      - MYSQL_DATABASE=zabbix
      - MYSQL_USER=zabbix
      - MYSQL_PASSWORD=mypass
      - 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:
 
  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
      - ./zbx_env/etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d:ro
      - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro
      - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro
      - ./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:
  zabbix-snmptraps:
    image: zabbix/zabbix-snmptraps:6.0-centos-latest
    container_name: zabbix-snmptraps
    volumes:
      - /etc/localtime:/etc/localtime
      - ./snmptraps:/var/lib/zabbix/snmptraps
      - ./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
      - ./snmptraps:/var/lib/zabbix/snmptraps
      - ./mibs:/var/lib/zabbix/mibs
      - ./alertscripts:/usr/lib/zabbix/alertscripts
      - ./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_USERx-server=zabbix
      - MYSQL_PASSWORD=mypass
      - MYSQL_ROOT_PASSWORD=myrootpass
      - 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:
      - ./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=mypass
      - MYSQL_ROOT_PASSWORD=myrootpass
      - 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
 

启动Zabbix Server容器

bash 复制代码
cd /zabbix-server/
docker-compose up -d

二、浏览器访问Zabbix

1.url栏输入http://ip/

bash 复制代码
初始账号 Admin  ##注意A是大写
密码 zabbix

2.修改主机配置


需要稍等一会就会变成绿色


总结

以上就是今天要讲的内容,本文仅仅简单介绍了zabbix的安装,创作不易,请大家给一个赞以示鼓励

相关推荐
桂月二二3 小时前
Java与容器化:如何使用Docker和Kubernetes优化Java应用的部署
java·docker·kubernetes
007php0074 小时前
linux服务器上CentOS的yum和Ubuntu包管理工具apt区别与使用实战
linux·运维·服务器·ubuntu·centos·php·ai编程
人类群星闪耀时4 小时前
深度学习在灾难恢复中的作用:智能运维的新时代
运维·人工智能·深度学习
djykkkkkk4 小时前
ubuntu编译遇到的问题
linux·运维·ubuntu
LinkTime_Cloud4 小时前
GitLab 将停止为中国区用户提供服务,60天迁移期如何应对? | LeetTalk Daily
大数据·运维·gitlab
qq_429856574 小时前
linux 查看服务是否开机自启动
linux·运维·服务器
Smile丶凉轩5 小时前
Docker核心技术和实现原理
运维·docker·容器
清风细雨_林木木5 小时前
Docker使用——国内Docker的安装办法
运维·docker·容器
运维&陈同学5 小时前
【Kibana01】企业级日志分析系统ELK之Kibana的安装与介绍
运维·后端·elk·elasticsearch·云原生·自动化·kibana·日志收集
dessler6 小时前
Docker-Dockerfile讲解(三)
linux·运维·docker