我想我有一个旧的个人资料(复制如下)。
我不知道去哪儿才能找到正确的个人资料。
是否有标准 apparmor 配置文件的权威来源 - 或者这会在 mysql 源的某个地方?
是否有一种标准的方法来更新配置文件,或者我必须手动弄清楚它应该是什么?
例如
sudo apparmor get-updated-profile-for mysql
MySQL 5.7/Ubuntu 16.04
现在:
/etc/apparmor.d$ cat usr.sbin.mysqld
# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>
/usr/sbin/mysqld {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/mysql>
#include <abstractions/winbind>
capability dac_override,
capability sys_resource,
capability setgid,
capability setuid,
network tcp,
/etc/hosts.allow r,
/etc/hosts.deny r,
/etc/mysql/*.pem r,
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/*.cnf r,
/usr/lib/mysql/plugin/ r,
/usr/lib/mysql/plugin/*.so* mr,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
/var/run/mysqld/mysqld.pid rw,
/var/run/mysqld/mysqld.sock w,
/var/run/mysqld/mysqld.sock.lock rw,
/run/mysqld/mysqld.pid rw,
/run/mysqld/mysqld.sock w,
/run/mysqld/mysqld.sock.lock rw,
/sys/devices/system/cpu/ r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
答案1
好的 - 因此启动一个干净的 ubuntu 服务器并安装 mysql 似乎是获取“正确”配置文件的合理方法。目前如下:
# vim:syntax=apparmor
# Last Modified: Tue Feb 09 15:28:30 2016
#include <tunables/global>
/usr/sbin/mysqld {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/mysql>
#include <abstractions/winbind>
# Allow system resource access
/sys/devices/system/cpu/ r,
capability sys_resource,
capability dac_override,
capability setuid,
capability setgid,
# Allow network access
network tcp,
/etc/hosts.allow r,
/etc/hosts.deny r,
# Allow config access
/etc/mysql/** r,
# Allow pid, socket, socket lock file access
/var/run/mysqld/mysqld.pid rw,
/var/run/mysqld/mysqld.sock rw,
/var/run/mysqld/mysqld.sock.lock rw,
/run/mysqld/mysqld.pid rw,
/run/mysqld/mysqld.sock rw,
/run/mysqld/mysqld.sock.lock rw,
# Allow execution of server binary
/usr/sbin/mysqld mr,
/usr/sbin/mysqld-debug mr,
# Allow plugin access
/usr/lib/mysql/plugin/ r,
/usr/lib/mysql/plugin/*.so* mr,
# Allow error msg and charset access
/usr/share/mysql/ r,
/usr/share/mysql/** r,
# Allow data dir access
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
# Allow data files dir access
/var/lib/mysql-files/ r,
/var/lib/mysql-files/** rwk,
# Allow keyring dir access
/var/lib/mysql-keyring/ r,
/var/lib/mysql-keyring/** rwk,
# Allow log file access
/var/log/mysql.err rw,
/var/log/mysql.log rw,
/var/log/mysql/ r,
/var/log/mysql/** rw,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
答案2
我错误 mysql 无法创建 ip 套接字,错误号为 13。Apparmor 设置为 DENY。在尝试了无数次 apparmor 配置后,我只能通过将 apparmor 设置为 COMPLAIN 来使其再次运行。我使用 apparmor-utils 中的 aa-complain。此后,Mysql 运行良好。
这可能不是最好的解决方案,特别是对于生产服务器而言。
我仅将它用于笔记本电脑上的本地主机实例。