文章目录
Zabbix概述
Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。
Zabbix 基础架构
Zabbix部署
集群规划
进程 | hadoop102节点 | hadoop103节点 | hadoop104节点 |
---|---|---|---|
zabbix-agent | √ | √ | √ |
zabbix-server | √ | ||
MySQL | √ | ||
zabbix-web | √ |
准备工作
关闭集群
如果集群开启,先关闭集群。因为安装Zabbix前,需要重启虚拟机。
[root@hadoop102 ~]$ cluster.sh stop
关闭防火墙(3台节点,已关闭)
[root@hadoop102 ~]$ sudo service iptables stop
[root@hadoop102 ~]$ sudo chkconfig iptables off
[root@hadoop103 ~]$ sudo service iptables stop
[root@hadoop103 ~]$ sudo chkconfig iptables off
[root@hadoop104 ~]$ sudo service iptables stop
[root@hadoop104 ~]$ sudo chkconfig iptables off
关闭SELinux(hadoop102)
1)修改配置文件/etc/selinux/config
[root@hadoop102 ~]$ sudo vim /etc/selinux/config
修改如下内容
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
2)重启服务器
[root@hadoop102 ~]$ sudo reboot
安装yum仓库
1)安装zabbix的yum仓库
[root@hadoop102 ~]$ sudo rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@hadoop103 ~]$ sudo rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@hadoop104 ~]$ sudo rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
2)安装Software Collections仓库
[root@hadoop102 ~]$ sudo yum install -y centos-release-scl
[root@hadoop103 ~]$ sudo yum install -y centos-release-scl
[root@hadoop104 ~]$ sudo yum install -y centos-release-scl
修改zabbix仓库配置文件
hadoop102、hadoop103、hadoop104三台节点,依次执行如下步骤。
1)修改为阿里云镜像
(1)查看原始zabbix.repo文件
[root@hadoop102 ~]$ sudo cat /etc/yum.repos.d/zabbix.repo
查看内容如下
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
(2)执行以下命令完成全局替换
[root@hadoop102 ~]$ sudo sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
(3)查看修改之后的zabbix.repo文件
[root@hadoop102 ~]$ sudo cat /etc/yum.repos.d/zabbix.repo
查看内容如下
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
2)启用zabbix-web仓库(hadoop102)
打开/etc/yum.repos.d/zabbix.repo文件,做如下修改
cat /etc/yum.repos.d/zabbix.repo
修改内容:[zabbix-frontend]下的enabled=1
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
安装Zabbix
在hadoop102、hadoop103、hadoop104三台节点分别执行以下安装命令
[root@hadoop102 ~]$ sudo yum install -y zabbix-server-mysql zabbix-agent zabbix-web-mysql-scl zabbix-apache-conf-scl
[root@hadoop103 ~]$ sudo yum install -y zabbix-agent
[root@hadoop104 ~]$ sudo yum install -y zabbix-agent
配置Zabbix
创建zabbix数据库
[root@hadoop102 ~]$ mysql -uroot -p000000 -e"create database zabbix character set utf8 collate utf8_bin"
导入Zabbix建表语句
[root@hadoop102 ~]$ zcat /usr/share/doc/zabbix-server-mysql-5.0.9/create.sql.gz | mysql -uroot -p000000 zabbix
会出现如下错误:
gzip: /usr/share/doc/zabbix-server-mysql-5.0.9/create.sql.gz: No such file or directory
则输入如下语句
[root@hadoop102 ~]$ zcat /usr/share/doc/zabbix-server-mysql-5.0.*/create.sql.gz | mysql -uroot -p000000 zabbix
配置Zabbix_Server(hadoop102)
修改zabbix-server配置文件
[root@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_server.conf
DBHost=hadoop102
DBName=zabbix
DBUser=root
DBPassword=000000
配置Zabbix_Agent(三台节点)
修改zabbix-agent配置文件
[root@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_agentd.conf
修改如下内容:
Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server
配置Zabbix_Web时区
修改/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf文件
[root@hadoop102 ~]$ sudo vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
修改如下内容:
[zabbix]
user = apache
group = apache
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
php_value[session.save_handler] = files
php_value[session.save_path] = /var/opt/rh/rh-php72/lib/php/session/
php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai
启动停止Zabbix
启动Zabbix
[root@hadoop102 ~]$ sudo systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@hadoop102 ~]$ sudo systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@hadoop103 ~]$ sudo systemctl start zabbix-agent
[root@hadoop103 ~]$ sudo systemctl enable zabbix-agent
[root@hadoop104 ~]$ sudo systemctl start zabbix-agent
[root@hadoop104 ~]$ sudo systemctl enable zabbix-agent
停止Zabbix
[root@hadoop102 ~]$ sudo systemctl stop zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@hadoop102 ~]$ sudo systemctl disable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@hadoop103 ~]$ sudo systemctl stop zabbix-agent
[root@hadoop103 ~]$ sudo systemctl disable zabbix-agent
[root@hadoop104 ~]$ sudo systemctl stop zabbix-agent
[root@hadoop104 ~]$ sudo systemctl disable zabbix-agent
连接Zabbix_Web数据库
1)浏览器访问http://hadoop102/zabbix/
2)检查配置
3)配置数据库
4)配置zabbix-server
登录Zabbix
1)用户名密码如下
用户名:Admin 密码:zabbix
2)点击User Settings,语言设成中文