`
leonzhx
  • 浏览: 768180 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

MongoDB DB connections

 
阅读更多

1.   The standard connection uri scheme is not yet supported by all of the drivers. All drivers support an alternative method of specifying connections if this format is not supported.

 

2.   The standard connection string format is as below:

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

 

  a)   mongodb:// is a required prefix to identify that this is a string in the standard connection format.

  b)   username:password@ are optional. If given, the driver will attempt to login to a database after connecting to a database server.

  c)   host1 is the only required part of the URI. It identifies a server address to connect to. As many hosts as necessary may be specified (for connecting to replica pairs/sets).

  d)   :portX is optional and defaults to :27017 if not provided.

  e)   /database is the name of the database to login to and thus is only relevant if the username:password@ syntax is used. If not specified the "admin " database will be used by default.

  f)   ?options are connection options. Note that if database is absent there is still a / required between the last host and the ? introducing the options. 

 

3.  Options are name=value pairs and the pairs are separated either by "& "" or "; ". (These options are not case sensitive):

  a)   replicaSet=name

The driver verifies that the name of the replica set it connects to matches this name. Implies that the hosts given are a seed list, and the driver will attempt to find all members of the set.

  b)   slaveOk=true|false

  true : sending all writes to the primary and distributing reads to the secondaries. false :all writes and reads are sent to primary.

  c)   safe=true|false

true : the driver sends a getLastError command after every update to ensure that the update succeeded.

  d)   w=n

The driver adds { w : n } to the getLastError command. Implies safe=true . Updates will wait for replication to succeed on at least n machines.

  e)   wtimeoutMS=ms

The driver adds { wtimeout : ms } to the getLastError command. Implies safe=true . The timeout for waiting on replication success.

  f)   fsync=true|false

true : the driver adds { fsync : true } to the getLastError command. Implies safe=true . Force MongoDB to flush all pending writes to the data files.

  g)   journal=true|false

true : Sync to journal. Implies safe=true .

  h)   connectTimeoutMS=ms

How long a connection can take to be opened before timing out.

  i)   socketTimeoutMS=ms

How long a send or receive on a socket can take before timing out.

 

4.   The server will use one thread per TCP connection, therefore it is highly recomended that your application use some sort of connection pooling. Luckily, most drivers handle this for you behind the scenes.

分享到:
评论

相关推荐

    MongoDb db.createUser用户权限

    MongoDb数据db.createUser的使用详解. 1、介绍官方文档; 2、实际应用举例。

    MongoDB db.serverStatus()输出内容中文注释

    主要介绍了MongoDB db.serverStatus()输出内容中文注释,本文收集了2个版本的中文注释来讲解,需要的朋友可以参考下

    mongodb-linux-x86_64-4.0.18.tgz

    3、进入 mongodb 目录创建目录 db 和 logs cd /usr/local/mongodb mkdir db mkdir logs 4、进入到 bin 目录下,编辑 mongodb.conf 文件,内容如下: dbpath=/usr/local/mongodb/db logpath=/usr/local/mongodb/...

    DB MongoDB Server x64 V4.1.0 便携版

    DB MongoDB Server x64 V4.1.0 便携版 DB MongoDB Server x64 V4.1.0 Portable

    mongoDb 常用命令

    mongodb php distinct command --- mongoDb 常用命令

    Cosmos DB for MongoDB Developers--2018

    Migrate to MongoDB and understand its strategies Develop a sample application using MongoDB’s client driver Make use of sizing best practices and performance optimization scenarios Optimize ...

    MongoDB与传统DB的异同

    传统的关系数据库一般由数据库(database)、表(table)、记录(record)三个层次概念组成,MongoDB是由数据库(database)、集合(collection)、文档对象(document)三个层次组成。

    MongoDB面试专题

    1.MongoDB 成为最好 NoSQL 数据库的原因是什么? 2.NoSQL 数据库有哪些类型? 3.MySQL 与 MongoDB 之间最基本的差别是什么? 4.你怎么比较 MongoDB、CouchDB 及 CouchBase? 5.分析器在 MongoDB 中的作用是什么? 6.什么...

    基于MongoDB的日志系统Mongodb-Log.zip

    mongodb-log 是一个基于MongoDB的Python日志系统。 MongoDB 的 Capped Collection是一个天生...log.addHandler(MongoHandler.to(db='mongolog', collection='log')) log.debug('Some message') 标签:Mongodb

    Linux安装mongodb客户端

    sudo vim /etc/yum.repos.d/mongodb-org-4.2.repo 写入: [mongodb-org-4.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ gpgcheck=1 enabled=1 gpg...

    MongoDB笔记.docx

    一、MongoDB简介 3 二、MongoDB结构 3 二、MongoDB 数据库关系型(这里并不是值关系型数据库的关系) 3 1、MongoDB一对一关系型 3 2、MongoDB一对多关系型 4 3、MongoDB多对多关系型 4 三、创建数据库(mongodb_test...

    MongoDB应用设计模式

    资源名称:MongoDB应用设计模式内容简介:无论是在构建社交媒体网站,还是在开发一个仅在内部使用的企业应用程序,《MongoDB应用设计模式》展示了MongoDB需要解决的商业问题之间的连接。你将学到如何把MongoDB设计...

    如何安装MongoDB 如何使用MongoDB

    本课程是一套关于MongoDB应用开发的实战性教程,名为《深入浅出MongoDB应用实战开发(基础、开发指南、系统管理、集群及系统架构)》,教程侧重于讲解MongoDB的常用特性及高级特性,从实际开发的角度出发对MongoDB...

    mongodb介质.zip

    mongo-db 4.2.3(安装介质,RPM安装即可用),内含6个RPM包,具体安装方法可查看我的博客,有具体安装方法。 mongodb-org-4.2.3-1.el6.x86_64.rpm mongodb-org-server-4.2.3-1.el6.x86_64.rpm mongodb-org-tools-...

    MongoDb多数据中心

    MongoDB multiple Data center,官方推荐的指导文档。

    基于MongoDb的图书管理系统.rar

    本系统是本人初学MongoDb时所写,代码不是很完美,基本实现图书管理系统的增删改查等基本功能,目前尚有一处缺陷未解决——在查询后只能在控制台看到结果,没有反馈到界面上,有兴趣的朋友可以加以修改,相信这是一...

    mongodb C++编译

    安装:mongod --dbpath=D:\mongodb\db --logpath=D:\mongodb\log\mongo.log= --install 卸载:mongod.exe --remove 最近准备把空闲时间都发在mongodb的研究上,因此将有一系列的文章记录这个过程。 直接从官网...

    MongoDB图形化管理工具 MongoDB Compass

    MongoDB图形化管理工具 MongoDB Compass

    【BAT必备】MongoDB面试题

    【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT必备】MongoDB面试题【BAT...

    五、MongoDB 学习PPT

    MongoDB 学习PPT

Global site tag (gtag.js) - Google Analytics