Zabbix安装部署文档

Zabbix安装部署文档

https://blog.csdn.net/m0_56055257/article/details/131260948

以上文档可以直接复制内容部署,写的非常好用

在本教程中,展示如何在 CentOS 8 / RHEL 8 / Oracle Linux 8 / Alma Linux 8/ Rocky Linux 8 上安装最新的 Zabbix 6.4 版本。

1、基本配置

1.0关闭防火墙和SELINUX


systemctl stop firewalld

systemctl disable firewalld

setenforce 0

sed -i "s/enforcing/permissive/g" /etc/selinux/config
1.1更换源
#更换源根据自己实际情况

cd /etc/yum.repos.d

rm -rf *

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

yum clean all

yum makecache
二、安装zabbix服务器前端和agent
2.1安装zabbix存储库
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm

dnf clean all
2.2切换PHP的DNF模块版本
dnf module switch-to php:7.4

三、安装和配置数据库

3.1安装MariDB10.6
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup

sudo bash mariadb_repo_setup --mariadb-server-version=10.6

 

dnf -y install mariadb-server && systemctl start mariadb && systemctl enable mariadb

\#安装完成后启动并且设置为开机启动
3.2重置数据库的root密码
  初始化数据库

mariadb-secure-installation

 

Enter current password for root (enter for none): Press Enter

Switch to unix_socket authentication [Y/n] y  

Change the root password? [Y/n] y

New password: <Enter root DB password>       #设置新的密码

Re-enter new password: <Repeat root DB password>

Remove anonymous users? [Y/n]: Y          #删除anonymous账户

Disallow root login remotely? [Y/n]: Y       #是否需要远程登录

Remove test database and access to it? [Y/n]:  Y  #删除test库

Reload privilege tables now? [Y/n]:  Y       #重新加载表

 
3.3创建数据库
mysql -uroot -p

password

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;

mysql> create user zabbix@localhost identified by 'password'; #要设置的zabbix密码

mysql> grant all privileges on zabbix.* to zabbix@localhost;

mysql> set global log_bin_trust_function_creators = 1;

mysql> quit;
3.4导入舒适架构和数据 #提供提示你输入新创建的密码就是上面设置的zabbix密码
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
3.5导入数据库模式后禁用log_bin_trust_function_creators选项
mysql -uroot -p

password            #你的root用户密码

mysql> set global log_bin_trust_function_creators = 0;

mysql> quit;

 

四、zabbix-server配置数据库及前端配置PHP

4.1配置zabbix_server
vim /etc/zabbix/zabbix_server.conf

![img](file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml23428\wps1.jpg)

4.2配置php
vim /etc/php.ini

 

post_max_size = 16M  #由8M改为16M

max_execution_time = 300  #由30改为300

max_input_time = 300  #由60改为300
4.3配置Nginx
vim /etc/nginx/conf.d/zabbix.conf

 listen 8080;

 server_name example.com; 

 

#取消注释并设置保存

 
4.4启动zabbix server和agent进程
systemctl restart zabbix-server zabbix-agent nginx php-fpm

systemctl enable zabbix-server zabbix-agent nginx php-fpm
报错:
1.问题

在安装zabbix5.0时使用的mysql80作为后端数据库配置好了数据之后开启zabbix-server服务的时候出现如下的错误:

![img](file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml23428\wps2.jpg)

![img](file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml23428\wps3.jpg)

就是如下报错:caching_sha2_password

connection to database 'zabbix' failed: [2059] Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.

2.分析

无法加载身份验证插件,身份验证插件找不到,MySql 8.0.32 换了新的身份验证插件(caching_sha2_password);之前的身份验证插件为(mysql_native_password)。zabbix找不到换了之后的验证插件身份。

可以尝试将mysql用户使用的登录密码加密规则 还原成 mysql_native_password。

3.解决

mysql> use mysql;

mysql> select user,host,plugin,authentication_string from user;

![img](file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml23428\wps4.jpg)

mysql>alter user 'zabbix'@'localhost' identified with mysql_native_password by 'Lyg@123.com';

mysql> select user,host,plugin,authentication_string from user;

![img](file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml23428\wps5.jpg)

重启zabbix:

![img](file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml23428\wps6.jpg)

其他报错:

8.0的mysql数据库再第一次登录进去需要输入密码:密码再/var/log/mysqld.log这个文件中。

登录后,第一次需要强制修改密码:命令如下:

MYSQL#> alter user 'root'@'localhost' IDENTIFIED BY '密码';

切记:密码有安全限制,需要有大小写和特殊字符和数字。否则修改失败。

posted @ 2024-04-26 18:17  三思博客  阅读(6)  评论(0编辑  收藏  举报