KubeBlocks
BlogsKubeBlocks Cloud
⌘K
​
KubeBlocks for MongoDB

Cluster Management

Create and connect
Scale
Expand volume
Restart
Stop/Start
Switchover
Delete protection

Configuration

Configure cluster parameters
  1. Steps

Restart MongoDB cluster

You can restart all pods of the cluster. When an exception occurs in a database, you can try to restart it.

Steps

  1. Create an OpsRequest to restart a cluster.

    kubectl apply -f - <<EOF
    apiVersion: apps.kubeblocks.io/v1alpha1
    kind: OpsRequest
    metadata:
      name: ops-restart
      namespace: demo
    spec:
      clusterName: mycluster
      type: Restart 
      restart:
      - componentName: mongodb
    EOF
    
  2. Check the pod and operation status to validate the restarting.

    kubectl get pod -n demo
    >
    NAME                  READY   STATUS            RESTARTS   AGE
    mycluster-mongodb-0   3/4     Terminating       0          5m32s
    
    kubectl get ops ops-restart -n demo
    >
    NAME          TYPE      CLUSTER     STATUS    PROGRESS   AGE
    ops-restart   Restart   mycluster   Succeed   1/1        3m26s
    

    During the restarting process, there are two status types for pods.

    • STATUS=Terminating: it means the cluster restart is in progress.
    • STATUS=Running: it means the cluster has been restarted.
  1. Restart a cluster with kbcli cluster restart command and enter the cluster name again.

    kbcli cluster restart mycluster -n demo
    >
    OpsRequest mongodb-cluster-restart-pzsbj created successfully, you can view the progress:
          kbcli cluster describe-ops mongodb-cluster-restart-pzsbj -n demo
    
  2. Validate the restart operation.

    Check the cluster status to identify the restart status.

    kbcli cluster list mycluster -n demo
    >
    NAME                   NAMESPACE        CLUSTER-DEFINITION        VERSION            TERMINATION-POLICY        STATUS         CREATED-TIME
    mongodb-cluster        demo             mongodb                   mongodb-5.0        Delete                    Running        Apr 26,2023 12:50 UTC+0800
    
    • STATUS=Updating: it means the cluster restart is in progress.
    • STATUS=Running: it means the cluster has been restarted.

© 2025 ApeCloud PTE. Ltd.