zabbix笔记以及错误总结

星期六一 2024-3-26 188 3/26

操作步骤

# 关闭防火墙
systemctl stop firewalld
# 关闭SELinux  打开后如下图,将此处改为disabled
vi /etc/selinux/config
# 重启服务器
reboot

zabbix笔记以及错误总结

# 安装 zabbix 的软件仓库配置包  (server和agent)
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# 安装 Software Collections 仓库 (server和agent)
yum install -y centos-release-scl
# 将仓库改为阿里云的仓库 (server和agent)
sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
# 打开/etc/yum.repos.d/zabbix.repo 文件,启用 zabbix-web 仓库  (server和agent)
vi /etc/yum.repos.d/zabbix.repo

zabbix笔记以及错误总结

# 安装zabbix
# server
yum install -y zabbix-server-mysql zabbix-agent zabbix-web-mysql-scl zabbix-apache-conf-scl
# agent
yum install -y zabbix-agent
# 创建 zabbix 数据库  (server)
mysql -uroot -p123456 -e"create database zabbix character set utf8 collate utf8_bin"
# 导入 Zabbix 建表语句  <注意zabbix-server-mysql的路径问题,以及记得更改mysql密码>(server)
zcat /usr/share/doc/zabbix-server-mysql-5.0.41/create.sql.gz | mysql -uroot -p123456 zabbix
# 配置 Zabbix_Server (server)
vi /etc/zabbix/zabbix_server.conf

DBHost=192.168.138.132
DBName=zabbix
DBUser=root
DBPassword=123456

# 配置 Zabbix_Agent (server和agent)
vi /etc/zabbix/zabbix_agentd.conf

Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server

# 配置 Zabbix_Web 时区
# 修改/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 文件
# 最后一行进行修改,如下面代码块中的所示
[zabbix]
user = apache
group = apache

listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/opt/rh/rh-php72/lib/php/session/

php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai
# 启动zabbix (server)
systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm
# 开机自启
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
# 启动zabbix (agent)
systemctl start zabbix-agent
# 开机自启
systemctl enable zabbix-agent

# 停止zabbix(server)
systemctl stop zabbix-server zabbix-agent httpd rh-php72-php-fpm
# 禁止开机自启
systemctl disable zabbix-server zabbix-agent httpd rh-php72-php-fpm
# 停止zabbix(agent)
systemctl stop zabbix-agent
# 禁止开机自启zabbix
systemctl disable zabbix-agent

错误记录

1、错误描述:

[root@localhost ~]# systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm
Job for zabbix-server.service failed because a configured resource limit was exceeded. See "systemctl status zabbix-server.service" and "journalctl -xe" for details.

查看systemctl status zabbix-server.service以及journalctl -xe:

[root@localhost zabbix]# systemctl status zabbix-server.service
● zabbix-server.service - Zabbix Server
   Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: resources) since Wed 2024-02-21 22:47:08 PST; 4s ago
  Process: 16500 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=1/FAILURE)
  Process: 21687 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
 Main PID: 16495 (code=exited, status=1/FAILURE)

Feb 21 22:47:08 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
Feb 21 22:47:08 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
Feb 21 22:47:08 localhost.localdomain systemd[1]: zabbix-server.service failed.
[root@localhost zabbix]# journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has begun starting up.
Feb 21 22:47:08 localhost.localdomain systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start.
Feb 21 22:47:08 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
-- Subject: Unit zabbix-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has failed.
--
-- The result is failed.
Feb 21 22:47:08 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
Feb 21 22:47:08 localhost.localdomain systemd[1]: zabbix-server.service failed.
Feb 21 22:47:18 localhost.localdomain systemd[1]: zabbix-server.service holdoff time over, scheduling restart.
Feb 21 22:47:18 localhost.localdomain systemd[1]: Stopped Zabbix Server.
-- Subject: Unit zabbix-server.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has finished shutting down.
Feb 21 22:47:18 localhost.localdomain systemd[1]: Starting Zabbix Server...
-- Subject: Unit zabbix-server.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has begun starting up.
Feb 21 22:47:20 localhost.localdomain systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start.
Feb 21 22:47:20 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
-- Subject: Unit zabbix-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has failed.
--
-- The result is failed.
Feb 21 22:47:20 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
Feb 21 22:47:20 localhost.localdomain systemd[1]: zabbix-server.service failed.

发现Feb 21 22:47:08 localhost.localdomain systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start.,证明是pid文件出现问题,但是zabbiz-agent没有出现问题,所以,查看/var/log/zabbix/下的zabbix_server.log,此时发现问题所在:

zabbix笔记以及错误总结

分析:

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

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

解决方式:

进入mysql

mysql> use mysql;

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

# 我的zabbix的用户是root
mysql>alter user 'root'@'localhost' identified with mysql_native_password by '123456'; 

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

之后重启zabbix,启动成功!!

网上的出现类似的错误的时候还要检查一下SELinux是否关闭

- THE END -

星期六一

6月30日17:42

最后修改:2024年6月30日
1

非特殊说明,本博所有文章均为博主原创。

共有 1 条评论

  1. zabbix可以结合granfa一起使用,因为zabbix的图形界面不是很友好,但是和granfa整合到一起之后就会十分方便