首页 > 其他分享 >Zabbix You do not have the SUPER privilege and binary logging is enabled

Zabbix You do not have the SUPER privilege and binary logging is enabled

时间:2023-02-24 19:02:04浏览次数:39  
标签:do systemd logging service binary 03 zabbix mysql localhost

背景:

服务器:Linux Centos 7

服务版本:MySQL 8.0 ,zabbix-proxy 6.0

事件:

在执行 systemctl restart zabbix-proxy.service 报错

Job for zabbix-proxy.service failed because the control process exited with error code.
See "systemctl status zabbix-proxy.service" and "journalctl -xe" for details.

根据提示查看报错信息

# journalctl -xe
--
-- The unit zabbix-proxy.service has entered the 'failed' state with result 'protocol'.
Feb 2 03:40:20 systemd[1]: Failed to start Zabbix Proxy.
-- Subject: Unit zabbix-proxy.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit zabbix-proxy.service has failed.
--
-- The result is failed.
Feb 2 03:40:22 setroubleshoot[192927]: SELinux is preventing mysqld from create access on the sock_file mysqlx.sock. For comp>
Feb 2 03:40:22 setroubleshoot[192927]: SELinux is preventing mysqld from create access on the sock_file mysqlx.sock.

***** Plugin catchall_labels (83.8 confidence) suggests *******************

If you want to allow mysqld to have create access on the mysqlx.sock sock_file
Then you need to change the label on mysqlx.sock
Do
# semanage fcontext -a -t FILE_TYPE 'mysqlx.sock'
where FILE_TYPE is one of the following: mysqld_db_t, mysqld_var_run_t.
Then execute:
restorecon -v 'mysqlx.sock'


***** Plugin catchall (17.1 confidence) suggests **************************

If you believe that mysqld should be allowed create access on the mysqlx.sock sock_fil>
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'mysqld' --raw | audit2allow -M my-mysqld
# semodule -X 300 -i my-mysqld.pp

Feb 2 03:40:22 setroubleshoot[192927]: AnalyzeThread.run(): Set alarm timeout to 10

根据提示执行下面步骤

# ausearch -c 'mysqld' --raw | audit2allow -M my-mysqld
# semodule -X 300 -i my-mysqld.pp

尝试启动zabbix-proxy,启动失败

查看数据库状态,发现数据库也down了

# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat Feb 2 03:40:23 -05; 1min 44s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1619 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
Process: 1602 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 1619 (code=exited, status=2)
Status: "Server startup in progress"

Feb 2 03:40:22 asus2016-vb01 systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Feb 2 03:40:22 asus2016-vb01 systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 2 03:40:22 asus2016-vb01 systemd[1]: Failed to start MySQL Community Server.
Feb 2 03:40:23 asus2016-vb01 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Feb 2 03:40:23 asus2016-vb01 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 9.
Feb 2 03:40:23 asus2016-vb01 systemd[1]: Stopped MySQL Community Server.
Feb 2 03:40:23 asus2016-vb01 systemd[1]: mysql.service: Start request repeated too quickly.
Feb 2 03:40:23 asus2016-vb01 systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 2 03:40:23 asus2016-vb01 systemd[1]: Failed to start MySQL Community Server.

尝试启动mysql,启动失败

看了一下journalctl -xe,发现是selinux的原因,导致数据库启动失败

#查看一下selinux的状态
# getenforce
Enforcing

#临时关闭selinux
# selinux 0

再次尝试启动mysql,成功启动!

尝试启动zabbix-proxy,启动失败

查看zabbix-proxy.log发现报错

query failed: [1419] you do not have the super privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) [create trigger hosts_name_upper_insert。。。

进入mysql修改zabbix权限

# mysql -uroot
mysql> SHOW VARIABLES LIKE 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)

mysql> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)

mysql> SELECT Host,User,Super_priv FROM mysql.user;
+-----------+------------------+------------+
| Host | User | Super_priv |
+-----------+------------------+------------+
| % | zabbix_monitor | N |
| localhost | mysql.infoschema | N |
| localhost | mysql.session | Y |
| localhost | mysql.sys | N |
| localhost | root | Y |
| localhost | zabbix | N |
+-----------+------------------+------------+
6 rows in set (0.00 sec)

