Centos7.9上部署zabbix5.0TLS
- 一定要做,不然后面会报错
- 关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
-
- 关闭SELinux
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
- 安装zabbix
- 打开zabbix官网
-
- 安装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 server,Web前端,agent
# yum install zabbix-server-mysql zabbix-agent
-
- Install Zabbix frontend
# yum install centos-release-scl
-
- 编辑配置文件 /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.
[zabbix-frontend]
...
enabled=1
...
-
- Install Zabbix frontend packages.
# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
- 安装mysql
(该步骤摘抄于https://blog.csdn.net/weixin_42218986/article/details/125893503)
-
- MySQL安装
- 下载wget命令
yum -y install wget
-
- 在线下载mysql安装包
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
-
- 安装MySQL
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
-
- 安装mysql服务
首先进入cd /etc/yum.repos.d/目录。
cd /etc/yum.repos.d/
-
- 安装MySQL服务(这个过程可能有点慢)
yum -y install mysql-server
-
- linux安装MySQL时报错:
原因:MySQL GPG 密钥已过期导致
解决办法:执行一下命令,解决
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
-
- 启动MySQL
systemctl start mysqld
-
- 修改MySQL临时密码
MySQL安装成功后会有一个临时密码,我们可以使用grep命令查看临时密码先登录进去MySQL,然后修改MySQL密码。
1.2.1 获取MySQL临时密码
grep 'temporary password' /var/log/mysqld.log
使用临时密码先登录
mysql -uroot -p
我的临时密码是:a22XRJ88=+a;
把MySQL的密码校验强度改为低风险
set global validate_password_policy=LOW;
修改MySQL的密码长度
set global validate_password_length=5;
修改MySQL密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'admin';
下面是在CentOS 7上安装MySQL并设置默认密码的步骤
$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): [Press Enter]
Set root password? [Y/n]: Y
New password: [Enter new password]
Re-enter new password: [Repeat password]
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
-
- 允许远程访问
首先要关闭Cenots的防火墙
sudo systemctl disable firewalld
修改MySQL允许任何人连接
1)首先登录MySQL
mysql -uroot -padmin
2)切换到mysql数据
use mysql;
3)查看user表
select Host,User from user;
发现root用户只允许localhost主机登录登录
4)修改为允许任何地址访问
update user set Host='%' where User='root';
5)刷新权限
flush privileges;
12. 将MySQL注册为服务
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add
mysqld chkconfig mysqld on
service mysqld restart(重启)
service mysqld status (状态)
d. 创建初始数据库
Make sure you have database server up and running.
在数据库主机上运行以下代码。
# mysql -uroot -p
passwordmysql> 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> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Disable log_bin_trust_function_creators option after importing database schema.
# mysql -uroot -p
passwordmysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
e. 为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=
password
f. 为Zabbix前端配置PHP
编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf uncomment and set the right timezone for you.
; php_value[date.timezone] = Europe/Riga
g. 启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
启动zabbix-server报错
查看日志