下载并安装zabbix-release
[root@C7m ~]#wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
--2017-11-21 11:23:59-- http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
Resolving repo.zabbix.com (repo.zabbix.com)... 162.243.159.138
Connecting to repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13572 (13K) [application/x-redhat-package-manager]
Saving to: ‘zabbix-release-3.4-2.el7.noarch.rpm’
100%[===================================================>] 13,572 --.-K/s in 0s
2017-11-21 11:24:00 (282 MB/s) - ‘zabbix-release-3.4-2.el7.noarch.rpm’ saved [13572/13572]
[root@C7m ~]#ls
anaconda-ks.cfg zabbix-release-3.4-2.el7.noarch.rpm
[root@C7m ~]#rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm
warning: zabbix-release-3.4-2.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-3.4-2.el7 ################################# [100%]
[root@C7m ~]#rpm -ql zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-3.4
/usr/share/doc/zabbix-release-3.4/GPL
[root@C7m ~]#yum repolist
Loaded plugins: fastestmirror
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
zabbix/x86_64/primary_db | 44 kB 00:00:00
zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:00
Loading mirror speeds from cached hostfile
zabbix-non-supported 4/4
repo id repo name status
base base 9,363
cd cd 9,591
epel epel 11,349
zabbix/x86_64 Zabbix Official Repository - x86_64 80
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 4
repolist: 30,387
配置数据库并启动
[root@C7m ~]#vim /etc/my.cnf.d/server.cnf
# this is read by the standalone daemon and embedded servers
9 [server]
10 skip_name_resolve = ON
11 innodb_file_per_table = ON
12 innodb_buffer_pool_size = 256M
13 max_connections = 2000
14
15 log_bin = master-log
16 # this is only for the mysqld standalone daemon
17 [mysqld]
[root@C7m ~]#systemctl start mariadb
安装zabbix软件包
[root@C7m ~]#yum install zabbix-server-mysql zabbix-web zabbix-web-mysql zabbix-agent zabbix-get zabbix-sender
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
数据库授权
[root@C7m ~]#mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE zbxdb;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> GRANT ALL ON zbxdb.* TO 'zbxuser'@'172.18.55.%' IDENTIFIED BY 'centos';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> EXIT
Bye
导入数据表
[root@C7m ~]#cp /usr/share/doc/zabbix-server-mysql-3.4.4/create.sql.gz ./
[root@C7m ~]#ls
anaconda-ks.cfg create.sql.gz zabbix-release-3.4-2.el7.noarch.rpm
[root@C7m ~]#gzip -d create.sql.gz
[root@C7m ~]#ls
anaconda-ks.cfg create.sql zabbix-release-3.4-2.el7.noarch.rpm
[root@C7m ~]#mysql -uzbxuser -h172.18.55.2 -pcentos zbxdb < create.sql
查看导入详情
[root@C7m ~]#mysql -uzbxuser -h172.18.55.2 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zbxdb |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> USE zbxdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zbxdb]> SHOW TABLES;
+----------------------------+
| Tables_in_zbxdb |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| groups |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| task |
| task_acknowledge |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
140 rows in set (0.01 sec)
MariaDB [zbxdb]> EXIT
Bye
备份及修改zabbix配置文件
[root@C7m zabbix]#cd /etc/zabbix/
[root@C7m zabbix]#ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@C7m zabbix]#cp zabbix_server.conf{,.bak}
[root@C7m zabbix]#ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf zabbix_server.conf.bak
[root@C7m zabbix]#vim zabbix_server.conf
ListenPort=10051
SocketDir=/var/run/zabbix
DBHost=172.18.55.2
DBName=zbxdb
DBUser=zbxuser
DBPassword=centos
DBPort=3306
启动zabbix
[root@C7m zabbix]#systemctl start zabbix-server
[root@C7m zabbix]#systemctl status zabbix-server
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2017-11-21 15:19:41 +08; 8s ago
Process: 2877 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 2879 (zabbix_server)
CGroup: /system.slice/zabbix-server.service
└─2879 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
Nov 21 15:19:40 C7m systemd[1]: Starting Zabbix Server...
Nov 21 15:19:41 C7m systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (y...art.
Nov 21 15:19:41 C7m systemd[1]: Started Zabbix Server.
Hint: Some lines were ellipsized, use -l to show in full.
修改时区并启动httpd
[root@C7m conf.d]#vim /etc/php.ini
875 [Date]
876 ; Defines the default timezone used by the date functions
877 ; http://php.net/date.timezone
878 date.timezone = Asia/ShangHai
[root@C7m conf.d]#systemctl start httpd
[root@C7m conf.d]#systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2017-11-21 15:34:00 +08; 8s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 2897 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─2897 /usr/sbin/httpd -DFOREGROUND
├─2899 /usr/sbin/httpd -DFOREGROUND
├─2900 /usr/sbin/httpd -DFOREGROUND
├─2901 /usr/sbin/httpd -DFOREGROUND
├─2902 /usr/sbin/httpd -DFOREGROUND
└─2903 /usr/sbin/httpd -DFOREGROUND
Nov 21 15:33:59 C7m systemd[1]: Starting The Apache HTTP Server...
Nov 21 15:33:59 C7m httpd[2897]: AH00558: httpd: Could not reliably determine the serve...age
Nov 21 15:34:00 C7m systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
http连接zabbix web端,进行初始化配置
初始化配置zabbix
填写连接ip和授权数据库
填写主机名称(选填)
确认信息
在登录时,默认用户为admin,默认密码为zabbix
被监控端安装zabbix-agent、zabbix-sender
[root@C7mini ~]#yum install zabbix-agent zabbix-sender
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
cd | 3.6 kB 00:00:00
epel | 4.3 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 0:3.4.4-2.el7 will be installed
---> Package zabbix-sender.x86_64 0:3.4.4-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================
Package Arch Version Repository Size
=============================================================================================
Installing:
zabbix-agent x86_64 3.4.4-2.el7 zabbix 358 k
zabbix-sender x86_64 3.4.4-2.el7 zabbix 258 k
配置zabbix-agent并启动
[root@C7mini ~]#cd /etc/zabbix/
[root@C7mini zabbix]#ls
zabbix_agentd.conf zabbix_agentd.d
97 Server=172.18.55.2
106 ListenPort=10050
115 ListenIP=0.0.0.0
124 StartAgents=3
140 ServerActive=172.18.55.2
151 Hostname=node2
[root@C7mini zabbix]#grep -i "^[^#]" zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.18.55.2
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=3
ServerActive=172.18.55.2
Hostname=node2
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@C7mini zabbix]#systemctl start zabbix-agent
[root@C7mini zabbix]#systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2017-11-23 09:28:40 +08; 8s ago
Process: 5855 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 5857 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─5857 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─5858 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─5859 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─5860 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─5861 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─5862 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Nov 23 09:28:40 C7mini systemd[1]: Starting Zabbix Agent...
Nov 23 09:28:40 C7mini systemd[1]: Started Zabbix Agent.
使用agent被动监控
在web端设置使用agent方式监控主机node4,ip172.18.55.4,首先创建一个主机群组,在Host groups 点右上角Create host group创建新的组,命名为mysrvs
在Hosts下点右上角Create host,添加新的主机,设置名称、组和ip
此ip是172.18.55.4,截图前失误,下同
点击Applictions设置监控类
点击右上角Create applictions 创建类别
在Hosts下点击Items,在Items右上角点击Create items创建新的监控项,设置key和更新时间
此处ip应该和Host对应,为172.18.55.4
等待主机连接,时间可能较长,在连接成功后,右边ZBX图标变成绿色,连接失败变红色
回到图形页面查看折线图