Configuration
High Availability
You can initiate a switchover for a MySQL Replication Cluster. Then KubeBlocks switches the instance roles.
Make sure the cluster is running normally.
Check whether the following role probe parameters exist to verify whether the role probe is enabled.
kubectl get cd apecloud-mysql -o yaml
>
probes:
roleProbe:
failureThreshold: 2
periodSeconds: 1
timeoutSeconds: 1
You can switch over a secondary of a MySQL Replication to the primary role, and the former primary instance to a secondary one.
The value of instanceName
decides whether a new primary instance is specified for the switchover.
Initiate a switchover with no specified primary instance.
kubectl apply -f -<<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: mycluster-switchover-demo
namespace: demo
spec:
clusterRef: mycluster
type: Switchover
switchover:
- componentName: mysql
instanceName: '*'
>>
Initiate a switchover with a specified new primary instance.
kubectl apply -f -<<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: mycluster-switchover-demo
namespace: demo
spec:
clusterRef: mycluster
type: Switchover
switchover:
- componentName: mysql
instanceName: 'mycluster-mysql-1'
>>
Initiate a switchover with a specified new primary instance.
kbcli cluster promote mycluster --instance='mycluster-mysql-1' -n demo
If there are multiple components, you can use --components
to specify a component.
kbcli cluster promote mycluster --instance='mycluster-mysql-1' --components='apecloud-mysql' -n demo
Check the instance status to verify whether the switchover is performed successfully.
kubectl get pods -n demo
kbcli cluster list-instances -n demo
If an error occurs, refer to Handle an exception to troubleshoot the operation.