Connecting to MongoDB
Principle
The connect dialog can be used to create a MongoClient instance connected to a MongoDB single instance, replica set, or sharded cluster.
Several MongoClient instances can be connected and managed by UMongo.
Options
The following options are supported:
- URI: the MongoDB URI like 'mongodb://...'. See specifications at http://docs.mongodb.org/manual/reference/connection-string/
- Servers: Comma separated list of servers to connect to. Typically a single mongod or mongos server is required.
- Connection Mode: the default is "Automatic" and should be used for a replica set or a sharded cluster. The "Direct" mode is used to connect directly to a single server.
- Databases: Optional, a comma separated list of databases to use. If empty, all databases will be detected.
- User: Optional, the user name for authentication. The authentication will be used for either the provided databases or 'admin'.
- Password: Optional, the password for authentication
Advanced options
The following options are supported:
- socketType: type of socket to use. Currently 'Plain', 'SSL' and 'SSL no validation' are supported
- connectTimeout: Timeout for the socket connect operation
- socketTimeout: Timeout for the socket read/write operations
- safeWrites: Sets the global WriteConcern as SAFE, which means that writes are acknowledged by the server
- secondaryReads: Allows the read operations to go to secondary servers
Connecting with SSL
To connect using SSL, use the 'SSL' socketType in the Connect Dialog.
If using self-signed certificates (for either client or server), use the 'SSL no validation' socketType.
UMongo relies on Java's SSL utilities, for more information please refer to Java and Keytool documentation.
Paths to the keyStore and trustStore can be entered under the Security tab in the Preferences Dialog.
UMongo will prompt for a password, but it will not store it on disk.
Setting up the client SSL certificate
The client certificate can be added through the Java Keystore.
Assuming you have a ".pem" certificate file, convert it to pkcs12 using:
openssl pkcs12 -export -in client-cert.pem -out client-cert.p12
From the p12 file you can create the keystore:
keytool -importkeystore -srckeystore client-cert.p12 -srcstoretype PKCS12 -destkeystore keystore.jks
Adding a Certificate Authority file
Adding a CA file is done using keytool
keytool -import -trustcacerts -alias root -file Thawte.crt -keystore keystore.jks
Proxy options
The following options are supported:
- proxyType: Type of proxy. Currently 'None' and 'SOCKS' are supported
- proxyHost: The proxy host
- proxyPort: The proxy port
If MongoDB is not accessible from your local machine, but you can SSH to a server that can connect, do the following:
- create a SOCKS proxy from your terminal by using 'ssh -D LocalPort hostWithDBAccess -N'. An example port is 9000
- when connecting, set proxyType to 'SOCKS', proxyHost to 'localhost' and proxyPort to 9000.
Examples
Following are possible connections:
- To connect to a replica set: input at least one server name in "servers", select "automatic" connection mode
- To connect to a secondary server: input the server name in "servers", select "direct" connection mode, check "secondary reads" box