修改MONGODB 最大连接数

问题: 今天PHP 测试端出错。不知是否为MONGODB的问题。测试最时而正常,刷新多次后就出错。

想到是否为连接次数的原因呢,所以想到把最大连接数修改后,再让他们测试一下,是否问题依旧。


修改方法:

---------------------------------------------------------------------------------------

1.修改系统参数:

vi /etc/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.


ulimit -n 20000
touch /var/lock/subsys/local



2.配置文件:
[root@localhost bin]# cat mongod.cfg
dbpath=/opt/mongodb/db/
logpath=/opt/mongodb/logs/mongod.log
port=28001
logappend=true
fork = true
directoryperdb=true
#auth=true

maxConns=30000


重启服务器,

但现在最大连接数还是默认:
> db.serverStatus().connections;
{ "current" : 1, "available" : 819, "totalCreated" : NumberLong(8) }


查看:ulimit -a 没有看到open files 项。



看来是没起作用。后来在用户的.bash_profile 添加了,再看,问题解决:


[root@localhost bin]# su - mongo
[mongo@localhost ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 30435
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 20000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited


修改的.bash_profile 文件如下:

--------------------------------------------

[mongo@localhost ~]$ cat ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin


MONGO_HOME=/opt/mongodb/mongodb-linux-x86_64-2.5.5; export MONGO_HOME
PATH=$PATH:$MONGO_HOME/bin;
export PATH

stty erase ^h #删除键可用处理

ulimit -n 20000
export PATH
[mongo@localhost ~]$


再查看最大连接数:


> db.serverStatus().connections;

{ "current" : 1, "available" : 15999, "totalCreated" : NumberLong(8) }



后来再另一测试服务器中修改mongod 启动参数:

maxConns=30000 发现在修改成10 时,还报错,后来为了测试修改成100,没有出错。

具体最小值为多少,还没有测试下去。


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值