ApsaraDB for MongoDB lets you change the endpoint prefix and port number of instance nodes, so that applications can connect to a new instance without configuration changes after migration.
Supported changes by architecture
| Architecture | Endpoint changes | Port changes |
|---|---|---|
| Standalone | Primary node only (internal and public) | Not supported |
| Replica set (local SSDs or ESSDs) | Primary, secondary, and read-only nodes | MongoDB 4.2 or later with ESSDs |
| Sharded cluster | Mongos nodes only | MongoDB 4.2 or later with ESSDs |
This procedure does not apply to the connection string URI of a replica set instance. A connection string URI includes the replicaSet parameter, which cannot be changed. If your application uses the connection string URI, you must update the URI in your application manually after changing the endpoint.
Connection types
Each ApsaraDB for MongoDB instance has two connection types:
Internal endpoint (VPC): For resources within the same Virtual Private Cloud (VPC). Provides lower latency and incurs no data transfer fees.
Public endpoint: For access over the internet. Available only after you apply for a public endpoint. For more information, see Apply for a public endpoint.
Prerequisites
Before you begin, make sure that you have:
An ApsaraDB for MongoDB instance in the Running state
A public endpoint applied for the instance, if you want to change the public endpoint
Change the endpoint or port
Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select the region where your instance is deployed. Find the target instance and click its ID.
In the left-side navigation pane, click Database Connections.
In the Internal Connections - VPC or Public Connections section, click Update Connection String.
NoteThe Update Connection String option appears in the Public Connections section only after a public endpoint is applied for the instance.
In the Update Connection String panel, configure the following parameters.
Parameter Description Node The node whose endpoint to modify. For a sharded cluster instance, only mongos nodes are available. Current Connection String The current endpoint of the selected node. New Connection String The prefix of the new endpoint. Must start with a lowercase letter, end with a lowercase letter or digit, contain only lowercase letters, digits, and hyphens (-), and be 8 to 64 characters in length. Port Number The port for the new endpoint. Valid values: 1000 to 65535. Click OK.
Verify the change
After the change takes effect, go to the Database Connections page. The updated endpoint and port are displayed in the Internal Connections - VPC or Public Connections section.
What to do next
After you modify the endpoint of the node, connect your client to the instance by using the new endpoint and port.