Zabbix(Docker版) 监控系统的安装

前言

之前的一段时间,需要进行压力测试,并且需要整体判断下服务器的性能和其它测试。于是,公司安装了Zabbix监控系统,个人只会使用,而没有实际的操作过。所以,自己安装了一下,详细的操作步骤记录如下。

本章节主要包括如下3个部分:
* Docker组件的安装(zabbix-server-mysql/zabbix-web-apache-mysql/zabbix-agent)
* 过程细节问题


组件安装

Zabbix主要包括3个基本组成部分:

  • zabbix-server-mysql
  • zabbix-web-apache-mysql
  • zabbix-agent

分别代表后端、前端和数据采集器。本文主要采用的是mysql数据的形势,实际上zabbix官方海提供了pgsql的数据库存储形式。详细的见docker hub上的官方介绍:https://hub.docker.com/r/zabbix/

安装的命令较为简单,本文采用的docker版本一致为alpine-3.2.5(agent版本和后端版本不一致是否会出现一定的问题目前海不太确定)。

# zabbix-server-mysql
docker run  --add-host=dockerhost:`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` --name some-zabbix-server-mysql  -p 10051:10051 -e DB_SERVER_HOST=docker.for.mac.host.internal -e DB_SERVER_PORT=3306 -e MYSQL_USER="root" -e MYSQL_PASSWORD="admin" -d zabbix/zabbix-server-mysql:alpine-3.2.5

#  zabbix-web-apache-mysql

docker run --name some-zabbix-agent --add-host=dockerhost:`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` -p 10050:10050 -e ZBX_HOSTNAME="localhost" -e ZBX_SERVER_HOST=`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge`  -e ZBX_SERVER_PORT=10051 -d zabbix/zabbix-agent:alpine-3.2.5

#  zabbix-agent

docker run --name some-zabbix-web-apache-mysql --add-host=dockerhost:`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` -p 8088:80  -e DB_SERVER_HOST=docker.for.mac.host.internal -e DB_SERVER_PORT=3306 -e MYSQL_USER=root -e MYSQL_PASSWORD=admin -e ZBX_SERVER_HOST=`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` -e TZ="Asia/Shanghai" -d zabbix/zabbix-web-apache-mysql:alpine-3.2.5

# ps: 上述命令中的--add-host 和 docker.for.mac.host.internal 是为了解决docker访问本地数据库而添加的,如果IP地址固定的情况下,更改成相应的IP地址即可。

注意事项

  • 特别注意,上述的SERVER_HOST千万不要配置127.0.0.1哦,因为这个是docker的虚拟化网络决定的。详细可以看下我的另一篇文章Docker内如何访问本机(宿主机)

  • 其二,可以通过docker logs 查看zabbix启动时候的日志。还有,其它的docker参数,可以查看相应的zabbix-docker 主页面。https://hub.docker.com/r/zabbix/zabbix-server-mysql/

  • 其三,mysql 连接不上

sh-3.2# docker logs 9515eb39b8b0
** Deploying Zabbix server with mysql database
** Preparing the system
** Preparing Zabbix server
********************
* DB_SERVER_HOST: dockerhost
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ZBX_USER: root
* DB_SERVER_ZBX_PASS: admin
********************
**** MySQL server is not available. Waiting 5 seconds...
**** MySQL server is not available. Waiting 5 seconds...
**** MySQL server is not available. Waiting 5 seconds...

这个问题是上文的docker访问了本地的ip:127.0.0.1所导致,具体还是看下docker访问本机这片文章即可解决上述问题。

  • 其四,docker初始化的数据库名称为zabbix, 账户和密码为Admin/zabbix

  • 其五,web连接不上host,肯定是因为apache-web镜像启动的时候没有配置正确的host地址导致。


相关log

启动