mysql> UPDATE mysql.user SET Super_Priv='Y' WHERE user='zabbix_monitor' AND host='%';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT Host,User,Super_priv FROM mysql.user;
+-----------+------------------+------------+
| Host | User | Super_priv |
+-----------+------------------+------------+
| % | zabbix_monitor | Y |
| localhost | mysql.infoschema | N |
| localhost | mysql.session | Y |
| localhost | mysql.sys | N |
| localhost | root | Y |
| localhost | zabbix | N |
+-----------+------------------+------------+
6 rows in set (0.00 sec)

mysql> exit

此时尝试启动zabbix-proxy,启动成功!

!!!重点!!!⬇️

之前做的修改需要恢复到之前的状态

数据库权限恢复

# mysql -uroot
mysql> SET GLOBAL log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)

mysql> UPDATE mysql.user SET Super_Priv='N' WHERE user='zabbix_monitor' AND host='%';
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)

mysql> SELECT Host,User,Super_priv FROM mysql.user;
+-----------+------------------+------------+
| Host | User | Super_priv |
+-----------+------------------+------------+
| % | zabbix_monitor | N |
| localhost | mysql.infoschema | N |
| localhost | mysql.session | Y |
| localhost | mysql.sys | N |
| localhost | root | Y |
| localhost | zabbix | N |
+-----------+------------------+------------+
6 rows in set (0.00 sec)

mysql> exit

selinux状态恢复

# selinux 1


经验总结:

zabbix-proxy启动失败有两个原因:

1.selinux没关,导致服务启动失败。

2.数据库中zabbix没有 SUPER 权限并且启用了二进制日志记录,这个需要细心检查才能发现。

⚠️ 由于安全问题,刚刚做的selinux以SUPER权限在解决完问题后需要恢复原状!!!

标签:do,systemd,logging,service,binary,03,zabbix,mysql,localhost
From: https://blog.51cto.com/u_15932009/6084334

相关文章

  • document.querySelector和querySelectorAll方法
    querySelector和querySelectorAll是W3C提供的 新的查询接口,其主要特点如下:1、querySelector只返回匹配的第一个元素,如果没有匹配项,返回null。 2、querySelectorAll返回......
  • windows 10系统安装
    windows10系统安装步骤一备份个人重要文件到其他地方步骤二复制:ed2k://|file|cn_windows_10_enterprise_x64_dvd_6846957.iso|4162242560|3F657E387CD65FE7BA69DACAA......
  • docker 操作常用命令
    镜像#以tomcat为基础镜像创建一个容器,容器名为my-tomcat#拉取tomcat最新镜像,实际生产中,dockerpull这一步可以省略,dockerrun的时候会自己去拉取。dockerpulltomcat......
  • docker之安装tomcat
    国内Image仓库地址:https://hub.docker.com/search?q=tomcat安装tomcatdockerpulltomcat查看Imagedockerimages运行tomcatdockerrun-d--namemy-tomcat-p9090......
  • 在Windows Server上安装typecho(基于IIS)
    TypechoTypecho是由type和echo两个词合成的,来自于开发团队的头脑风暴。Typecho基于PHP5开发,支持多种数据库,是一款内核强健﹑扩展方便﹑体验友好﹑运行流畅的轻量级开源博客程序......
  • SkeyePlayer RTSP Windows播放器D3D,GDI的几种渲染方式的选择区别 (2)
    SkeyePlayerRTSPwindows播放器支持D3D和GDI两种渲染方式,其中D3D支持格式如下:DISPLAY_FORMAT_YV12DISPLAY_FORMAT_YUY2DISPLAY_FORMAT_UYVYDISPLAY_FORMAT_......
  • windows常用bat分享
    单运行jarjava-jarxxx.jar执行依赖包运行jarlib文件夹和jar同级java-jar-Dloader.path="lib/"xxx.jar设置编码运行jar设置控制台编码为utf-8chcp65001java......
  • Windows防火墙无法更改某些设置。 windows 7
       Win7更改防火墙提示“Windows防火墙无法更改某些设置”怎么办?最近一位Win7用户想要更改防火墙的设置,结果系统跳出提示:“Windows防火墙无法更改某些设置,错误代码......
  • Python中出现IndentationError:unindent does not match any outer indentation level
    【问题】 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError:unindentdoesnotmatchanyo......
  • Odoo14_pdf下载功能实现
    1.安装wkhtmltopdfsudoaptinstallwkhtmltopdf2.安装pip包pip3installpdfkit3.代码实现#-*-coding:utf-8-*-fromodooimporthttpimportpdfkitcl......