简体   繁体   English

MySQL SELinux冲突Fedora 19

[英]MySQL SELinux conflict Fedora 19

I've successfully installed MySQL 5.6 on my F19. 我已经在F19上成功安装了MySQL 5.6。 Although the installation was successful, I'm unable to start the mysql service. 尽管安装成功,但是我无法启动mysql服务。

When I ran 我跑的时候

service mysql start

It returns the following error: 它返回以下错误:

Starting MySQL..The server quit without updating PID file (/var/lib/mysql/sandboxlabs.pid). 

I disabled SELinux (permissive mode), and the service started smoothly. 我禁用了SELinux(许可模式),该服务顺利启动。 But I did some research about disabling SELinux, and found that disabling SELinux is a bad idea. 但是我做了一些关于禁用SELinux的研究,发现禁用SELinux是一个坏主意。 So, is there any way to add custom MySQL policy? 那么,有什么方法可以添加自定义MySQL策略? Or should I leave the SELinux to permissive mode? 还是应该让SELinux进入许可模式?

The full answer depends on your server configuration and how you're using MySQL. 完整的答案取决于您的服务器配置以及MySQL的使用方式。 However, it's completely feasible to modify your SELinux policy to allow MySQL to run. 但是,修改SELinux策略以允许MySQL运行是完全可行的。 In most cases, this sort of operation can be performed with a small number of shell commands. 在大多数情况下,可以使用少量的Shell命令来执行此类操作。

Start by looking at /var/log/audit/audit.log. 首先查看/var/log/audit/audit.log。 You can use audit2allow to generate a permission-granting policy around the log messages themselves. 您可以使用audit2allow围绕日志消息本身生成权限授予策略。 On Fedora 19, this utility is in the policycoreutils yum package. 在Fedora 19上,此实用程序位于policycoreutils yum软件包中。

The command 命令

    # grep mysql /var/log/audit/audit.log | audit2allow

...will output the policy code that would need to be compiled in order to allow the mysql operations that were prevented and logged in audit.log. ...将输出需要编译的策略代码,以允许阻止并登录到audit.log的mysql操作。 You can review this output to determine whether you'd like to incorporate such permissions into your system's policy. 您可以查看此输出,以确定是否要将此类权限合并到系统的策略中。 It can be a bit esoteric but you can usually make out a few file permissions that mysql would need in order to run. 这可能有点深奥,但通常可以确定mysql运行所需的一些文件权限。

To enable these changes, you need to create the policy module as a compiled module: 要启用这些更改,您需要将策略模块创建为已编译模块:

    # grep mysql /var/log/audit/audit.log | audit2allow -M mysql

...will output the saved plaintext code to mysql.te and the compiled policy code to mysql.pp. ...将保存的明文代码输出到mysql.te,将编译后的策略代码输出到mysql.pp。 You can then use the semodule tool to import this into your system's policy. 然后,您可以使用semodule工具将其导入系统的策略中。

    # semodule -i mysql.pp

Once you've done this, try starting mysqld again. 完成此操作后,尝试再次启动mysqld。 You might need to repeat this process a few times since mysqld might still falter on some new access permission that wasn't logged in previous runs. 您可能需要重复此过程几次,因为mysqld可能仍然无法获得以前运行时未记录的某些新访问权限。 This is because the server daemon encounters these permission checks sequentially and if it gets tripped on one, it won't encounter the others until you allow access to the initial ones. 这是因为服务器守护程序顺序地遇到这些权限检查,并且如果它在一个守护程序上被触发,则在您允许访问初始守护程序之前,它不会遇到其他权限。 Have patience -- sometimes you will need to create mysql1.pp mysql2.pp mysql3.pp ... and so on. 有耐心-有时您将需要创建mysql1.pp mysql2.pp mysql3.pp ...等。

If you're really interested in combining these into a unified policy, you can take the .te files and "glue" these together to create a unified .te file. 如果您真的有兴趣将它们组合到统一策略中,则可以将.te文件并将其“粘合”在一起以创建统一的.te文件。 Compiling this file is only slightly more work -- you need the Makefile from /usr/share/selinux/devel/Makefile in order to convert this into a .pp file. 编译该文件仅需要更多的工作-您需要/usr/share/selinux/devel/Makefile中的/usr/share/selinux/devel/Makefile才能将其转换为.pp文件。

For more information: 欲获得更多信息:

If you're a more graphical type, there's also a great article by RedHat magazine on compiling policy here . 如果你是一个更图形化的类型,这里还有上编制的政策有很大的文章由红帽杂志在这里 There's also a great blog article which takes you through the creation of a policy here . 还有一篇很棒的博客文章,可以在这里指导您创建策略。 Note the emphasis on using /usr/share/selinux/devel/Makefile to compile your own .te, .fc, and .if files (selinux source written in M4). 请注意,强调使用/ usr / share / selinux / devel / Makefile来编译自己的.te,.fc和.if文件(用M4编写的selinux源代码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM