github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-mysql/cluster-management/restart-mysql-cluster.md (about)

     1  ---
     2  title: Restart MySQL cluster
     3  description: How to restart a MySQL cluster
     4  keywords: [mysql, restart, restart a cluster]
     5  sidebar_position: 4
     6  sidebar_label: Restart
     7  ---
     8  
     9  # Restart MySQL cluster
    10  
    11  You can restart all pods of the cluster. When an exception occurs in a database, you can try to restart it.
    12  
    13  :::note
    14  
    15  All pods restart in the order of learner -> follower -> leader and the leader may change after the cluster restarts.
    16  
    17  :::
    18  
    19  ## Steps
    20  
    21  1. Restart a cluster.
    22  
    23     You can use `kbcli` or create an OpsRequest to restart a cluster.
    24    
    25     **Option 1.** (**Recommended**) Use kbcli
    26  
    27     Configure the values of `components` and `ttlSecondsAfterSucceed` and run the command below to restart a specified cluster.
    28  
    29     ```bash
    30     kbcli cluster restart <name> --components="mysql" \
    31     --ttlSecondsAfterSucceed=30
    32     ```
    33  
    34     - `components` describes the component name that needs to be restarted.
    35     - `ttlSecondsAfterSucceed` describes the time to live of an OpsRequest job after the restarting succeeds.
    36  
    37     **Option 2.** Create an OpsRequest
    38  
    39     Run the command below to restart a cluster.
    40  
    41     ```bash
    42     kubectl apply -f - <<EOF
    43     apiVersion: apps.kubeblocks.io/v1alpha1
    44     kind: OpsRequest
    45     metadata:
    46       name: ops-restart
    47     spec:
    48       clusterRef: mysql-cluster
    49       type: Restart 
    50       restart:
    51       - componentName: mysql
    52     EOF
    53     ```
    54  
    55  2. Check the cluster status to validate the restarting.
    56  
    57     ```bash
    58     kbcli cluster list mysql-cluster
    59     >
    60     NAME                 NAMESPACE        CLUSTER-DEFINITION        VERSION                TERMINATION-POLICY        STATUS         CREATED-TIME
    61     mysql-cluster        default          apecloud-mysql            ac-mysql-8.0.30        Delete                    Running        Jan 29,2023 14:29 UTC+0800
    62     ```
    63  
    64     - STATUS=Restarting: it means the cluster restart is in progress.
    65     - STATUS=Running: it means the cluster has been restarted.