集群监控-Zabbix

集群监控:zabbix、cacti(流量与性能监测为主 状态监测较差)、Nagios(服务与性能监测为主 监控监测好 展示差 收集方式 C/S (脚本 预定义))等,zabbix较为主流集合后两者优点,且开源。

zabbix由zabbix-server  zabbix-agent 构成

zabbix定义:是一个基于web界面的提供分布式系统监视以及网络监视功能的企业级开源解决方案

zabbix服务环境:LAMP,防火墙关闭,服务端需要有网,centos7

配置环境

[root@192 ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.202  netmask 255.255.255.0  broadcast 192.168.2.255
[root@192 yum.repos.d]# systemctl stop firewalld;setenforce 0
[root@192 ~]# mount /dev/sr0 /mnt
[root@192 ~]# cd /etc/yum.repo.d/
[root@192 yum.repos.d]# ls
bak               CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  media.repo
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo
#安装需要的包 mysql闭源了这里用mariadb 
[root@192 yum.repos.d]# yum -y install httpd mariadb mariadb-server php php-mysql
#启动
[root@192 yum.repos.d]# systemctl restart httpd;systemctl restart mariadb
#初始化数据库
[root@192 yum.repos.d]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
#第一次回车即可
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
#是否给root设置密码
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
#是否删除默认users
Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
#是否允许远程连接
Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
#是否删除测试数据库
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
#是否刷新权限
Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

#建立zabbix数据库
[root@192 yum.repos.d]# mysql -uroot -p
MariaDB [(none)]> create database zabbix default character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> quit

zabbix服务安装与配置

#安装zabbix 需联网,本地包版本有不匹配的需要联网更新
[root@192 yum.repos.d]# rpm -ivh https://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@192 yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
#zabbix-server-mysql zabbix-web-mysql 服务端, zabbix-agent 客户端, 这里也可以安装客户端包检测本机
[root@192 yum.repos.d]# yum -y install zabbix-server-mysql zabbix-web-mysql
#将zabbix的数据库包信息导入到 "zabbix数据库"
[root@192 yum.repos.d]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@192 zabbix-server-mysql-3.2.11]# zcat create.sql.gz  | mysql -u root -p123456 zabbix
#配置zabbix_server
[root@192 zabbix-server-mysql-3.2.11]# vim /etc/zabbix/zabbix_server.conf
#前面的数字为行号 
81 DBHost=localhost
115 DBPassword=zabbix
#配置时区
[root@192 zabbix-server-mysql-3.2.11]# vim /etc/httpd/conf.d/zabbix.conf 
php_value date.timezone Asia/Shanghai
#重启服务
[root@192 zabbix-server-mysql-3.2.11]# systemctl restart zabbix-server;systemctl restart httpd
--------------
#host:locahost
#zabbix端口:10051
#密码:zabbix
#Name:zabbix
--------------

web界面显示为中文

点小人==>User==>Language==>Chinese==>Update

配置监控(手动配置)

---zabbix-agent配置

#本机监测
安装方法一 在有前两部的情况下 yum安装速度慢
#[root@192 yum.repos.d]# rpm -ivh https://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
#[root@192 yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
[root@192 zabbix-server-mysql-3.2.11]# yum -y install zabbix-agent
#配置
[root@192 zabbix-server-mysql-3.2.11]# vim /etc/zabbix/zabbix_agentd.conf 
#前面的数字为行号
#server填服务机ip 
95 Server=192.168.2.202
136 ServerActive=192.168.2.202
#host填本机ip
147 Hostname=192.168.2.202
[root@192 zabbix-server-mysql-3.2.11]# systemctl restart zabbix-agent

#zabbix-agent监测
[root@localhost ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.203  netmask 255.255.255.0  broadcast 192.168.2.255
##安装导入导出工具 在xshell中用 rpm安装
[root@localhost ~]# yum -y install lrzsz
[root@localhost ~]# ls
anaconda-ks.cfg  zabbix-agent-3.2.11-1.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh zabbix-agent-3.2.11-1.el7.x86_64.rpm 
95 Server=192.168.2.202
136 ServerActive=192.168.2.202
147 Hostname=192.168.2.203
[root@192 zabbix-server-mysql-3.2.11]# systemctl restart zabbix-agent
[root@localhost ~]# systemctl stop firewalld;setenforce 0

------web端配置

配置==>主机==>删除默认主机==>创建主机

主机==>填主机名、可见名、群组(可用已有的也可新建)==>ip

模板==>选择==>添加 http、linux os、ICMP ping==>添加==>添加

<

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值