Restart MySQL cluster
You can restart all pods of the cluster. When an exception occurs in a database, you can try to restart it.
note
The pod role may change after the cluster restarts.
Steps
- kubectl
- kbcli
-
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: mysql
EOF -
Check the pod and operation status to validate the restarting.
kubectl get pod -n demo
>
NAME READY STATUS RESTARTS AGE
mycluster-mysql-0 4/4 Running 0 5m32s
mycluster-mysql-1 3/4 Terminating 0 6m36s
kubectl get ops ops-restart -n demo
>
NAME TYPE CLUSTER STATUS PROGRESS AGE
ops-restart Restart mycluster Succeed 1/1 3m26sDuring 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.
-
Restart a cluster.
Configure the values of
components
andttlSecondsAfterSucceed
and run the command below to restart a specified cluster.kbcli cluster restart mycluster -n demo --components="mysql" --ttlSecondsAfterSucceed=30
components
describes the component name that needs to be restarted.ttlSecondsAfterSucceed
describes the time to live of an OpsRequest job after the restarting succeeds.
-
Check the cluster status to validate the restarting.
kbcli cluster list mycluster -n demo
>
NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME
mycluster demo mysql mysql-8.0.33 Delete Updating Jul 05,2024 19:01 UTC+0800- STATUS=Updating: it means the cluster restart is in progress.
- STATUS=Running: it means the cluster has been restarted.