参考1: http://blog.csdn.net/JIESA/article/details/49891673
错误描述:com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db
connectionsPerHost:每个主机的连接数
threadsAllowedToBlockForConnectionMultiplier:线程队列数,它以上面connectionsPerHost值相乘的结果就是线程队列最大值。如果连接线程排满了队列就会抛出“Out of semaphores to get db”错误。
connectionsPerHost默认是10,threadsAllowedToBlockForConnectionMultiplier默认是5,也就是线程池有50个连接数可供使用。因此只要将这个属性的值加大就可以避免上述错误。
其它属性设置:
maxWaitTime:最大等待连接的线程阻塞时间
connectTimeout:连接超时的毫秒。0是默认和无限
socketTimeout:socket超时。0是默认和无限
autoConnectRetry:这个控制是否在一个连接时,系统会自动重试
java设置方法:
MongoOptions options = new MongoOptions();
options.connectionsPerHost = 100;//链接池数量 默认10 。避免Out of semaphores to get db connection error
options.autoConnectRetry = true;
options.threadsAllowedToBlockForConnectionMultiplier=5;
options.slaveOk = true;
mongo = new Mongo(replicaSetSeeds, options);
参考2:Error using mongodb with java
参考3:【mongodb】Out of semaphores to get db connection
d
d
e
e
w
w
相关推荐
The book covers the necessary features of MongoDB which is needed to get up to speed in knowing about the database. The book covers details on Architecting, Developing and Administering MongoDB. Big ...
MongoDB connection timeout(解决方案).md
You will get an overview of MongoDB and how to play to its strengths, with relevant use cases. After that, you will learn how to query MongoDB effectively and make use of indexes as much as possible. ...
var db = new MongoDB.Mongo().getDB("mydb"); var colls = db.getCollectionNames(); colls.forEach(function(el) { print(el); }); var coll = db.getCollection("testCollection"); coll.drop(); var doc = { ...
MongoDB 是一个流行的开源文档型数据库,以其灵活性和高性能而受到许多开发者的青睐。在MongoDB中,管理用户权限是数据库安全的重要环节。`db.createUser` 方法就是用于创建具有特定权限的用户的。以下是对 `db....
With so many companies opting for MongoDB as their NoSQL database of choice, there's a need for a practical how-to combined with expert advice for getting the most out of the software. Beginning ...
Practical Guide to MongoDB: Architecting, Developing, and Administering MongoDB begins with a short introduction to the basics of NoSQL databases and then introduces readers to MongoDB—the leading ...
3. 配置数据目录:默认情况下,MongoDB的数据存储在`C:\data\db`,如果需要更改,可以在安装过程中设置。 4. 添加环境变量:在系统环境变量中添加`MONGO_HOME`指向MongoDB的安装路径,并在`Path`中添加`%MONGO_HOME%...
8. **安全注意事项**:安装完成后,强烈建议执行`mongo` shell中的`use admin`和`db.runCommand({keyFile:"/path/to/keyfile"})`来启用身份验证,并创建用户账户,以增强安全性。 至此,MongoDB 4.2.21已经在Linux...
本文将深入探讨MongoDB与传统DB的异同,并解析它们各自的特点。 首先,从架构层面来看,MongoDB摒弃了关系数据库中的表格结构,采用了一种更加灵活的数据模型。在传统DB中,数据以表格形式存储,每个表格有预定义的...
mongodb 命令行mongod启动报错 about to fork child process, waiting until server is ready for connections. forked process: 3560 ERROR: child process failed, exited with error number 1 To see additional ...
MongoDB是一种流行的开源文档数据库系统,以其灵活性、可扩展性和高性能而受到开发者的青睐。在Java应用程序中,当处理大量并发请求时,有效地管理数据库连接是至关重要的。这就是MongoDB连接池的作用,它能帮助优化...
《MongoDB:终极指南》是Eelco Plugge、Peter Membrey和Tim Hawkins三位作者共同编写的关于MongoDB数据库的权威指南。本书详细介绍了MongoDB作为一种非关系型(NoSQL)数据库在云计算和桌面计算领域的应用,为读者...
/usr/local/mongodb/mongodb-linux-2.0.7/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/mongodb-linux-2.0.7/logs/mongodb.log --logappend --port=27017 --fork 知识点 6:配置...
MongoDB Basics, from The Definitive Guide to MongoDB, 2E, shows you how a document-oriented database system differs from a relational database, and how to install and get started using it. You'll ...