All Products
Search
Document Center

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

Last Updated:Jul 15, 2024

This topic describes how to restart an ApsaraDB for MongoDB instance, a component, or a node. If databases in an ApsaraDB for MongoDB instance reach the maximum number of connections to the instance and experience degraded performance, you can attempt to manually restart the instance, a component in the instance, or a node in the instance.

Limits

  • You can restart a component only in a sharded cluster instances.

  • You can restart a node only in an ApsaraDB for MongoDB instance that uses cloud disks.

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.

  • After a node in 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 node in a shard component of a sharded cluster instance is restarted, connections between your client and databases are not closed. However, data write operations may fail. We recommend that you retry write operations later.

Procedure

Restart an ApsaraDB for MongoDB 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 restart 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 status changes to Running, the instance is restarted.

Restart a component

Note

You can restart a component only in a sharded cluster instance.

  1. Go to the Sharded Cluster Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.

  2. In the Mongos List or Shard List section of the instance details page, find the component that you want to restart and click the 更多 icon in the Actions column. Then, select Restart.

  3. In the Restart Node message, click OK.

    When the component is being restarted, the instance is in the Restarting state. If the instance status changes to Running, the component is restarted.

Restart a node

  1. Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.

  2. In the left-side navigation pane of the instance details page, click Service Availability.

  3. Find the node that you want to restart and click Restart Node in the Actions column.

  4. In the Restart Node message, click OK.

    When the node is being restarted, the instance is in the Restarting state. If the instance status changes to Running, 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.