Linux创建复数个子进程,linux – 如何为在Debian Jessie上运行的守护进程提高文件描述符的最大数量?...

您可以在pgbouncer init脚本的“start”部分中使用“ulimit”:

/etc/init.d/pgbouncer:

[... snip ...]

case "$1" in

start)

# Check if we are still disabled in /etc/default/pgbouncer

[ "${START:-}" = "0" ] && exit 0

log_daemon_msg "Starting PgBouncer" $NAME

test -d $PIDDIR || install -d -o postgres -g postgres -m 2775 $PIDDIR

### set whatever limits you want ###

ulimit -n 20000

$SSD --start --chuid $RUNASUSER --oknodo -- $OPTS 2> /dev/null

log_end_msg $?

;;

[... snip ...]

添加此行后,应在重新启动后发生效果:

这样做,或者你被大喊:

# systemctl daemon-reload

然后:

# /etc/init.d/pgbouncer restart

更新:

我的原始答案显示你可以在init脚本中添加“ulimit”,适用于Debian 8.尽管Deb8是一个systemd发行版,但是pgbouncer的默认安装仍然使用了init脚本.

对于使用systemd完全管理pgbouncer的Centos7,您希望使用systemd.service文件.

首先,在Centos7上pgbouncer的默认服务文件中似乎存在一个错误,你需要将“Type = forked”改为“Type = simple”.

在pgbouncer.service文件中,您还可以在[Service]部分添加“LimitNOFILE = ##”…

/etc/systemd/system/pgbouncer.service

## good practice to include the default service file as it may change with future updates

.include /lib/systemd/system/pgbouncer.service

## change the Type= per this bug

## http://www.postgresql.org/message-id/554A7105.1050002@gmx.net

Type=simple

## Add a service section and set the max number of open files

[Service]

LimitNOFILE=12345

可能值得验证打开文件的最大数量是瓶颈.您可以检查日志,实际上是“太多打开文件”错误消息.在我超过允许打开文件的最大数量的每种情况下,该过程都抱怨…

/var/log/postgresql/pgbouncer.log

ERROR S: login failed: FATAL: could not open relation mapping file (...): Too many open files in system

ERROR S: login failed: FATAL: could not open file (...): Too many open files in system

ERROR S: login failed: FATAL: pipe() failed: Too many open files in system

WARNING sbuf_connect failed: Too many open files in system

/var/log/postgresql/postgresql-9.4-main.log

LOG: out of file descriptors: Too many open files in system; release and retry

PANIC: could not open file (...): Too many open files in system

LOG: server process (...) was terminated by signal 6: Aborted

DETAIL: Failed process was running: END;

LOG: terminating any other active server processes

我们不需要担心pgbench的可用FD,因为如果它们还不够,pgbench将无法运行:

$ulimit -S -n 100

$pgbench -h 192.168.122.69 -p 6432 -U postgres -d booktown -c 200 -t 10000

You need at least 202 open files but you are only allowed to use 100.

Use limit/ulimit to increase the limit before using pgbench.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值