天天看點

MariaDB [Warning] Could not increase number of max_open_files to more than 1024

啟動mariadb,檢視mariadb狀态資訊時:

systemctl start mariadb
systemctl -l status mariadb
           

報錯

MariaDB [Warning] Could not increase number of max_open_files to more than 1024

[Warning] Could not increase number of max_open_files to more than 1024 (request: 8131)

[Warning] Changed limits: max_open_files: 1024 max_connections: 594 (was 4096) table_cache: 200 (was 2000)

出現警告資訊:提示最大打開檔案數不能超過1024,但依然能夠啟動mariaDB。

解決方法

  • cat /usr/lib/systemd/system/mariadb.service 檢視資訊
14 # For example, if you want to increase mysql's open-files-limit to 10000,
 15 # you need to increase systemd's LimitNOFILE setting, so create a file named
 16 # "/etc/systemd/system/mariadb.service.d/limits.conf" containing:
 17 #       [Service]
 18 #       LimitNOFILE=10000
           
  • 根據前面的資訊
mkdir /etc/systemd/system/mariadb.service.d
vim /etc/systemd/system/mariadb.service.d/limits.conf   '  //添加  '
[Service]
LimitNOFILE=10000     '  //根據前面的warning資訊,數值隻需要大于8131即可,還可以改為infinity '
           
  • 修改完之後,重新加載配置
systemctl --system-daemon-reload
           

已解決

如圖:

MariaDB [Warning] Could not increase number of max_open_files to more than 1024

拓展

ulimit -n       檢視目前程序的max_open_files
cat /proc/sys/fs/file-max       檢視系統最大檔案數
/etc/security/limits.conf是一個很重要的檔案
           

繼續閱讀