# docker zabbix-mysql
localhost:~ Sean$ docker logs 0aab68a67f1c
** Deploying Zabbix server with mysql database
** Preparing the system
** Preparing Zabbix server
********************
* DB_SERVER_HOST: docker.for.mac.host.internal
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ZBX_USER: root
* DB_SERVER_ZBX_PASS: admin
********************
** Database 'zabbix' already exists. Please be careful with database COLLATE!
** Table 'zabbix.dbversion' already exists.
** Preparing Zabbix server configuration file
** Updating '/etc/zabbix/zabbix_server.conf' parameter "ListenPort": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SourceIP": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogType": 'console'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogFile": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogFileSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "PidFile": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "DebugLevel": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "DBHost": 'docker.for.mac.host.internal'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "DBName": 'zabbix'... updated
** Updating '/etc/zabbix/zabbix_server.conf' parameter "DBUser": 'root'... updated
** Updating '/etc/zabbix/zabbix_server.conf' parameter "DBPort": '3306'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "DBPassword": 'admin'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartPollers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartIPMIPollers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartPollersUnreachable": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartTrappers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartPingers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartDiscoverers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartHTTPPollers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartTimers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartEscalators": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "JavaGateway": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "JavaGatewayPort": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartJavaPollers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartVMwareCollectors": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "VMwareFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "VMwarePerfFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "VMwareCacheSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "VMwareTimeout": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SNMPTrapperFile": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartSNMPTrapper": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "HousekeepingFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "MaxHousekeeperDelete": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SenderFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "CacheSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "CacheUpdateFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartDBSyncers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "HistoryCacheSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "HistoryIndexCacheSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "TrendCacheSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "ValueCacheSize": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "Timeout": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "TrapperTimeout": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "UnreachablePeriod": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "UnavailableDelay": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "UnreachableDelay": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "AlertScriptsPath": '/usr/lib/zabbix/alertscripts'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "ExternalScripts": '/usr/lib/zabbix/externalscripts'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "FpingLocation": '/usr/sbin/fping'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "Fping6Location": '/usr/sbin/fping6'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSHKeyLocation": '/var/lib/zabbix/ssh_keys'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogSlowQueries": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "StartProxyPollers": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "ProxyConfigFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "ProxyDataFrequency": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSLCertLocation": '/var/lib/zabbix/ssl/certs/'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSLKeyLocation": '/var/lib/zabbix/ssl/keys/'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSLCALocation": '/var/lib/zabbix/ssl/ssl_ca/'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "LoadModulePath": '/var/lib/zabbix/modules/'... added
** Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSCAFile": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSCRLFile": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSCertFile": ''... removed
** Updating '/etc/zabbix/zabbix_server.conf' parameter "TLSKeyFile": ''... removed
** Cleaning the system
########################################################
** Executing supervisord
2018-05-31 14:31:41,095 CRIT Set uid to user 0
2018-05-31 14:31:41,095 CRIT Set uid to user 0
2018-05-31 14:31:41,095 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2018-05-31 14:31:41,095 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2018-05-31 14:31:41,103 INFO RPC interface 'supervisor' initialized
2018-05-31 14:31:41,103 INFO RPC interface 'supervisor' initialized
2018-05-31 14:31:41,103 INFO supervisord started with pid 1
2018-05-31 14:31:41,103 INFO supervisord started with pid 1
2018-05-31 14:31:42,108 INFO spawned: 'zabbix-server' with pid 108
2018-05-31 14:31:42,108 INFO spawned: 'zabbix-server' with pid 108
Starting Zabbix Server. Zabbix 3.2.5 (revision 67445).
Press Ctrl+C to exit.

   108:20180531:143142.119 Starting Zabbix Server. Zabbix 3.2.5 (revision 67445).
   108:20180531:143142.120 ****** Enabled features ******
   108:20180531:143142.120 SNMP monitoring:           YES
   108:20180531:143142.120 IPMI monitoring:           YES
   108:20180531:143142.120 Web monitoring:            YES
   108:20180531:143142.121 VMware monitoring:         YES
   108:20180531:143142.121 SMTP authentication:       YES
   108:20180531:143142.121 Jabber notifications:       NO
   108:20180531:143142.121 Ez Texting notifications:  YES
   108:20180531:143142.122 ODBC:                      YES
   108:20180531:143142.122 SSH2 support:              YES
   108:20180531:143142.122 IPv6 support:              YES
   108:20180531:143142.122 TLS support:               YES
   108:20180531:143142.122 ******************************
   108:20180531:143142.123 using configuration file: /etc/zabbix/zabbix_server.conf
   108:20180531:143142.151 current database version (mandatory/optional): 03020000/03020000
   108:20180531:143142.152 required mandatory version: 03020000
   108:20180531:143142.218 server #0 started [main process]
   109:20180531:143142.219 server #1 started [configuration syncer #1]
   110:20180531:143142.220 server #2 started [db watchdog #1]
   111:20180531:143142.220 server #3 started [poller #1]
   125:20180531:143142.226 server #17 started [timer #1]
   120:20180531:143142.227 server #12 started [trapper #4]
   126:20180531:143142.231 server #18 started [http poller #1]
   112:20180531:143142.231 server #4 started [poller #2]
   127:20180531:143142.232 server #19 started [discoverer #1]
   113:20180531:143142.233 server #5 started [poller #3]
   114:20180531:143142.233 server #6 started [poller #4]
   128:20180531:143142.233 server #20 started [history syncer #1]
   115:20180531:143142.237 server #7 started [poller #5]
   129:20180531:143142.237 server #21 started [history syncer #2]
   116:20180531:143142.237 server #8 started [unreachable poller #1]
   130:20180531:143142.238 server #22 started [history syncer #3]
   131:20180531:143142.240 server #23 started [history syncer #4]
   132:20180531:143142.240 server #24 started [escalator #1]
   133:20180531:143142.242 server #25 started [proxy poller #1]
   134:20180531:143142.244 server #26 started [self-monitoring #1]
   135:20180531:143142.248 server #27 started [task manager #1]
   121:20180531:143142.249 server #13 started [trapper #5]
   117:20180531:143142.249 server #9 started [trapper #1]
   122:20180531:143142.250 server #14 started [icmp pinger #1]
   118:20180531:143142.251 server #10 started [trapper #2]
   123:20180531:143142.252 server #15 started [alerter #1]
   119:20180531:143142.253 server #11 started [trapper #3]
   124:20180531:143142.253 server #16 started [housekeeper #1]
