微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

arch-linux – MySQL max_open_files超过1024

在启动MariaDB时我得到[警告]无法将max_open_files的数量增加到1024以上(请求:4607)

$sudo systemctl status MysqLd
● MysqLd.service - MariaDB database server
  Loaded: loaded (/usr/lib/systemd/system/MysqLd.service; enabled)
  Active: activating (start-post) since Tue 2014-08-26 14:12:01 EST; 2s ago
Main PID: 8790 (MysqLd);         : 8791 (MysqLd-post)
  CGroup: /system.slice/MysqLd.service
      ├─8790 /usr/bin/MysqLd --pid-file=/run/MysqLd/MysqLd.pid
      └─control
    ├─8791 /bin/sh /usr/bin/MysqLd-post
    └─8841 sleep 1

Aug 26 14:12:01 acpfg MysqLd[8790]: 140826 14:12:01 [Warning] Could not increase number of max_open_files to more than 1024 (request: 4607)

我尝试使用此文件中的max_open_files解决问题但未成功:

$sudo nano /etc/security/limits.conf 
MysqL           hard    nofile          8192
MysqL           soft    nofile          1200

我甚至重新启动了计算机,但我遇到了同样的问题.

/etc/MysqL/my.cnf看起来像这样:

[MysqL]

# CLIENT #
port                           = 3306
socket                         = /home/u/tmp/MysqL/MysqL.sock

[MysqLd]

# GENERAL #
user                           = MysqL
default-storage-engine         = InnoDB
socket                         = /home/u/tmp/MysqL/MysqL.sock
pid-file                       = /home/u/tmp/MysqL/MysqL.pid

# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP

# SAFETY #
max-allowed-packet             = 16M
max-connect-errors             = 1000000
skip-name-resolve
sql-mode                       = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate-is-Now                 = 1
innodb                         = FORCE
innodb-strict-mode             = 1

# DATA STORAGE #
datadir                        = /home/u/tmp/MysqL/

# BINARY LOGGING #
log-bin                        = /home/u/tmp/MysqL/MysqL-bin
expire-logs-days               = 14
sync-binlog                    = 1

# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 65535
table-deFinition-cache         = 1024
table-open-cache               = 2048

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 128M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 2G

# LOGGING #
log-error                      = /home/u/tmp/MysqL/MysqL-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /home/u/tmp/MysqL/MysqL-slow.log

如何用max_open_files解决问题?

解决方法:

编辑/etc/security/limits.conf并添加以下行

MysqL soft nofile 65535
MysqL hard nofile 65535

然后重新启动

然后编辑/usr/lib/systemd/system/MysqLd.service或/usr/lib/systemd/system/mariadb.service并添加

LimitNOFILE=infinity
LimitMEmlock=infinity

然后重启db服务:

systemctl reload mariadb.service

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