Zabbix监控基本安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zabbix监控基本安装相关的知识,希望对你有一定的参考价值。

1. 安装硬件要求
ip地址 硬件配置 主机名
10.0.0.61 1CPU、1G内存 zabbix-server

2. 安装步骤

(1)下载zabbix官方源
[root@zabbix-server /etc/yum.repos.d]# wget -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
wget到本地,方便下次使用

[root@zabbix-server /etc/yum.repos.d]# rpm -Uvh zabbix-release-4.0-1.el7.noarch.rpm 
warning: zabbix-release-4.0-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-4.0-1.el7         ################################# [100%]

[root@zabbix-server /etc/yum.repos.d]# ll -h
total 28K
-rw-r--r--  1 root root 1.6K Dec  1  2016 CentOS-Base.repo
-rw-r--r--  1 root root  664 May 11  2018 epel-7.repo
drwxr-xr-x. 2 root root  187 Apr 19 12:36 test
-rw-r--r--  1 root root  14K Oct  2  2018 zabbix-release-4.0-1.el7.noarch.rpm
-rw-r--r--  1 root root  410 Oct  2  2018 zabbix.repo

(2)更改zabbix.repo
[root@zabbix-server /etc/yum.repos.d]# vim zabbix.repo_bak 
把第3行的baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/
改成
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/

把第10行的baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
改成
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/

(3)安装zabbix服务端和zabbix-web前端
[root@zabbix-server /etc/yum.repos.d]# yum install zabbix-server-mysql zabbix-web-mysql -y

(4)安装数据库并启动
[root@zabbix-server /etc/yum.repos.d]# yum -y install mariadb-server
[root@zabbix-server /etc/yum.repos.d]# systemctl enable mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix-server /etc/yum.repos.d]# systemctl start mariadb.service 
[root@zabbix-server /etc/yum.repos.d]# echo $?
0

(5)初始化数据库
[root@zabbix-server /etc/yum.repos.d]# mysql_secure_installation 
回车
n
一直y

(6)登录数据库创建zabbix库及授权
[root@zabbix-server ~]# mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘123456‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye

(7)导入数据
使用 MySQL 来导入 Zabbix server 的初始数据库 schema 和数据
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix

(8)检查导入是否成功
[root@zabbix-server ~]# mysql -uroot zabbix -e ‘show tables‘
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| 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_suppress             |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| hstgrp                     |
| 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         |
| maintenance_tag            |
| 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              |
| tag_filter                 |
| task                       |
| task_acknowledge           |
| task_check_now             |
| 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               |
+----------------------------+

(9)为 Zabbix server/proxy 配置数据库
编辑 zabbix_server.conf 或 zabbix_proxy.conf 文件以使用已创建的数据库
[root@zabbix-server ~]# vim  /etc/zabbix/zabbix_server.conf
91行:# DBHost=localhost
改成
DBHost=localhost

DBName=zabbix 不用改
DBUser=zabbix  不用改

124行:# DBPassword=
改成
DBPassword=123456

(10)启动 Zabbix server 进程
[root@zabbix-server ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@zabbix-server ~]# systemctl start zabbix-server

(11)检查启动情况
[root@zabbix-server ~]# netstat -lntup|grep 10051
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      7718/zabbix_server  
tcp6       0      0 :::10051                :::*                    LISTEN      7718/zabbix_server

(12)Zabbix 前端配置
[root@zabbix-server ~]# vim /etc/httpd/conf.d/zabbix.conf
把20行的:# php_value date.timezone Europe/Riga
改成
php_value date.timezone Asia/Shanghai

(13)启动httpd
[root@zabbix-server ~]# systemctl  enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix-server ~]# systemctl start httpd

(14)浏览器访问

ip+/zabbix

技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片

3. 在zabbix服务端添加agent

(1)下载rpm包
[root@zabbix-server ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.11-1.el7.x86_64.rpm

[root@zabbix-server ~]# ls
anaconda-ks.cfg                       zabbix-release-4.0-1.el7.noarch.rpm
zabbix-agent-4.0.11-1.el7.x86_64.rpm

(2)安装
[root@zabbix-server ~]# rpm -ivh zabbix-agent-4.0.11-1.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-agent-4.0.11-1.el7        ################################# [100%]

(3)启动服务
[root@zabbix-server ~]# systemctl start zabbix-agent.service
[root@zabbix-server ~]# systemctl enable zabbix-server.service

(4)网页验证
技术图片

以上是关于Zabbix监控基本安装的主要内容,如果未能解决你的问题,请参考以下文章

zabbix基本监控,端口监控,WEB站点监控,邮件报警

Zabbix4.0 linux 基本监控

Zabbix——Zabbix的安装和基本配置

zabbix监控,Zabbix4.0安装配置,Linux监控

zabbix安装和基本介绍

zabbix安装和基本介绍