修改MONGODB 最大连接数
生活随笔
收集整理的這篇文章主要介紹了
修改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
[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 文件如下:
--------------------------------------------
# .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 ~]$
再查看最大連接數:
{ "current" : 1, "available" : 15999, "totalCreated" : NumberLong(8) }
后來再另一測試服務器中修改mongod 啟動參數:
maxConns=30000 發現在修改成10 時,還報錯,后來為了測試修改成100,沒有出錯。
具體最小值為多少,還沒有測試下去。
總結
以上是生活随笔為你收集整理的修改MONGODB 最大连接数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NOSQL 之 cassadra 安装与
- 下一篇: [MongoDB]db.serverSt