加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – 为Postgres获取太多打开文件错误

发布时间:2020-12-13 16:22:16 所属栏目:百科 来源:网络整理
导读:在JAVA应用程序的Ubuntu 14.04服务器上,我们收到Postgres的太多Open文件错误(使用 Postgresql 9.5). 我们在/etc/security/limits.conf中设置了以下内容 * soft nofile 16384* hard nofile 16384root soft nofile 16384root hard nofile 16384postgres soft n
在JAVA应用程序的Ubuntu 14.04服务器上,我们收到Postgres的太多Open文件错误(使用 Postgresql 9.5).

我们在/etc/security/limits.conf中设置了以下内容

* soft nofile 16384
* hard nofile 16384
root soft nofile 16384
root hard  nofile 16384
postgres soft nofile 16384
postgres hard  nofile 16384

还在/etc/sysctl.conf中设置以下内容

kern.maxfiles=20480
kern.maxfilesperproc=18000

另请在以Postgres用户身份运行时查看以下结果:

-> ulimit -Hn
16384

-> ulimit -Sn
16384


-> cat /proc/sys/fs/file-max
100268

重新启动服务器并检查postgres的ulimit为100268.但是在postgres下检查打开文件的限制时,它仍然是1024和4096

# cat /proc/1072/limits

Max open files            1024                 4096                 files

当我们重新启动postgres服务时,它已改为

#cat /proc/1759/limits
Max open files            16384                16384                files

但它似乎没有受到影响,因为我们仍然得到“太多的打开文件”错误.

在Server的目录/etc/security/limits.d/和/etc/security/conf.d/中也是空的.所以任何人都可以指导我.

@dilyin感谢您的更新.

我们在PostgreSQL的启动脚本中更新了ulimit值,但问题仍然存在.

最后,我们通过将max_files_per_process从默认值1000减少到200来修复此问题.此参数位于postgresql.conf文件中,这将设置允许每个服务器子进程允许的最大同时打开文件数.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读