2018-05-31 14:31:43,254 INFO success: zabbix-server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-05-31 14:31:43,254 INFO success: zabbix-server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
   120:20180531:143405.258 cannot send list of active checks to "172.17.0.1": host [hostname] not found
   121:20180531:143527.483 cannot send list of active checks to "172.17.0.1": host [hostname] not found
   116:20180531:143607.352 enabling Zabbix agent checks on host "Zabbix server": host became available
# web
localhost:~ Sean$ docker logs de277d1fbd25
** Deploying Zabbix frontend (apache) with mysql database
** Preparing the system
** Preparing Zabbix web-interface
********************
* DB_SERVER_HOST: docker.for.mac.host.internal
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ZBX_USER: root
* DB_SERVER_ZBX_PASS: admin
********************
** Disable default site
** Adding Zabbix virtual host (HTTP)
**** Impossible to enable SSL support for Apache2. Certificates are missed.
** Preparing Zabbix frontend configuration file
** Updating '/etc/php5/conf.d/99-zabbix.ini' parameter "max_execution_time": '600'... updated
** Updating '/etc/php5/conf.d/99-zabbix.ini' parameter "memory_limit": '128M'... updated
** Updating '/etc/php5/conf.d/99-zabbix.ini' parameter "post_max_size": '16M'... updated
** Updating '/etc/php5/conf.d/99-zabbix.ini' parameter "upload_max_filesize": '2M'... updated
** Updating '/etc/php5/conf.d/99-zabbix.ini' parameter "max_input_time": '300'... updated
** Updating '/etc/php5/conf.d/99-zabbix.ini' parameter "date.timezone": 'Asia/Shanghai'... added
** Cleaning the system
########################################################
** Executing supervisord
2018-05-31 14:38:07,611 CRIT Set uid to user 0
2018-05-31 14:38:07,611 CRIT Set uid to user 0
2018-05-31 14:38:07,612 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2018-05-31 14:38:07,612 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2018-05-31 14:38:07,621 INFO RPC interface 'supervisor' initialized
2018-05-31 14:38:07,621 INFO RPC interface 'supervisor' initialized
2018-05-31 14:38:07,621 INFO supervisord started with pid 1
2018-05-31 14:38:07,621 INFO supervisord started with pid 1
2018-05-31 14:38:08,628 INFO spawned: 'apache2' with pid 30
2018-05-31 14:38:08,628 INFO spawned: 'apache2' with pid 30
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
[Thu May 31 14:38:08.663829 2018] [mpm_prefork:notice] [pid 30] AH00163: Apache/2.4.25 (Unix) PHP/5.6.30 configured -- resuming normal operations
[Thu May 31 14:38:08.664184 2018] [core:notice] [pid 30] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
2018-05-31 14:38:09,666 INFO success: apache2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-05-31 14:38:09,666 INFO success: apache2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
#总揽
CONTAINER ID        IMAGE                                         COMMAND                  CREATED             STATUS              PORTS                                        NAMES
1d92829fb478        zabbix/zabbix-agent:alpine-3.2.5              "/bin/bash /run_zabb…"   3 days ago          Up 57 seconds       0.0.0.0:10050->10050/tcp                     some-zabbix-agent
ff3feda84ac1        zabbix/zabbix-web-apache-mysql:alpine-3.2.5   "/bin/bash /run_zabb…"   3 days ago          Up About a minute   443/tcp, 0.0.0.0:8088->80/tcp                some-zabbix-web-apache-mysql
0aab68a67f1c        zabbix/zabbix-server-mysql:alpine-3.2.5       "/bin/bash /run_zabb…"   3 days ago          Up About a minute   162/udp, 0.0.0.0:10051->10051/tcp            some-zabbix-server-mysql

Zabbix(Docker版) 监控系统的安装_第1张图片


Reference

[1] (Abel)docker 安装 zabbix
[2] (csdn)开源商业级服务器监控软件Zabbix 3.4.4部署方法
[3] (cnblog)docker搭建zabbix
[4] (agent error)Zabbix discoverer processes more than 75% busy原因及解决方法
[5] (agent error)zabbix_agentd.log里面有出现host [] not found错误的解决
[6] (web error)Zabbix server is not running:the information displayed may not be current

你可能感兴趣的:(25.,监控工具,-------25.1,zabbix)