如何修复MySQL错误日志中的“mbind:Operation not permitted”错误

102

我有一个MySQL错误日志的问题,其中大部分是“mbind: Operation not permitted”行(如下所示)。这是为什么呢?我该如何解决?

让我困扰的是“大部分”这个词。正如您可以在下面看到的,不是所有的行都是“mbind: Operation not permitted”。 我怀疑MySQL查询错误应该代替那一行,但由于某种原因它们无法写入文件。

MySQL本身是一个Docker容器,其中日志文件通过以下方式成为卷:

volumes:
- ./mysql/log:/var/log/mysql

有趣的是:

  • “docker logs mysql_container”没有显示任何内容...
  • 位于相同卷文件夹中的 slow.log 完全正常,其中包含真实的慢日志行,没有出现“mbind: Operation not permitted”的情况!
  • 同样,general.log 也是如此——这里也没有问题

有什么想法吗?提前感谢。

2019-04-07T12:56:22.478504Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2019-04-07T12:56:22.478533Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2019-04-07T12:56:22.478605Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.15) starting as process 1
2019-04-07T12:56:22.480115Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2019-04-07T12:56:22.480122Z 0 [Warning] [MY-013244] [Server] --collation-server: 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
[same line goes forever]

顺便说一下,MySQL启动并运行良好,没有问题。只是这个错误日志一直困扰着我,阻止我看到实际的错误。

2个回答

182

4
一般而言,当一个进程被允许改变自己的优先级或"niceness"(操作系统中一种影响调度策略的参数),它可以将自己设置为超高优先级,并比其他所有进程更频繁地调度到 CPU 上。因此,如果选择了不合适的优先级/ niceness 参数,该进程可能会使主机上的其他进程饿死。但是,迄今为止我在 MySQL 中从未遇到过这样的问题。也许是因为我没有使用需要这个功能的特性吗? - Laurent Gosselin
5
如果您使用Docker Stack/Swarm,cap_add/security_opt不被支持(https://github.com/moby/moby/issues/25885)。 - tsauerwein
4
为什么会发生这种情况?我以前在使用MySQL时没有问题,而且解决方案似乎并不安全。Docker MySQL镜像v8有特定的问题吗?将来是否会有更好的解决方案,而这只是一个快速修复? - Rodrigo
6
如果没有启用CAP_SYS_NICE,MySQL将无法处理线程优先级,我猜你将失去MySQL 8引入的一个新功能(我相信是资源组https://dev.mysql.com/doc/refman/8.0/en/resource-groups.html)。MySQL应该在启动时向我们发出*一次*警告。但与其如此(不确定现在是否仍然是这种情况),它会用这个消息填满磁盘。 - Laurent Gosselin
2
所以我正在使用MySQL 8.0,但错误消息仍然存在...这个解决方案只适用于5.7吗?有人知道是否还有其他的CAP可以解决这个问题吗? - Davi S Evangelista
显示剩余5条评论

14

在docker-compose.yml文件中添加security_opt选项有助于解决这个问题:

database:
  image: mysql:latest
  container_name: mysql_0
  ports:
    - "3306:3306"
  security_opt:
    - seccomp:unconfined

11
我会尽量避免完全禁用安全配置文件,并添加最少的额外权限。 - Laurent Gosselin
7
加入最小额外权利是什么意思?@LaurentGosselin - Joseph Astrahan
@JosephAstrahan 我想他是指他自己在2分钟前发布的上面的回答 - chrisly

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接