开源商业级服务器监控软件Zabbix 3.4.4部署方法

来源:互联网 发布:怎么在阿里云里备案 编辑:程序博客网 时间:2024/05/16 03:00

zabbix是一款免费开源而且商业级的服务器监控软件,扩展性很强,部署简单,是一个很好的服务器负载监控解决方案

zabbix分为server和agent,proxy三个模块,server由zabbix,mysql,php和中间件组成,用来提供Web页面并且定时轮训检查各个被监控主机的,agent是跑在被监控主机上面,定时收集主机信息的,proxy是放在防火墙上做转发代理的。

要部署zabbix需要准备以下几个材料


服务端

1、mysql,我这里使用docker,https://hub.docker.com/r/alexzhuo/mysql/

2、zabbix-server,我这里也使用docker:https://hub.docker.com/r/zabbix/zabbix-server-mysql/

3、zabbix中间件,也是docker:https://hub.docker.com/r/zabbix/zabbix-web-nginx-mysql/

服务端不管你是什么操作系统,只要部署3个docker就可以了,非常容易,减少了很多兼容问题


被监控端

下载相应的rpm或者deb包安装即可


服务端的搭建比较麻烦,客户端容易,所以我们先介绍服务端的搭建步骤

首先将3个docker pull到本地,由于docker hub国内速度很慢,服务器也没法连接公网,所以我这里是在别的电脑save下来,然后到监控主机上直接安装

[root@localhost ~]# docker load < /root/mysql.tar745f5be9952c: Loading layer [==================================================>] 135.7 MB/135.7 MB85782553e37a: Loading layer [==================================================>] 15.87 kB/15.87 kB29660d0e5bb2: Loading layer [==================================================>] 11.78 kB/11.78 kB440e02c3dcde: Loading layer [==================================================>] 4.608 kB/4.608 kB56827159aa8b: Loading layer [==================================================>] 3.072 kB/3.072 kB8cb043c85445: Loading layer [==================================================>] 477.9 MB/477.9 MBf5ceb2bf1cc3: Loading layer [==================================================>] 139.4 MB/139.4 MBLoaded image: alexzhuo/mysql:5.7                                                ] 557.1 kB/139.4 MBLoaded image ID: sha256:d0bfd2b961fd0f801f86de053356379c2355e70f480972ee06b87a55333e1175Loaded image ID: sha256:f04c878f4fb0cfd82f7e138a7138e4e40e00199d4fef570e99ac7ef4a0d30d3a[root@localhost ~]# docker load < /root/zabbix-server-mysql.taref763da74d91: Loading layer [==================================================>] 5.058 MB/5.058 MB19023d040ef1: Loading layer [==================================================>] 98.01 MB/98.01 MB7de75a51a1ef: Loading layer [==================================================>]    12 MB/12 MB14e240c7dfd1: Loading layer [==================================================>] 5.632 kB/5.632 kB37f180052c31: Loading layer [==================================================>] 36.35 kB/36.35 kBLoaded image: zabbix/zabbix-server-mysql:alpine-3.4.4                           ]    512 B/36.35 kB[root@localhost ~]# docker load < /root/zabbix-web-nginx-mysql.tarcb0e385a9b35: Loading layer [==================================================>] 141.2 MB/141.2 MB2bfd8c2624ee: Loading layer [==================================================>] 3.072 kB/3.072 kB176bad0b5cef: Loading layer [==================================================>] 36.15 MB/36.15 MB56c77e189281: Loading layer [==================================================>] 5.632 kB/5.632 kBfbcdf5e59ad3: Loading layer [==================================================>] 4.608 kB/4.608 kBbf7269ea0868: Loading layer [==================================================>] 5.632 kB/5.632 kB5b6aed9c7e11: Loading layer [==================================================>] 3.584 kB/3.584 kB9aff7fe48c6a: Loading layer [==================================================>] 4.608 kB/4.608 kB9d962e9eaeec: Loading layer [==================================================>]  25.6 kB/25.6 kB09cd8c1a9355: Loading layer [==================================================>] 3.584 kB/3.584 kB0b16c5f8e035: Loading layer [==================================================>] 36.35 kB/36.35 kBLoaded image: zabbix/zabbix-web-nginx-mysql:alpine-3.4.4                        ]    512 B/36.35 kB

然后我们按照顺序启动三个docker,分别是mysql,zabbix-server,zabbix php中间件,如下

docker run -itd -p 3306:3306 alexzhuo/mysql:5.7 /etc/start_mysql.sh

