简体   繁体   English

了解MongoDb连接字符串

[英]Understanding MongoDb connection strings

I am working with Mongodb as a database for my asp.net mvc front end site. 我正在使用Mongodb作为我的asp.net mvc前端站点的数据库。 I have MongoDB running on 3 servers, in a replica set, a primary, secondary and an arbiter. 我在3台服务器上运行MongoDB,在副本集中运行,主服务器,辅助服务器和仲裁服务器。 Connecting to this is the 3 front end web servers that performs CRUD operations on the data held in Mongo. 连接到这是3个前端Web服务器,它们对Mongo中保存的数据执行CRUD操作。 I have a number of questions on my setup that I would like clarification on. 我对我的设置有很多疑问,我想澄清一下。

This is my connection string from C# 这是我来自C#的连接字符串

server=myprimary.com:27017,mysecondary.com:27017;replicaset=MySet;safe=true;database=MyDatabase

Is it correct not to include arbiter in this connection string? 在此连接字符串中包含仲裁者是否正确?

When I work with sql server, I set up all my connection strings with integrated security. 当我使用sql server时,我使用集成安全性设置所有连接字符串。 What is the best practise for similar in Mongo connection strings? Mongo连接字符串中类似的最佳做法是什么?

Is it correct not to include arbiter in this connection string? 在此连接字符串中包含仲裁者是否正确?

You don't need to provide the arbiter details, it will be automatically discovered by your app-driver. 您无需提供仲裁者详细信息,您的应用程序驱动程序将自动发现它。

The only thing you can provide in mongoURI is SSL option or username and password for the database that you want to connect. 您可以在mongoURI中唯一提供的是SSL选项或您要连接的数据库的用户名和密码。 But let me remind you, some of the driver don't honor SSL or 'username' and 'password' in mongoURI. 但是让我提醒你,一些司机不尊重SSL或mongoURI中的'用户名'和'密码'。

http://docs.mongodb.org/manual/reference/connection-string/#uri.ssl http://docs.mongodb.org/manual/reference/connection-string/#uri.ssl

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

I'd suggest you consult the documentation . 我建议你查阅文档 It can answer most of your questions. 它可以回答您的大部分问题。 In addition, I see you are using the alternative connection string syntax. 另外,我看到你正在使用备用连接字符串语法。 I'd highly suggest changing to the other connection string format as we will likely be deprecating the version you are using. 我强烈建议更改为其他连接字符串格式,因为我们可能会弃用您正在使用的版本。 The equivalent connection string would be 等效的连接字符串

 mongodb://myprimary.com:27017,mysecondary.com:27017/MyDatabase/?replicaset=MySet.

Finally, you'll find documentation at the previous link regarding authentication. 最后,您将在上一个关于身份验证的链接中找到文档。 We don't have the "integrated security" option, but we do support SSPI integration (also called GSSAPI and kerberose). 我们没有“集成安全性”选项,但我们支持SSPI集成(也称为GSSAPI和kerberose)。 You'll find it referred to as External Authentication in our documentation. 您会在我们的文档中发现它被称为外部身份验证。 The caveat is that the MongoDB server you are running will need to be on a linux box and setup with kerberos. 需要注意的是,您运行的MongoDB服务器需要在Linux机器上并使用kerberos进行设置。 This can be a complicated process when used in conjunction with Active Directory to get the keytab file out. 与Active Directory结合使用以获取keytab文件时,这可能是一个复杂的过程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM