centos7
zabbix5 与musql8.42安装
先替换yum源
第一个yum源
vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
安装 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
安装Zabbix服务器,前端,代理
# yum install zabbix-server-mysql zabbix-agent
安装 Zabbix 前端
启用 Red Hat 软件集合
# yum install centos-release-scl
编辑文件 /etc/yum.repos.d/zabbix.repo 并启用 zabbix-frontend 存储库。[zabbix-frontend]
...
enabled=1
...
替换第二个yum源
vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
[centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
替换第三个yum源
vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
[centos-sclo-sclo]
name=CentOS-$releasever - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
清理缓存
yum clean all
导入新的密钥
vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
[centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
rpm --import https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo
安装 Zabbix 前端包。
# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
下载数据库mysql8.42 yum源
wget https://dev.mysql.com/get/mysql84-community-release-el7-1.noarch.rpm
安装yum源
yum install mysql84-community-release-el7-1.noarch.rpm
安装数据库
yum install mysql-community-server
启动mysql
systemctl restart mysqld
在mysqld设置mysql_native_password=ON
systemctl restart mysqld
查询mysql初始密码 (:后的是初始密码)
grep 'temporary password' /var/log/mysqld.log
登录mysql
mysql -uroot -p 密码如上
修改mysql密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
创建初始数据库
在数据库主机上运行以下命令。
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root_password';
mysql> quit;
在 Zabbix 服务器主机上导入初始模式和数据。系统将提示您输入新创建的密码。
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
导入数据库模式后禁用 log_bin_trust_function_creators 选项
# mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
为 Zabbix 服务器配置数据库
编辑文件 /etc/zabbix/zabbix_server.conf
DBPassword=password
为 Zabbix 前端配置 PHP
编辑文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 取消注释并为您设置正确的时区。
php_value[date.timezone] = Asia/Shanghai
关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
vim /etc/sysconfig/selinux
-
将SELinux=enforcing改为SELinux=disabled
启动Zabbix服务器和代理进程
启动 Zabbix 服务器和代理进程并使其在系统启动时启动。
# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm