日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

修改MONGODB 最大连接数

發布時間:2024/4/15 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 修改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,沒有出錯。

具體最小值為多少,還沒有測試下去。


總結

以上是生活随笔為你收集整理的修改MONGODB 最大连接数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。