一、环境初始化(使用centos7.9)
1、关闭防火墙、selinux
setenforce 0
sed -ri '/^SELINUX=/c SELINUX=disabled' /etc/sysconfig/selinux
sed -ri '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
二、下载zabbix安装源并更换为阿里源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
修改zabbixyum源否则找不到下载包
vi /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=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/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
三、配置mysql yum仓库(zabbix监控后台需要用到mysql)
[mysql]
name=mysql
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/
gpgcheck=0
enabled=1
四、配置centos extras仓库(用来安装高版本PHP,不安装就得手动部署了,因为centos自带php安装源里面的版本比较老)
[centos-extras]
name=centos-extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/x86_64/
enabled=1
gpgcheck=0
五、安装mysql并初始化密码
yum install -y mysql-community-server
systemctl start mysqld
systemctl enable mysqld
新部署的mysql会给一个初始密码
grep 'temporary password' /var/log/mysqld.log
直接拿这个初始密码登录就行了
mysql -uroot -p
登录数据库修改临时密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'HkLjYQt4J8C%';
六、安装zabbix server和agent
yum -y install zabbix-server-mysql zabbix-agent
七、部署centos-release-scl
yum install -y centos-release-scl
附:一个下载php rpm包的网站,我看拿别人劳动的成果来收费属实。。。
https://cbs.centos.org/koji/buildinfo?buildID=27659
八、部署web服务和zabbix数据
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
如果报这个错 需要部署centos-release-scl,已经配置好yum源了直接安装就行
九、初始化zabbix数据库
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'HkLjYQt4J8C%';
grant all privileges on zabbix.* to zabbix@localhost;
导入初始架构和数据,会提示需要输入刚创建的密码
zcat /usr/share/doc/zabbix-server-mysql-5.0.25/create.sql.gz | mysql -uzabbix -p zabbix
为Zabbix server配置数据库
vim /etc/zabbix/zabbix_server.conf
Zabbix前端设置PHP
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
十、启动服务
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
十一、访问
访问服务 ip/zabbix
默认账号密码 Admin zabbix