这样就启动了mysql,开放宿主机的3306端口,mysql的用户名root,密码123456,数据库名mysql,可以用mysql客户端登录进去看看,现在是一个空的数据库,什么都没有。

注意,mysql的表空间位置是docker里面的/var/lib/mysql 目录,如果你的docker停止,里面的表空间也会丢失,监控数据也就没了,如果想要监控数据持久化,就要把/var/lib/mysql 这个目录通过-v参数挂载到宿主机上,实现方法见docker hub主页的ReadMe


然后启动zabbix服务端程序,并开放宿主机10051端口

docker run --name some-zabbix-server-mysql -e DB_SERVER_HOST="192.166.1.187" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="root" -e MYSQL_PASSWORD="123456" -p 10051:10051 -d zabbix/zabbix-server-mysql:alpine-3.4.4

其中

DB_SERVER_HOST:是数据库的IP地址,由于刚才已经把mysql的3306端口映射到了宿主机,所以此处的ip就是宿主机的ip

MYSQL_DATABASE:是数据库的名字,是zabbix-server建库时使用的名字,一般填zabbix就行。

MYSQL_USER:是mysql的用户名,我上面那个docker开放了root,所以这里填root

MYSQL_PASSWORD:是mysql的密码,上面docker里root的密码是123456,如果你用自己的mysql数据库,就按照实际情况来就行


启动之后,就可以使用

docker logs some-zabbix-server-mysql
来查看zabbix启动的过程,正常的log如下

[root@localhost mysql]# docker logs some-zabbix-server-mysql** Deploying Zabbix server with mysql database** Preparing the system** Preparing Zabbix server********************* DB_SERVER_HOST: 192.166.1.187* DB_SERVER_PORT: 3306* DB_SERVER_DBNAME: zabbix* DB_SERVER_ZBX_USER: root* DB_SERVER_ZBX_PASS: 123456********************** Creating 'root' user in MySQL database** Database 'zabbix' does not exist. Creating...** Creating 'zabbix' schema in MySQL** Fill the schema with initial data** 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": '192.166.1.187'... 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": '123456'... 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 supervisord2017-12-18 02:39:00,234 CRIT Set uid to user 02017-12-18 02:39:00,234 CRIT Set uid to user 02017-12-18 02:39:00,235 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing2017-12-18 02:39:00,235 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing2017-12-18 02:39:00,254 INFO RPC interface 'supervisor' initialized2017-12-18 02:39:00,254 INFO RPC interface 'supervisor' initialized2017-12-18 02:39:00,255 INFO supervisord started with pid 12017-12-18 02:39:00,255 INFO supervisord started with pid 12017-12-18 02:39:01,259 INFO spawned: 'zabbix-server' with pid 1202017-12-18 02:39:01,259 INFO spawned: 'zabbix-server' with pid 120Starting Zabbix Server. Zabbix 3.4.4 (revision 74338).Press Ctrl+C to exit.   120:20171218:023901.292 Starting Zabbix Server. Zabbix 3.4.4 (revision 74338).   120:20171218:023901.292 ****** Enabled features ******   120:20171218:023901.292 SNMP monitoring:           YES   120:20171218:023901.292 IPMI monitoring:           YES   120:20171218:023901.292 Web monitoring:            YES   120:20171218:023901.292 VMware monitoring:         YES   120:20171218:023901.292 SMTP authentication:       YES   120:20171218:023901.292 Jabber notifications:       NO   120:20171218:023901.292 Ez Texting notifications:  YES   120:20171218:023901.292 ODBC:                      YES   120:20171218:023901.292 SSH2 support:              YES   120:20171218:023901.292 IPv6 support:              YES   120:20171218:023901.292 TLS support:               YES   120:20171218:023901.292 ******************************   120:20171218:023901.292 using configuration file: /etc/zabbix/zabbix_server.conf   120:20171218:023901.304 current database version (mandatory/optional): 03040000/03040005   120:20171218:023901.304 required mandatory version: 03040000   120:20171218:023901.334 server #0 started [main process]   121:20171218:023901.334 server #1 started [configuration syncer #1]   122:20171218:023901.335 server #2 started [alerter #1]   123:20171218:023901.335 server #3 started [alerter #2]   124:20171218:023901.335 server #4 started [alerter #3]   125:20171218:023901.335 server #5 started [housekeeper #1]   126:20171218:023901.336 server #6 started [timer #1]   127:20171218:023901.336 server #7 started [http poller #1]   128:20171218:023901.336 server #8 started [discoverer #1]   129:20171218:023901.336 server #9 started [history syncer #1]   130:20171218:023901.336 server #10 started [history syncer #2]   132:20171218:023901.337 server #12 started [history syncer #4]   133:20171218:023901.337 server #13 started [escalator #1]   131:20171218:023901.338 server #11 started [history syncer #3]   134:20171218:023901.338 server #14 started [proxy poller #1]   135:20171218:023901.338 server #15 started [self-monitoring #1]   137:20171218:023901.339 server #17 started [poller #1]   139:20171218:023901.339 server #19 started [poller #3]   138:20171218:023901.339 server #18 started [poller #2]   141:20171218:023901.340 server #21 started [poller #5]   142:20171218:023901.341 server #22 started [unreachable poller #1]   150:20171218:023901.342 server #30 started [preprocessing manager #1]   144:20171218:023901.342 server #24 started [trapper #2]   136:20171218:023901.343 server #16 started [task manager #1]   145:20171218:023901.343 server #25 started [trapper #3]   153:20171218:023901.344 server #33 started [preprocessing worker #3]   143:20171218:023901.344 server #23 started [trapper #1]   152:20171218:023901.348 server #32 started [preprocessing worker #2]   140:20171218:023901.348 server #20 started [poller #4]   146:20171218:023901.349 server #26 started [trapper #4]   149:20171218:023901.349 server #29 started [alert manager #1]   151:20171218:023901.351 server #31 started [preprocessing worker #1]   147:20171218:023901.353 server #27 started [trapper #5]   148:20171218:023901.356 server #28 started [icmp pinger #1]2017-12-18 02:39:02,358 INFO success: zabbix-server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)2017-12-18 02:39:02,358 INFO success: zabbix-server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)[root@localhost mysql]# 


