1. 安装服务端 zabbix-server
1.1 关闭防火墙和selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
1.2 获取zabbix的下载源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
1.3 更换zabbix.repo 源(阿里云)
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
1.4 清空缓存
yum clean all
yum makecache
1.5 下载zabbix服务端
yum install zabbix-server-mysql zabbix-agent -y
1.6 安装工具
# 可以在机器上,使用多个版本的软件,并且不会影响整个系统的依赖环境
yum install centos-release-scl -y
1.7 更改zabbix.repo中zabbix-frontend的数值
vim /etc/yum.repos.d/zabbix.repo
将enabled修改为1
1.8 安装zabbix前端环境,且是安装到scl环境下
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
1.9 安装zabbix所需的数据库(mariadb)
yum install mariadb-server -y
1.10 配置数据库开机启动
systemctl enable --now mariadb
1.11 初始化数据库,并配置密码
mysql_secure_installation
1.12 添加数据库用户
# 进入数据库,创建一个zabbix数据库:
create database zabbix character set utf8 collate utf8_bin;
# 创建一个zabbix用户,密码123
create user zabbix@localhost identified by '123';
# 修改权限
grant all privileges on zabbix.* to zabbix@localhost;
1.13 导入数据库信息
# mysql -u 用户名 -p 数据库名
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p zabbix
1.14 修改zabbix的配置
# 修改zabbix server配置文件,修改数据库密码
# 进入/etc/zabbix/zabbix_server.conf中,修改DBPassword为数据库密码
vim /etc/zabbix/zabbix_server.conf
DBPassword=123
# 查看修改是否成功
grep '^DBPass' /etc/zabbix/zabbix_server.conf
# 修改zabbix PHP的配置文件
#进入/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf中最后一行改成php_value[date.timezone] = Asia/Shanghai
1.15 启动zabbix和php
# 启动zabbix相关服务器
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
1.16 访问zabbix入口
本机ip/zabbix
2. 安装客户端 zabbix-agent
agent2新版本采用golang开发,默认使用10050端口,也会zabbix客户端的端口。
2.1 关闭selinux和防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
2.2 配置时间
yum install ntpdate -y
ntpdate -u ntp.aliyun.com
# 时区统一
mv /etc/localtime{,.back}
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2.3 获取zabbix下载资源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
2.4 更换zabbix.repo源 (阿里云)
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
2.5 安装
yum install zabbix-agent2 -y
2.6 启动
ls -l /usr/sbin/zabbix_agent2
# 启动客户端
systemctl enable --now zabbix-agent2
2.7 修改配置文件
vim /etc/zabbix/zabbix_agent2.conf
# 将Server,ServerActive改为server的IP地址
# 将Hostname改为本机名(使用hostname查询本机名)
# 查看修改后的文件
grep -Ev '^#|^$' /etc/zabbix/zabbix_agent2.conf
2.8 重启
systemctl restart zabbix-agent2
waring
解决zabbix查看乱码问题
zabbix默认检测了服务端本身,但是编码有问题
安装字体
yum -y install wqy-microhei-fonts
复制字体
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf