1.基础环境
1.关闭防火墙
service iptables stop
chkconfig iptables off
#查看selinux
setenforce 0
#禁止selinux
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
#关闭firewalld
systemctl stop firewalld
systemctl disable firewalld
2.安装Zabbix
1.安装zabbix储存库
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
2.安装zabbix-server和zabbix-agent
yum install zabbix-server-mysql zabbix-agent
3.安装zabbix前端组件
yum install -y centos-release-scl
4.安装Zabbix前端软件包
#编辑配置文件
vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
5.创建初始数据库
yum install -y mariadb-server
systemctl restart mariadb
systemctl enable mariadb
systemctl status mariadb
#配置密码
mysqladmin -uroot password 'pwd@123'
mysql -uroot -ppwd@123 -e "use mysql;delete from user where password='';"
mysql -uroot -ppwd@123 -e "use mysql;select user,password,host from user;"
#设置字符集
mysql -uroot -ppwd@123 -e "create database zabbix character set utf8 collate utf8_bin;"
#赋权
mysql -uroot -ppwd@123 -e "create user 'zabbix'@'%' identified by 'zabbix';"
mysql -uroot -ppwd@123 -e "grant all privileges on zabbix.* to 'zabbix'@'%';"
#刷新权限
mysql -uroot -ppwd@123 -e "flush privileges;"
#重启
systemctl restart mariadb
3.初始化配置Zabbix
#导入初始架构和数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
#为Zabbix server配置数据库
sed -i '/DBPassword=/a\DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
#为Zabbix前端配置PHP
sed -i '/php_value\[date.timezone\]/a\php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#完成上述所有配置后设置服务开机自启动
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
#重启
reboot
4.初始化配置zabbix
http://192.168.100.70/zabbix
1.访问登录首页
2.查看各组件
状态为OK后点击右下角Next step
3.配置数据库连接、
完成后点击右下角Next step
4.配置监控信息
完成后点击右下角Next step
5.核实信息
完成后点击右下角Next step
6.配置文件生成位置
完成后点击右下角
7.登录
默认user:Admin
默认password:zabbix
8.设置中文界面
完成后点update即可