码迷,mamicode.com
首页 > 其他好文 > 详细

Zabbix监控基本安装

时间:2020-03-15 23:49:30      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:updating   lib   emc   Inventor   导入数据   tab   key   服务端   detail   

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监控基本安装

标签:updating   lib   emc   Inventor   导入数据   tab   key   服务端   detail   

原文地址:https://blog.51cto.com/13751090/2478500

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!