How to restart a cluster
This guide explains how to restart a MongoDB cluster from the Hikube console, for example when a member no longer behaves normally.
Prerequisites
- A MongoDB cluster with the status Ready in your project
- The right to edit this cluster
What happens during the restart
All instances of the cluster restart at once:
- the cluster is unreachable for a few seconds while the members restart;
- open connections are closed and your applications must reconnect;
- data is kept.
On a sharded cluster, the mongos routers are not restarted.
Plan the restart in a maintenance window or outside peak hours, and check that your applications can reconnect automatically.
Steps
1. Open the cluster page
- Open DB & Messaging → MongoDB.
- Open the cluster.
2. Start the restart
- Click Restart, next to the Edit and Delete buttons.
- The "Restart
<name>?" window recalls the effect of the restart. Confirm with Restart.
The "Restart started" message confirms that the request was accepted. The restart continues in the background.
A cluster that is still being created has nothing to restart yet: the request is refused. Wait a few minutes after the cluster reaches the status Ready, while it finishes starting, then start the restart again.
Verification
The cluster status does not change during a restart: it keeps showing Ready. To confirm the restart, check how many seconds the member has been running:
mongosh "mongodb://<host>:27017/admin?directConnection=true&authSource=admin" --username <user> \
--eval "db.serverStatus().uptime"
A low value confirms that the member has just restarted.
Further reading
- MongoDB concepts: replication, high availability and sharding
- Change a cluster's resources