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

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