5

linux系统与进程文件打开数设置

 2 years ago
source link: https://baorongquan.github.io/2019/08/08/linux%E7%B3%BB%E7%BB%9F%E4%B8%8E%E8%BF%9B%E7%A8%8B%E6%96%87%E4%BB%B6%E6%89%93%E5%BC%80%E6%95%B0%E8%AE%BE%E7%BD%AE/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

linux系统与进程文件打开数设置

发表于 2019-08-08

| 分类于 配置

| 0 Comments

| 浏览 次

场景是这样的:小伙伴在mongodb主备环境把备机停了一段时间后重新启动,mongodb主机在同步数据的过程中出现”too many open files error”, 在网上查到的说可以通过设置linux系统文件打开数来解决(服务器是Ubuntu),
然后开始一顿操作修改 /etc/security/limits.conf 进行设置

vi /etc/security/limits.conf 添加以下内容
* soft nproc 65533
* hard nproc 65533
* soft nofile 65533
* hard nofile 65533
root soft nproc 65533
root hard nproc 65533
root soft nofile 65533
root hard nofile 65533

重启后 ulimit -a 查看系统文件打开数已修改。但是查看mongodb进程限制仍未改变

cat /proc/pid/limits // pid 为mongod的进程id

登陆mongo通过,查看mongo连接数仍未改变。

db.runCommand({serverStatus:1}).connections

最后在stackoverflow 找到答案, 修改/etc/systemd/user.conf 以及 /etc/systemd/system.conf
添加以下内容

DefaultLimitNOFILE=65535

然后reboot重启后再看已生效


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK