目录
系统和软件介绍
系统:Alma:8.6
软件 : mysql:8.0.28 zabbix:6.0.7
一、系统环境准备:
#安装好系统后,进行更新系统
dnf update
#关闭防火墙和SELINUX
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/SELINUX=enforcing/\SELINUX=disabled/' /etc/selinux/config
二、安装mysql和创建表格:
#创建mysql文件夹(我是在root目录下)
mkdir mysql
cd mysql
#下载软件
wegt:https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.28-1.el8.x86_64.rpm-bundle.tar
#解压软件包
tar -xf mysql-8.0.28-1.el8.x86_64.rpm-bundle.tar
#安装rpm包(务必要按照下面的顺序)
rpm -ivh mysql-community-common-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.28-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.28-1.el8.x86_64.rpm
#如果提示错可以按照官方命令提示进行安装
yum install mysql-community-{server,client,common,libs}-*
#启动并执行开机自启mysql
systemctl start mysqld && systemctl enable mysqld
#查看初始密码
grep 'temporary password' /var/log/mysqld.log
#修改初始密码、这里需要特别注意mysql8.0修改临时密码,如果密码过于简单(如:123456),不符合MySQL8.0版本密码规范,会提示一个报错信息,这些需要修改密码规则。
#报错提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。
mysql> set global validate_password.policy=0;
mysql> set global validate_password.length=1;
#修改密码
mysql> SET PASSWORD = '123456';
#创建初始zabbix数据库
mysql> create database zabbix character set utf8mb4 collate utf8mb4_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;
如果需要mysql远程访问按照下面的命令进行设置mysql8.0访问登录。
mysql>create user 'root'@'%' identified with mysql_native_password by '123456';
#密码为123456
mysql>grant all privileges on *.* to 'root'@'%';
mysql>flush privileges;
三、zabbix软件安装
按照官方文档安装教程步骤如下:
#配置Zabbix存储官方源
rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/8/x86_64/zabbix-release-6.2-1.el8.noarch.rpm
dnf clean all
#安装PHP
dnf module switch-to php:7.4
#安装zabbix
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
#导入初始架构和数据,系统将提示您输入新创建的密码。
zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
#导入数据库模式后在mysql中禁用 log_bin_trust_function_creators
mysql> SET GLOBAL log_bin_trust_function_creators = 0;
mysql> quit;
#为Zabbix server配置数据库(编辑配置文件: /etc/zabbix/zabbix_server.conf)
DBPassword=password
#启动Zabbix server和agent进程,并为它们设置开机自启
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
#连接到新安装的Zabbix前端: http://server_ip_or_name/zabbix
#zabbix客户端初始账号(admin)和密码(zabbix)