搭建Zabbix监控系统

1.Zabbix是一个基于Web界面企业及开源监控套件
1.1具备功能
主机的性能监控、网络设备性能监控、数据库性能监控、多种告警方式、详细报表图表绘制
1.2监测对象
Linux 服务器 、Windows服务器、路由器、交换机等网络设备
1.3官方网站是http://www.zabbix.com
2. Zabbix重要组件
Zabbix Server、 Database storage、Web interface、 Pxory、 Agent

3.Zabbix进程
zabbix_agentd、zabbix_get、zabbix_proxy、zabbix_sender、zabbix_server、zabbix_java_gateway

实验环境:gns与vmware桥接实验
1.gns
1台交换机 sw1
vlan 1 : 192.168.10.100

  1. 2台linux服务器+1台windows服务器

2.1 linux-1 centos7.4 zabbix监控服务器
vmnet1 192.168.10.1

2.2 linux-2 centos7.4 被监控端
vmnet1 192.168.10.2

2.3 windows7 被监控端
vmnet1 192.168.10.3

实验步骤:
一、zabbix服务器 192.168.10.1

1.安装数据库—实现LAMP环境
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。

开发这个分支的原因是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。

MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

[root@localhost ~]# yum -y install mariadb-server mariadb

[root@localhost ~]# systemctl start mariadb

[root@localhost ~]# systemctl stop mariadb

[root@localhost ~]# systemctl enable mariadb

[root@localhost ~]# systemctl restart mariadb

[root@localhost ~]# netstat -anpt|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1628/mysqld

[root@localhost ~]# mysqladmin -u root password 123

[root@localhost ~]# mysql -u root -p123

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server

Copyright © 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 |
| mysql |
| performance_schema |
| test |
±-------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

  1. 安装zabbix(yum方式安装)
    ##zabbix安装时会有很多依赖包(包含httpd和php相关软件包),所以无需再安装httpd和php

##zabbix软件包需要去zabbix官网下载

创建本地yum源
[root@localhost ~]# which createrepo

[root@localhost ~]# mkdir /other

上传zabbix相关软件到此目录

[root@localhost other]# ll /other/zabbix*

-rw-r–r-- 1 root root 361808 10月 7 19:02 /other/zabbix-agent-3.4.1-1.el7.x86_64.rpm
-rw-r–r-- 1 root root 2046420 10月 7 19:02 /other/zabbix-server-mysql-3.4.1-1.el7.x86_64.rpm
-rw-r–r-- 1 root root 2637704 10月 7 19:02 /other/zabbix-web-3.4.1-1.el7.noarch.rpm
-rw-r–r-- 1 root root 6088 10月 7 19:02 /other/zabbix-web-mysql-3.4.1-1.el7.noarch.rpm

[root@localhost other]# vim /etc/yum.repos.d/local.repo

[local]
name=centos7.4
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

[other]
name=zabbix
baseurl=file:///other
enabled=1
gpgcheck=0

创建软件数据库目录
[root@localhost other]# createrepo /other

[root@localhost ~]# yum makecache

已加载插件:fastestmirror
local | 3.6 kB 00:00
other | 2.9 kB 00:00
(1/5): other/filelists_db | 55 kB 00:00
(2/5): other/other_db | 29 kB 00:00
(3/5): other/primary_db | 65 kB 00:00
(4/5): local/other_db | 1.2 MB 00:00
(5/5): local/filelists_db | 3.1 MB 00:00
Loading mirror speeds from cached hostfile
元数据缓存已建立

[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

##zabbix web需要数据库。在mariadb中创建数据库zabbix,授权用户zabbix管理,增强安全性。

[root@localhost ~]# mysql -u root -p123

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘123123’;

MariaDB [(none)]> exit

导入数据库脚本
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.1/create.sql.gz |mysql -uzabbix -p123123 zabbix

  1. 检查和编辑配置文件
    ##server配置文件 /etc/zabbix/zabbix_server.conf
    ##指定数据库名称、用户、密码
    [root@localhost ~]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak

[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf

91
DBHost=localhost
101 DBName=zabbix
117 DBUser=zabbix
125 DBPassword=123123

##agent配置文件 /usr/local/etc/zabbix_agentd.conf,指定server的ip地址(每台agent主机都要配置,本地服务器中不做修改)

[root@localhost ~]# cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf

客户端被动等待指定服务器来查询数据

97 Server=127.0.0.1

##客户端主动提交数据到指定服务器
138 ServerActive=127.0.0.1
149 Hostname=Zabbix server

启动server、agent、httpd
[root@localhost ~]# systemctl start zabbix-server

[root@localhost ~]# systemctl enable zabbix-server

[root@localhost ~]# systemctl start zabbix-agent

[root@localhost ~]# systemctl enable zabbix-agent

[root@localhost ~]# systemctl start httpd

[root@localhost ~]# systemctl enable httpd

[root@localhost ~]# netstat -anpt|grep zabbix

tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 16302/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 16216/zabbix_server
tcp6 0 0 :::10050 ::😗 LISTEN 16302/zabbix_agentd
tcp6 0 0 :::10051 ::😗 LISTEN 16216/zabbix_server

[root@localhost ~]# netstat -anpt|grep httpd

tcp6 0 0 :::80 ::😗 LISTEN 16334/httpd

4.安装zabbix web接口
1)编辑apache服务针对zabbix的前端配置为/etc/httpd/conf.d/zabbix.conf 设置时区与当前系统时区一致

[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf

19 php_value date.timezone Asia/Shanghai

[root@localhost ~]# systemctl restart httpd

2)浏览器 http://192.168.10.1/zabbix

  • 系统环境检测:确保软件都符合要求
  • 数据库连接界面:数据库名称、用户、密码(123123)

*监控平台信息
host:localhost
port:10051
name:zabbix监控平台

*返回汇总信息,确认无误
在里插入图片描述

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值