All Products
Search
Document Center

ApsaraDB for MongoDB:Restart an ApsaraDB for MongoDB instance or a node

Last Updated:Aug 03, 2023

If a standalone instance, a replica set instance, or a sharded cluster instance, or a mongos or shard node in a sharded cluster instance reaches the upper limit for connections or is degraded in performance, you can restart the instance or node.

Usage notes

  • When an instance is restarted, processes that run on the instance are stopped and restarted, and all connections to the instance are closed. Make sure that your application can automatically reconnect to the instance.

  • In most cases, the mongod and mongos processes are started within 30 seconds. However, if the instance contains more than 10,000 collections, several minutes may be required for the mongod process to start. Before a mongod process is started, you cannot connect to the node on which the process is run. To prevent service interruptions caused by excessive restart time, we recommend that you use no more than 10,000 collections in your instance. For more information, see MongoDB documentation.

  • After a replica set instance is restarted, the role of a node in the instance may change. We recommend that you use a connection string URI in the production environment. For more information, see Connect to a replica set instance.

  • If a sharded cluster instance is restarted, connections to the instance are closed when the mongos process is restarted. We recommend that you use a connection string URI in the production environment and add endpoints of at least two mongos nodes to the URI. For more information, see Connect to a sharded cluster instance.

Restart an instance

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Replica Set Instances or Sharded Cluster Instances.

  3. In the upper-left corner of the page, select the resource group and region to which the instance belongs.

  4. Find the instance that you want to manage and click More in the Actions column. Then, select Restart.

  5. In the Restart Instance message, click OK.

    When the instance is being restarted, the instance is in the Restarting state. If the instance is in the Running state, the instance is restarted.

Restart a node

Note

Only nodes in a sharded cluster instance can be restarted.

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Sharded Cluster Instances.

  3. In the upper-left corner of the page, select the resource group and region to which the instance belongs.

  4. Click the ID of the instance that you want to manage or click Manage in the Actions column corresponding to the instance.

  5. In the Mongos List or Shard List section of the Basic Information page, find the node that you want to manage and click the 更多 icon in the Actions column. Then, select Restart.

  6. In the Restart Node message, click OK.

    When the node is being restarted, the instance is in the Restarting state. If the instance is in the Running state, the node is restarted.

FAQ

  • How does the system restart a replica set instance in the background? What are the impacts of the restart operation on my service?

    The system restarts the hidden node first, and then the secondary nodes. After these nodes are restarted, the system runs the replSetFreeze command to prevent a secondary node from being elected as the primary node within the next 60 seconds. Then, the system restarts the primary node. The restart operation has the following impacts on your service:

    • Hidden node: The restart operation that is performed on the hidden node does not affect your service.

    • Secondary nodes: All connections to the secondary nodes are closed and the client needs to establish the connections again. In this case, the primary node is available without affecting read and write operations.

    • Primary node: All connections to the primary node are closed and the client needs to establish the connections again. In this case, the secondary nodes are available without affecting read operations. If the primary node is restarted within 60 seconds, the instance becomes readable and writable. Otherwise, a secondary node is elected as the primary node.

  • How does the system restart a sharded cluster instance in the background? What are the impacts of the restart operation on my service?

    The system restarts the shard nodes, the Configserver node, and then the mongos nodes. The restart operation has the following impacts on your service:

    • Shard node: Multiple shard nodes are restarted in parallel. Client connections are not closed during the restart, but the shard nodes may not be able to handle write operations. We recommend that you retry the write operations after the restart.

    • ConfigServer node: The restart operation that is performed on the Configserver node does not affect your service.

    • Mongos nodes: Multiple mongos nodes are restarted in parallel. During the restart, all connections to the mongos nodes are closed. Make sure that your application can automatically reconnect to the instance.