如果出现上面的日志,那么证明zabbix服务端启动成功了。


最容易出现问题的是数据库连接不上,如下

[root@localhost ~]# docker logs some-zabbix-server-mysql** Deploying Zabbix server with mysql database** Preparing the system** Preparing Zabbix server********************* DB_SERVER_HOST: 172.17.0.2* DB_SERVER_PORT: 3306* DB_SERVER_DBNAME: zabbix* DB_SERVER_ZBX_USER: root* DB_SERVER_ZBX_PASS: 123456************************ MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...**** MySQL server is not available. Waiting 5 seconds...

zabbix服务端启动成功之后,就可以启动中间件了,中间件也要指定数据库,启动命令如下


docker run --name zabbix-web-nginx-mysql -e DB_SERVER_HOST="192.166.1.187" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="root" -e MYSQL_PASSWORD="123456" -e ZBX_SERVER_HOST="192.166.1.187" -e PHP_TZ="Asia/Shanghai" -p 8080:80 -d zabbix/zabbix-web-nginx-mysql:alpine-3.4.4

DB_SERVER_HOST:和上面的zabbix-server一样,填写mysql数据库的地址,由于已经把3306端口映射到宿主机,所以填写宿主机的地址

ZBX_SERVER_HOST:是zabbix-server的地址,也就是上一步开启的docker,由于我们已经把10051映射到宿主机,所以填写宿主机的地址

PHP_TZ:填写时区,这样在看图的时候显示的时间就是本地时间了

-p 8080:80:是把docker的80端口映射到宿主机的8080端口,就可以通过8080直接访问

然后可以使用

docker logs zabbix-web-nginx-mysql

命令查看启动日志

如果出现如下日志,说明启动是成功的

[root@localhost mysql]# docker logs zabbix-web-nginx-mysql** Deploying Zabbix frontend (nginx) with mysql database** Preparing the system** Preparing Zabbix web-interface********************* DB_SERVER_HOST: 192.166.1.187* DB_SERVER_PORT: 3306* DB_SERVER_DBNAME: zabbix* DB_SERVER_ZBX_USER: root* DB_SERVER_ZBX_PASS: 123456********************** Disable default vhosts** Adding Zabbix virtual host (HTTP)**** Impossible to enable SSL support for Nginx. 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/Beijing'... added** Cleaning the system########################################################** Executing supervisord2017-12-18 02:45:09,049 CRIT Set uid to user 02017-12-18 02:45:09,049 CRIT Set uid to user 02017-12-18 02:45:09,049 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing2017-12-18 02:45:09,049 WARN Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing2017-12-18 02:45:09,068 INFO RPC interface 'supervisor' initialized2017-12-18 02:45:09,068 INFO RPC interface 'supervisor' initialized2017-12-18 02:45:09,068 INFO supervisord started with pid 12017-12-18 02:45:09,068 INFO supervisord started with pid 12017-12-18 02:45:10,071 INFO spawned: 'nginx' with pid 292017-12-18 02:45:10,071 INFO spawned: 'nginx' with pid 292017-12-18 02:45:10,073 INFO spawned: 'php-fpm' with pid 302017-12-18 02:45:10,073 INFO spawned: 'php-fpm' with pid 30[18-Dec-2017 02:45:10] WARNING: Nothing matches the include pattern '/etc/php5/fpm.d/*.conf' from /etc/php5/php-fpm.conf at line 15.2017-12-18 02:45:11,117 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)2017-12-18 02:45:11,117 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)2017-12-18 02:45:11,117 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)2017-12-18 02:45:11,117 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

