docker-compose部署zabbix+grafana的实现
作者:小熊故事集
这篇文章主要介绍了docker-compose部署zabbix+grafana的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
1.引言
1.1目的
zabbix+grafana实现图形化监控
2.部署环境
服务器ip | 服务 | 版本 |
---|---|---|
192.168.5.137 | zabbix-server | 6.0.21 |
192.168.5.137 | grafana | 10.2.2 |
192.168.5.152 | zabbix-client | 6.0.21 |
3.部署zabbix-server
3.1 创建zabbix目录
mkdir zabbix
3.2 编写docker-compose文件
cd zabbix vim docker-compose.yaml 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: 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_USER=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
3.3 启动zabbix容器
docker-compose -f docker-compose.yaml up –d
3.4 查看zabbix容器
docker ps
3.5 访问zabbix的web页面
url: http://192.168.5.137:80
4.部署grafana
4.1创建grafana目录
mkdir grafana
4.2 编写grafana.yaml文件
cd grafana vim grafana.yaml version: '3.9' services: grafana: image: grafana/grafana container_name: grafana ports: - "3000:3000" environment: - TZ=Asia/Shanghai networks: - grafana volumes: - ./grafana:/var/lib/grafana networks: grafana: driver: bridge
4.3启动grafana容器
docker-compose -f grafana.yaml up –d
4.4 安装grafana的zabbix数据源
进入grafana容器 docker exec -it grafana bash 安装zabbix数据源 grafana cli plugins install alexanderzobnin-zabbix-app 查看是否安装成功 grafana cli plugins ls 重启grafana容器 docker restart grafana
4.5 访问grafana的web页面
url:http://192.168.5.137:3000
5.部署zabbix-client
5.1 创建zabbix目录
mkdir zabbix
5.2 编写zabbix.yaml文件
cd zabbix vim zabbix.yaml version: '3' services: zabbix-agent: image: zabbix/zabbix-agent:latest environment: - ZBX_SERVER_HOST=192.168.5.137 - ZBX_HOSTNAME=test volumes: - ./agentd/zabbix_agentd.conf:/etc/zabbix/zabbix_agentd.conf ports: - "10050:10050"
5.3 启动zabbix客户端
docker-compose -f zabbix.yaml up –d
6.添加zabbix监控
6.1 添加zabbix客户端ip
6.2 监控zabbix客户端CPU
6.3添加cpu触发器
6.4 添加图形化界面
6.5 查看监控到的数据
7.配置grafana
7.1 添加zabbix插件
7.2搜索添加zabbix数据源
7.3 添加zabbix服务端信息
7.4 开启zabbix模板
7.5 添加zabbix监控数据
到此这篇关于docker-compose部署zabbix+grafana的实现的文章就介绍到这了,更多相关docker-compose部署zabbix+grafana内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!