Connection address type |
- Private endpoint:
- VPC endpoint: Virtual Private Cloud (VPC) endpoints are used for communication over
VPCs. A VPC is an isolated network that provides higher security and performance than
the classic network. By default, ApsaraDB for MongoDB provides VPC endpoints for instances
to ensure high security and high performance.
- Classic network endpoint: Cloud services in the classic network are not isolated.
Unauthorized access to cloud services is blocked only by using security groups or
whitelists.
- Public endpoint: Public endpoints are used for communication over the Internet. If you connect to
an ApsaraDB for MongoDB instance over the Internet, the instance may be exposed to
security risks. By default, no public endpoints are provided for ApsaraDB for MongoDB
instances. If you want to connect to an ApsaraDB for MongoDB instance over the Internet,
you must apply for a public endpoint. For more information, see (Optional) Apply for a public endpoint for an ApsaraDB for MongoDB instance.
|
Role |
- Primary node: The primary node of a replica set instance can perform both read and
write operations on instance databases.
Important We recommend you do not connect to the primary node in the production environment
by using its connection string. Otherwise, your connection will be interrupted if
a primary/secondary switchover triggers a connection string change for the node. In
this case, you must connect to the new connection string to ensure that the read and
write operations are not affected.
- Secondary node: The secondary node of a replica set instance can perform only read
operations on instance databases.
- Read-only node: The read-only node of a replica set instance can perform only read
operations on instance databases.
Note The connection string of a read-only node is displayed only if the replica set instance
contains the read-only node.
- Read-only connection string URI: an HA connection string URI that ensures load balancing
and HA. If you use this URI to connect to a replica set instance, you can perform
read and write operations on instance databases. This URI allows you to connect to
a read-only node in the instance. If your instance contains multiple read-only nodes,
we recommend that you connect to this URI in scenarios where a large number of read
operations must be handled.
Note
- This URI can be viewed only if the instance contains at least one read-only node.
- If you use the read-only connection string URI to connect to a replica set instance,
read requests are preferentially sent to read-only nodes.
- If one read-only node fails, read requests are switched to the next read-only node
to ensure connectivity. If all read-only nodes fail, read requests are switched to
a secondary node.
- Connection string URI: an HA connection string URI that ensures load balancing and
HA. If you use this URI to connect to a replica set instance, you can perform read
and write operations on instance databases. This URI allows you to connect to a node
in the instance. We recommend that you connect to this URI in the production environment.
Important If you connect to this URI, all requests are processed by the primary node. Read and
write operations are not affected by primary/secondary switchover.
|
Connection string of a primary, secondary, or read-only node |
Format:<host>:<port>
Parameters:
<host> : the domain name information used to connect to the primary, secondary, or read-only node.
<port> : the port number used to connect to the primary, secondary, or read-only node.
Example: dds-bp19f409d7512****.mongodb.rds.aliyuncs.com:3717
|
Read-only connection string URI |
Format:mongodb://<username>:<password>@<host1>:<port1>,<host2>:<port2>,...,<hostN>:<portN>/<database>?readPreference=[secondary | secondaryPreferred][&readPreferenceTags=<readonly_Tags>]&replicaSet=<replicaSet_value>[&authSource=<authenticationDatabase>]
Parameters:
<username> : the name of the database account used to log on to the database. Default value:
root.
<password> : the password of the database account used to log on to the database.
<host> : the domain name information used to connect to the read-only node.
<port> : the port number used to connect to the read-only node.
<database> : the name of the database to which you want to connect. Default value: admin.
readPreference=[secondary | secondaryPreferred] : sends write requests to the primary node and read requests to a random secondary
or read-only node to ensure read/write splitting and load balancing. Valid values:
readPreference=secondary : does not send read requests to the primary node if all secondary and read-only nodes
fail.
readPreference=secondaryPreferred : sends read requests to the primary node if all secondary and read-only nodes fail.
readPreferenceTags=<readonly_Tags> : preferentially sends read requests to read-only nodes that are added with specified
tags. This parameter is optional. <readonly_Tags> : the list of tags that can be added to read-only nodes. The value is fixed at role:readonly and cannot be modified.
replicaSet=<replicaSet_value> : sends read requests to all nodes in the replica set instance. <replicaSet_value> : the unique URI ID used to connect to the replica set instance.
authSource=<authenticationDatabase> : specifies the database to which the specified database account belongs. This parameter
is optional. <authenticationDatabase> : the name of the database used for authentication. If you do not specify the authentication
database, the database specified by <database> is used as the authentication database.
Important For the authentication to succeed, the specified database account must belong to the
specified authentication database.
Example: mongodb://root:****@dds-bp19f409d7512****.mongodb.rds.aliyuncs.com:3717/admin?readPreference=secondary&readPreferenceTags=role:readonly&replicaSet=mgset-6108****
|
Connection string URI |
Format:mongodb://<username>:<password>@<host1>:<port1>,<host2>:<port2>,...,<hostN>:<portN>/<database>?replicaSet=<replicaSet_value>[&authSource=<authenticationDatabase>]
Parameters:
<username> : the name of the database account used to log on to the database. Default value:
root.
<password> : the password of the database account used to log on to the database.
<host> : the domain name information used to connect to the primary, secondary, or read-only node.
<port> : the port number used to connect to the primary, secondary, or read-only node.
<database> : the name of the database to which you want to connect.
replicaSet=<replicaSet_value> : sends read requests to all nodes in the replica set instance. <replicaSet_value> : the unique URI ID used to connect to the replica set instance.
authSource=<authenticationDatabase> : specifies the database to which the specified database account belongs. This parameter
is optional. <authenticationDatabase> : the name of the database used for authentication. If you do not specify the authentication
database, the database specified by <database> is used as the authentication database.
Important For the authentication to succeed, the specified database account must belong to the
specified authentication database.
Example: mongodb://root:****@dds-bp19f409d7512****.mongodb.rds.aliyuncs.com:3717,dds-bp19f409d7512****.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-6108****
|