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

     1  ---
     2  title: Stop/Start a MySQL cluster
     3  description: How to stop/start a MySQL cluster
     4  keywords: [mysql, stop a cluster, start a cluster]
     5  sidebar_position: 5
     6  sidebar_label: Stop/Start
     7  ---
     8  
     9  # Stop/Start a MySQL cluster
    10  
    11  You can stop/start a cluster to save computing resources. When a cluster is stopped, the computing resources of this cluster are released, which means the pods of Kubernetes are released, but the storage resources are reserved. Start this cluster again if you want to restore the cluster resources by snapshots.
    12  
    13  ## Stop a cluster
    14  
    15  ### Option 1. (Recommended) Use kbcli
    16  
    17  Configure the name of your cluster and run the command below to stop this cluster.
    18  
    19  ```bash
    20  kbcli cluster stop mysql-cluster
    21  ```
    22  
    23  ### Option 2. Create an OpsRequest
    24  
    25  Run the command below to stop a cluster.
    26  
    27  ```bash
    28  kubectl apply -f - <<EOF
    29  apiVersion: apps.kubeblocks.io/v1alpha1
    30  kind: OpsRequest
    31  metadata:
    32    name: mysql-cluster
    33    generateName: stop-
    34  spec:
    35    # cluster ref
    36    clusterRef: mysql-cluster
    37    type: Stop
    38  EOF
    39  ```
    40  
    41  ### Option 3. Change the YAML file of the cluster
    42  
    43  Configure replicas as 0 to delete pods.
    44  
    45  ```yaml
    46  apiVersion: apps.kubeblocks.io/v1alpha1
    47  kind: Cluster
    48  metadata:
    49      name: mysql-cluster
    50  spec:
    51    clusterDefinitionRef: apecloud-mysql
    52    clusterVersionRef: ac-mysql-8.0.30
    53    terminationPolicy: WipeOut
    54    componentSpecs:
    55    - name: mysql
    56      componentDefRef: mysql
    57      monitor: false  
    58      replicas: 0
    59      volumeClaimTemplates:
    60      - name: data
    61        spec:
    62          storageClassName: standard
    63          accessModes:
    64            - ReadWriteOnce
    65          resources:
    66            requests:
    67              storage: 1Gi
    68  ```
    69  
    70  ## Start a cluster
    71    
    72  ### Option 1. (Recommended) Use kbcli
    73  
    74  Configure the name of your cluster and run the command below to start this cluster.
    75  
    76  ```bash
    77  kbcli cluster start mysql-cluster
    78  ```
    79  
    80  ### Option 2. Create an OpsRequest
    81  
    82  Run the command below to start a cluster.
    83  
    84  ```bash
    85  kubectl apply -f - <<EOF
    86  apiVersion: apps.kubeblocks.io/v1alpha1
    87  kind: OpsRequest
    88  metadata:
    89    name: mysql-cluster
    90    generateName: start-
    91  spec:
    92    # cluster ref
    93    clusterRef: mysql-cluster
    94    type: Start
    95  EOF 
    96  ```
    97  
    98  ### Option 3. Change the YAML file of the cluster
    99  
   100  Change replicas back to the original amount to start this cluster again.
   101  
   102  ```yaml
   103  apiVersion: apps.kubeblocks.io/v1alpha1
   104  kind: Cluster
   105  metadata:
   106      name: mysql-cluster
   107  spec:
   108    clusterDefinitionRef: apecloud-mysql
   109    clusterVersionRef: ac-mysql-8.0.30
   110    terminationPolicy: WipeOut
   111    componentSpecs:
   112    - name: mysql
   113      componentDefRef: mysql
   114      monitor: false  
   115      replicas: 3
   116      volumeClaimTemplates:
   117      - name: data
   118        spec:
   119          storageClassName: standard
   120          accessModes:
   121            - ReadWriteOnce
   122          resources:
   123            requests:
   124              storage: 1Gi
   125  ```