8

我在 Macos 10.15.5 和 mariadb 10.4.13 上运行。因为我做了“brew upgrade”我有这个错误: Out of resources when opening file './pluto/_connection.MYD' (Errcode: 24 "Too many open files")

我尝试修改此文件 /usr/local/etc/my.cnf 以添加此行open_files_limit = 60000,但它不起作用,open_files_limit 变量仍然在值 256 上被阻止。

我试过这条线 : sudo ulimit -n 1024,但每次我重新启动值都会返回 256

你有什么帮助让我帮我解决我的问题吗?

4

5 回答 5

15

您是否尝试过寻找其他方法来修改 MacOS Catalina 上的打开文件限制?快速搜索将我带到这里,它建议在系统运行时为系统修改以下内容:

sudo launchctl limit maxfiles <soft limit> <hard limit>

这个站点这个超级用户问题 建议修改/Library/LaunchDaemons/limit.maxfiles.plist以永久增加它。

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"  
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">  
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string><your soft limit here></string>
      <string><your hard limit here></string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist> 

然后,通过更改权限并验证更改来完成。

sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
launchctl limit maxfiles
于 2020-07-07T21:36:08.603 回答
6
  • MacOS Catalina 10.15.x
  • Mariadb 使用自制软件安装

导入数据库mysql < foo.sql失败:[ERROR] Error in accept: Too many open files

同意楼上的帖子。这看起来像一个假阴性。这对我有用:

brew services stop mariadb

并确保您没有运行任何 mysql 进程:ps aux | grep mysql.

mkdir /usr/local/var/run/mysqld

编辑 Mariadb 配置文件/usr/local/etc/my.cnf并告诉它使用这个目录。

[client-server]
socket = /usr/local/var/run/mysqld/mysql.sock

[mysqld_safe]
pid-file = /usr/local/var/run/mysqld/mysqld.pid

严格来说你只需要定义 pid 文件,虽然我个人喜欢将 pid 和 socket 文件都存储在/usr/local/var/run- 结构中。我对从 Homebrew 安装的 PHP (/usr/local/var/run/php) 执行相同的操作。

启动你的数据库服务器,你就完成了。

brew services start mariadb
于 2020-11-03T13:13:15.433 回答
2

从 10.15.5 升级到 10.15.6 后,我在 MacOS 上解决了同样的问题,mariadb 通过自制软件安装,版本 10.5.5。

原来问题不是打开文件限制,而是缺少创建 PID 文件的权限。

为了修复它,我创建~/.my.cnf了包含以下内容的文件。

[mysqld_safe]
pid-file    = /var/run/mysqld/mysqld.pid

并使用以下命令创建mysqld.pid文件(取自此服务器故障问题

mkdir /var/run/mysqld
touch /var/run/mysqld/mysqld.pid
chown -R mysql:mysql /var/run/mysqld

这解决了问题。MySQL/MariaDB 不再抱怨打开太多文件了。

我还需要杀死所有正在运行的 mysql 进程(让 PID 运行ps aux | grep mysql然后kill {proces_number}. 但也许你不需要这一步。

于 2020-09-01T14:16:22.110 回答
1

我能够通过遵循此线程中指出的建议来增加系统限制来解决此问题:https ://discourse.brew.sh/t/mariadb-too-many-open-files/8110并在 GIST 中进行了概述这里:https ://gist.github.com/tombigel/d503800a282fcadbee14b537735d202c

于 2020-07-03T20:15:58.627 回答
0

我在 macOS 10.15.7 上使用通过 Macports 安装的 mariadb-10.2 时遇到了同样的问题。检查 open_files_limit 显示它已因未知原因恢复为 256。我尝试了此问题和其他地方描述的许多方法;包括确保ulimit足够(20000)和launchctl limit maxfiles足够(20000和200000),并且在my.cnf中有合理的open_file_limit设置(3000)这些参数保持在这些值并且在mariadb时不会改变恢复为 256,但仍保持在预期值。

不是根本原因的解决方案,但解决方法是重新启动 mariadb。之后,mariadb 的 open_files_limit 被重置为 20000 的 ulimit。请注意,它没有设置为 my.cnf 中的 3000 值,而是设置为 20000 值。这解决了一段时间的问题。

另请注意,对于从 MacPorts 安装的 mariadb,重启方式由以下两个命令给出:

  1. sudo 端口卸载 mariadb-10.2-server
  2. sudo 端口加载 mariadb-10.2-server

即使控制台输出表明它已重新启动,仅执行加载也是行不通的。它可能会重新启动,但我已经证明 open_files_limit 重置的唯一方法是首先进行卸载。

于 2020-11-22T16:32:46.067 回答