zabbix分布式监控环境搭建

Posted alexr

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix分布式监控环境搭建相关的知识,希望对你有一定的参考价值。

 

 

本次测试主要是在 centos 系统环境实践,测试内容:集群多台服务器资源监控做后续铺垫。zabbix的简介和自身的特点。在这就不阐述了

 

查询防火墙状态
service iptables status
停止防火墙:
service iptables stop

防火墙配置状态查询:http://www.linuxidc.com/Linux/2012-06/63111.htm

 

环境准备:

1.需要确认防火墙是否关闭

2.Linux下安装zabbix需要有LAMP或者LNMP运行环境

 

一、安装LAMP环境

1.安装zabbix web所需要的依赖包

yum -y install httpd mysql mysql-server php php-mysql postgresql postgresql-server php-postgresql php-pgsql php-devel

2.启动apache服务并查看时候启动成功

启动:/etc/rc.d/init.d/httpd start
检测启动结果:ps aux | grep httpd

3.mysql数据库的配置:
启动:/etc/rc.d/init.d/mysqld start
检查启动结果:netstat -tulnp | grep 3306
修改root密码: mysqladmin -u root password ‘你想设置的密码’
登录:令mysql -u root -p

 

另:附lamp环境快速搭建:https://jingyan.baidu.com/article/3d69c5518e82e3f0cf02d7ea.html

 

一、安装zabbix服务端

官方也提供了安装文档:https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packages

1.安装zabbix-release包

mkdir -p /home/tools  //创建约定目录
wget -q http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-
1.el6.noarch.rpm  //下载zabbix-release包
rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm  //安装
rpm -ql zabbix-release

  

2.安装zabbix

1)保留yum安装的rpm包
 
[[email protected] tools]# sed -i ‘s#keepcache=1#keepcache=0#g‘ /etc/yum.conf
 
[[email protected] tools]# grep keepcache /etc/yum.conf
 
keepcache=0
 
2)开始安装zabbix
 
yum -y install zabbix zabbix-server zabbix-server-mysql #<==ZABBIX SERVER相关
 
yum -y install zabbix-web zabbix-web-mysql #<==Apache、Php Web界面环境
 
yum -y install zabbix-agent #<== ZABBIX客户端
 
yum -y install mysql-server mysql #<==MySQL客户端与服务端

  

3.配置zabbix服务相关

1)配置mysql
 
[[email protected] tools]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
 
[[email protected] tools]# vim /etc/my.cnf
 
在[mysqld](第26行)标签下增加如下三行后保存
 
[mysqld]
 
character-set-server = utf8
init-connect = ‘SET NAMES utf8‘
collation-server = utf8_general_ci
 
[[email protected] tools]# /etc/init.d/mysqld start
 
2)初始化数据库环境
 
创建数据库
 
mysql> create database zabbix character set utf8 collate utf8_bin;
 
Query OK, 1 row affected (0.00 sec)
 
授权数据库
 
mysql> grant all on zabbix.* to [email protected] identified by ‘zabbix‘;
 
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
 
导入表结构
 
[[email protected] tools]# cd /usr/share/doc/zabbix-server-mysql-2.4.6/create/
 
[[email protected] create]#  mysql -u root -p zabbix < schema.sql
 
[[email protected] create]# mysql -u root -p zabbix < images.sql
 
[[email protected] create]#  mysql -u root -p zabbix < data.sql
 
[[email protected] create]# mysqladmin -uroot password 123456
 
3)设置apache时区
 
sed -i ‘s## php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g‘ /etc/httpd/conf.d/zabbix.conf
 
grep Shanghai /etc/httpd/conf.d/zabbix.conf
 
    php_value date.timezone Asia/Shanghai
 
4)更改zabbix server配置
 
[[email protected] ~]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak
 
[[email protected] ~]# sed -i ‘[email protected]# [email protected][email protected]‘ /etc/zabbix/zabbix_server.conf
 
[[email protected] ~]# sed -i ‘[email protected]# [email protected][email protected]‘ /etc/zabbix/zabbix_server.conf
 
-------------------------------------------------
 
vim /etc/zabbix/zabbix_server.conf
 
LogFile=/var/log/zabbix/zabbix_server.log
 
DBHost=localhost
 
DBName=zabbix
 
DBUser=zabbix
 
DBPassword=zabbix
 
5)启动相关服务
 
[[email protected] ~]# /etc/init.d/zabbix-server start
 
Starting Zabbix server:                                    [确定]
 
[[email protected] ~]# /etc/init.d/httpd start
 
正在启动 httpd:                                           [确定]
 
[[email protected] ~]# lsof -i:10051|wc -l
 
[[email protected] ~]# lsof -i:80|wc -l

  

4.zabbix页面安装

访问地址http://172.16.87.223/zabbix/index.php

技术分享图片

技术分享图片

 

 技术分享图片

 

5.安装zabbix客户端

rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-
1.el6.noarch.rpm yum install zabbix-agent -y
 
vim /etc/zabbix/zabbix_agentd.conf  //编辑添加server 服务端IP
  Server=172.16.87.223
 
 [[email protected] tools]# grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
 PidFile=/var/run/zabbix/zabbix_agentd.pid
 LogFile=/var/log/zabbix/zabbix_agentd.log
 LogFileSize=0
 Server=172.16.87.223 (服务端ip)
 ServerActive=127.0.0.1 (服务端ip)
 Hostname=Zabbix server
 Include=/etc/zabbix/zabbix_agentd.d/
 
  
 
/etc/init.d/zabbix-agentd start  //启动zabbix

  

ok 到此zabbix 就搭建完成了! 另 附上zabbix 搭建资料:

http://www.cnblogs.com/liang-wei/p/5848923.html

https://www.cnblogs.com/zzzhfo/p/5820321.html

http://www.osyunwei.com/archives/7891.html
http://www.osyunwei.com/archives/7984.html










以上是关于zabbix分布式监控环境搭建的主要内容,如果未能解决你的问题,请参考以下文章

zabbix监控系统的搭建

zabbix监控环境的搭建

Zabbix监控环境搭建实现7x24监控服务

zabbix监控实战

CentOS7.5下搭建zabbix3.4监控

在centos6.8搭建zabbix3.2