CentOS7.9 Zabbix4.4安装
环境
VMware Workstation Pro
系统:CentOS Linux release 7.9.2009 (Core)
内核:3.10.0-1160.el7.x86_64
内存:1G
CPU:1G
磁盘:20G
IP:192.168.1.73
关闭防火墙
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
setenforce 0
systemctl stop firewalld && systemctl disable firewalld
一、配置阿里源
1.1 安装wget
yum install -y wget
1.2 备份默认更新源
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
1.3 下载阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
1.4 清空缓存
yum clean all
1.5 生成yum缓存
yum makecache
二、安装zabbix
2.1 添加ZABBIX软件仓库
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
2.2 更换zabbix安装源为阿里源
vim /etc/yum.repos.d/zabbix.repo
2.3 生成缓存
yum makecache
2.4 安装
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
三、安装MySQL
3.1 安装MYSQL软件仓库
rpm -Uvh https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
3.2 安装
yum -y install mysql mysql-server mysql-devel
3.3 启动mysql并设置开机启动
systemctl start mysqld && systemctl enable mysqld
3.4 mysql启动后,日志中会有一个默认密码
grep password /var/log/mysqld.log
3.5 登录数据库并重置密码
SET PASSWORD = PASSWORD("Zabbix*2020%");
3.6 创建zabbix数据库
create database zabbix character set utf8 collate utf8_bin;
3.7 授权zabbix用户
grant all privileges on zabbix.* to zabbix@localhost identified by 'Zabbix%2020';
3.8 导入zabbix数据
zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz |mysql -uzabbix -p -Dzabbix
-D 指定zabbix库,如果不指定,会报下面的错误
ERROR 1046 (3D000) at line 1: No database selected
zcat是一个命令行实用程序,用于查看压缩文件的内容。无需对其进行解压缩,它将压缩文件扩展为标准输出。
3.9 登录数据库,查看表是否导入
mysql -uzabbix -p
use zabbix;
show tables;
四、配置zabbix-server
4.1 配置数据库信息
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix%2020
4.2 启动zabbix-server并设置开机启动
systemctl start zabbix-server && systemctl enable zabbix-server
五、配置httpd
5.1 修改时区
vim /etc/httpd/conf.d/zabbix.conf
将# php_value date.timezone Europe/Riga去掉注释,改成下面这行。
php_value date.timezone Asia/Shanghai
5.2 启动httpd,并设置开机启动
systemctl start httpd && systemctl enable httpd
六、web界面配置