Stop mysql in xtradbcluster on Kubernetes

Hello,

I have deployed xtradbcluster using K8s operator. I want to stop mysql instances and also stop galera replication. or gracefull shutdown of mysql instance. Can you please help with this?

Tried the cluster pause command, that does not work. I’m doing anything wrong?

helm upgrade mysql-a18 . --namespace ns5 --set pause=true

Regards,
Anand

1 Like

Hi @AnandaKumar_Kench

What is the output of the command?

1 Like

Below is the output


ts_a_kencharamanahal@paas-app:~/pxc-db$ helm upgrade mysql-a22 . --namespace ns5 --set pause=true
Release “mysql-a22” has been upgraded. Happy Helming!
NAME: mysql-a22
LAST DEPLOYED: Wed Aug 4 09:54:42 2021
NAMESPACE: ns5
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:

  1. To get a MySQL prompt inside your new cluster you can run:

    ROOT_PASSWORD=kubectl -n ns5 get secrets mysql-a22-pxc-db -o jsonpath="{.data.root}" | base64 --decode
    kubectl -n ns5 exec -ti
    mysql-a22-pxc-db-pxc-0 – mysql -uroot -p"$ROOT_PASSWORD"

  2. To connect an Application running in the same Kubernetes cluster you can connect with:

$ kubectl run -i --tty --rm percona-client --image=percona --restart=Never
– mysql -h mysql-a22-pxc-db-proxysql.ns5.svc.cluster.local -uroot -p"$ROOT_PASSWORD"

1 Like

You need to patch the CR, not the operator via helm.

As I understand, your cluster name is mysql-a22-pxc-db. You can pause the cluster with the following command:

kubectl -n ns5 patch --type=merge --patch='{ "spec": { "pause": true } }' pxc mysql-a22-pxc-db
1 Like

Thank you. The above command stops the cluster and also brings down the pods.

My requirement is to restore a database into the cluster. I have backup of standalone DB taken from xtrabackup. Inorder to restore on the xtradbcluster i need to stop mysql services and restart the replication post restore. How can i stop mysql and galera replication?

Thanks,
Anand

1 Like

You can create a PerconaXtraDBClusterRestore object and let the operator do the rest. But, since you don’t have a PerconaXtraDBClusterBackup to reference from restore config, you need to put your backup to s3 or google cloud storage and configure the restore with backupSource:

apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBClusterRestore
metadata:
  name: restore1
spec:
  pxcCluster: cluster1
  backupSource:
    destination: s3://<path/to/backup>
    s3:
      bucket: s3-bucket
      credentialsSecret: my-cluster-name-backup-s3
      endpointUrl: https://s3.us-west-2.amazonaws.com/
      region: us-west-2

Please note, I didn’t test the config and maybe you need perform more actions. If anything unexpected happens, please let me know.

1 Like

Thank you.

We don’t have S3/object store. The backup is available in NFS server, any alternates? Pls suggest.

Thanks,
Anand

1 Like