1. Zabbix 简介
1.1 是啥?
Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。
1.2 基础架构?
2. 安装部署
2.1 环境规划
服务 | hadoop102 | hadoop103 | hadoop104 |
---|---|---|---|
zabbix-server | √ | ||
zabbix-agent | √ | √ | √ |
zabbix-web | √ | ||
MySQL | √ |
2.2 准备工作
(1)关闭防火墙
-- 方式1
sudo service iptables stop
sudo chkconfig iptables off
-- 方式2
sudo systemctl stop iptables
sudo systemctl disable iptables
(2) 关闭Selinux
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
(3) 重启服务器
sudo reboot
2.3 安装Yum源
(1) 查看原始zabbix.repo文件
# (1) 查看原始zabbix.repo文件
sudo cat /etc/yum.repos.d/zabbix.repo
内容如下
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/$basearch/
enabled=1
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/4.4/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) 执行以下命令完成全局替换
sudo sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
(3) 查看修改之后的zabbix.repo文件
sudo cat /etc/yum.repos.d/zabbix.repo
内容如下
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/
enabled=1
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/4.4/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.4 安装Zabbix
(1)在hadoop102 上安装
[hadoop@hadoop102 ~]$ sudo yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent
(2)在hadoop103 和 hadoop104上安装
[hadoop@hadoop103 ~]$ sudo yum install -y zabbix-agent
[hadoop@hadoop104 ~]$ sudo yum install -y zabbix-agent
2.5 配置Zabbix
2.5.1 创建Zabbix 数据库
[hadoop@hadoop102 ~]$ mysql -uroot -p1230 -e"create database zabbix character set utf8 collate utf8_bin"
2.5.2 初始化Zabbix 数据库
[hadoop@hadoop102 ~]$ zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz | mysql -uroot -p1230 zabbix
2.5.3 配置Zabbix-Server
(1) 修改zabbix_server.conf配置文件
sudo vim /etc/zabbix/zabbix_server.conf
sudo vim /etc/zabbix/zabbix_server.conf
2.5.4 配置Zabbix-Agent
(1) zabbix_agent文件
[hadoop@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_agentd.conf
[hadoop@hadoop103 ~]$ sudo vim /etc/zabbix/zabbix_agentd.conf
[hadoop@hadoop104 ~]$ sudo vim /etc/zabbix/zabbix_agentd.conf
Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server
2.5.5 配置Zabbix_Web 时区
[hadoop@hadoop102 ~]$ sudo vim /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
2.5.6 启动Zabbix
[hadoop@hadoop102 ~]$ sudo systemctl start zabbix-server zabbix-agent httpd
[hadoop@hadoop102 ~]$ sudo systemctl enable zabbix-server zabbix-agent httpd
[hadoop@hadoop103 ~]$ sudo systemctl start zabbix-agent
[hadoop@hadoop103 ~]$ sudo systemctl enable zabbix-agent
[hadoop@hadoop104 ~]$ sudo systemctl start zabbix-agent
[hadoop@hadoop104 ~]$ sudo systemctl enable zabbix-agent
2.5.7 配置Zabbix_Web的数据库
1)浏览器访问http://hadoop102/zabbix
2)检查配置
3)配置数据库
4)配置zabbix-server
5)再次确认配置
5)点击完成