zabbix

下载并安装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图标变成绿色,连接失败变红色



回到图形页面查看折线图
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,133评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,682评论 3 390
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,784评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,508评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,603评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,607评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,604评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,359评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,805评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,121评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,280评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,959评论 5 339
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,588评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,206评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,442评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,193评论 2 367
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,144评论 2 352

推荐阅读更多精彩内容

  • Zabbix简介 Zabbix官方网站Zabbix中文文档 本文系统环境是CentOS7x86_64, Zabbi...
    Zhang21阅读 7,985评论 0 37
  • 自定义key网络发现Web监控主动检测基于SNMP监控基于JMX监控Zabbix ProxyZabbix调优 一、...
    哈喽别样阅读 1,142评论 0 1
  • 1.写在前面 本文主要介绍的是zabbix的编译安装过程,包含它的基础环境LNMP,虽然zabbix官方一般推荐的...
    天之蓝色阅读 2,532评论 0 16
  • 1. 安装epel扩展包,并升级ca证书ssl yum install -y epel-releaseyum --...
    石乐志的LK阅读 882评论 0 0
  • 从没想过 原来 猪也是会骨折的 所以 我做了猪蹄汤给你喝 希望你的猪蹄 快点好
    虾米酱Wow阅读 159评论 0 2