問題: 今天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,沒有出錯。
具體最小值為多少,還沒有測試下去。