ApsaraDB for MongoDB allows you to modify the internal endpoint, public endpoint, and port of an instance.
Limits
Instance architecture | Endpoint | Port | Scenario for switching to a new instance |
Standalone instance | You can modify only the public and internal endpoints of the primary node in a standalone instance. | You cannot modify the port of a standalone instance. | You can modify the endpoint and port of a new instance to match those of the original instance. This way, you do not need to modify the endpoint and port in your application. |
Replica set instance | You can modify the endpoints of the primary, secondary, and read-only nodes for an instance that uses local SSDs and ESSDs. | You can modify the port of an instance that runs MongoDB 4.2 or later and uses ESSDs. | The connection string of a high availability address for a replica set instance contains replicaSet information that cannot be modified. Therefore, when you switch to a new instance, you need to modify the endpoint and port in your application. |
Sharded cluster instance |
| You can modify the port of an instance that runs MongoDB 4.2 or later and uses ESSDs. | You can modify the endpoint and port of a new instance to match those of the original instance. This way, you do not need to modify the endpoint and port in your application. |
Procedure
Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select a resource group and region. Then, click the ID of the target instance.
In the left-side navigation pane of the instance details page, click Database Connections.
In the Internal Connections - VPC or Public Connections section, click Update Connection String.
NoteThe Public Connections section displays the Update Connection String button only after you apply for a public endpoint for the MongoDB instance. For more information, see Apply for a public endpoint.
In the Update Connection String panel, configure the parameters.
Parameter
Description
Node
The node whose endpoint you want to modify. Select the node from the drop-down list.
NoteYou can modify only the endpoint of a mongos node for a sharded cluster instance.
Current Connection String
The current endpoint of the node.
New Connection String
The prefix of the new endpoint of the node, which must meet the following requirements:
The prefix must start with a lowercase letter.
The prefix must end with a lowercase letter or a digit.
The prefix must be 8 to 64 characters in length and can contain lowercase letters, digits, and hyphens (-).
Port Number
The port corresponding to the new endpoint. Valid values: 1000 to 65535.
Click OK.
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.