然后就可以访问宿主机的8080端口了



默认用户名:Admin

默认密码:Zabbix

注意不支持ie浏览器哦


然后到Zabbix官网,根据你要监控的操作系统选择合适的安装包,我这里选择的是zabbix-agent-3.4.4-2.el7.x86_64.rpm,因为我的操作系统为Redhat 7.2


安装过程如下

[root@resinapp1 ~]# yum localinstall ./zabbix-agent-3.4.4-2.el7.x86_64.rpm 已加载插件:langpacks, product-id, search-disabled-repos, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.正在检查 ./zabbix-agent-3.4.4-2.el7.x86_64.rpm: zabbix-agent-3.4.4-2.el7.x86_64./zabbix-agent-3.4.4-2.el7.x86_64.rpm 将被安装正在解决依赖关系--> 正在检查事务---> 软件包 zabbix-agent.x86_64.0.3.4.4-2.el7 将被 安装--> 解决依赖关系完成base                                                                                                                           | 4.1 kB  00:00:00     centos                                                                                                                         | 3.6 kB  00:00:00     epel                                                                                                                           | 4.3 kB  00:00:00     依赖关系解决====================================================================================================================================================== Package                         架构                      版本                             源                                                   大小======================================================================================================================================================正在安装: zabbix-agent                    x86_64                    3.4.4-2.el7                      /zabbix-agent-3.4.4-2.el7.x86_64                    1.3 M事务概要======================================================================================================================================================安装  1 软件包总计:1.3 M安装大小:1.3 MIs this ok [y/d/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction  正在安装    : zabbix-agent-3.4.4-2.el7.x86_64                                                                                                   1/1   验证中      : zabbix-agent-3.4.4-2.el7.x86_64                                                                                                   1/1 已安装:  zabbix-agent.x86_64 0:3.4.4-2.el7                                                                                                                   完毕![root@resinapp1 ~]# 

安装完毕后需要修改/etc/zabbix/zabbix_agentd.conf,这个文件

找到里面的

Server=127.0.0.1

ServerActive=127.0.0.1

将ip地址改为监控主机的ip地址,我这里是192.166.1.187

就可以开启客户端程序了

systemctl start zabbix-agent.service

在红帽6和ubuntu中

service zabbix-agent start


启动之后,就可以看到开放了10050端口

[root@resinapp1 sbin]# netstat -anpt | grep 10050tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      19990/zabbix_agentd tcp6       0      0 :::10050                :::*                    LISTEN      19990/zabbix_agentd [root@resinapp1 sbin]# 

[root@resinapp1 sbin]# ps aux | grep zabbixzabbix   19990  0.0  0.0  86904  1280 ?        S    12:03   0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.confzabbix   19991  0.0  0.0  86904  1608 ?        S    12:03   0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]zabbix   19992  0.0  0.0  86904  1856 ?        S    12:03   0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]zabbix   19993  0.0  0.0  86904  1852 ?        S    12:03   0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]zabbix   19994  0.0  0.0  86904  1852 ?        S    12:03   0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]zabbix   19995  0.0  0.0  87032  2140 ?        S    12:03   0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]root     20028  0.0  0.0 112664   968 pts/0    S+   12:04   0:00 grep --color=auto zabbix


然后我们就可以回到zabbix的服务端页面,添加刚刚这台主机了



找到"Configuration"-“Hosts”中的Creat Host,填写被监控主机的IP和Groups


然后切换到Templates标签,根据主机的类型选择一个监控模板



不同的模板对应着不同的监控指标和不同的图像


然后点击最下面的Add按钮,添加一台被监控主机



当Aviliability中的ZBX变为绿色之后,说明已经zabbix服务器已经可以正常获取被监控主机的状态了,如果是红色的,说明网络出现了问题,需要检查zabbix主机和被监控服务器之间的网络联通性


然后就可以看到这台主机的CPU占用之类的参数了,搭建基本完成


如果图像中的时间显示不对,那么应该是时区没有设置好,应该检查时区的设置