# Stop mysql in xtradbcluster on Kubernetes

**URL:** <https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645>\
**Category:** Percona XtraDB Cluster 8.x\
**Tags:** percona\
**Created:** [August 4, 2021, 5:19am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645 "2021-08-04T05:19:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnandaKumar\_Kench](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/anandakumar_kench/32/4143_2.png) [@AnandaKumar\_Kench](https://forums.percona.com/u/AnandaKumar_Kench)\
**Post date:** [August 4, 2021, 5:19am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/1 "2021-08-04T05:19:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ege\_Gunes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ege_gunes/32/4595_2.png) [@Ege\_Gunes](https://forums.percona.com/u/Ege_Gunes)\
**Post date:** [August 4, 2021, 8:51am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/2 "2021-08-04T08:51:51Z")

</div>

Hi @AnandaKumar_Kench

> [@AnandaKumar\_Kench](#):
>
> helm upgrade mysql-a18 . --namespace ns5 --set pause=true

What is the output of the command?

---

<div class="post-metadata">

**Author:** ![AnandaKumar\_Kench](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/anandakumar_kench/32/4143_2.png) [@AnandaKumar\_Kench](https://forums.percona.com/u/AnandaKumar_Kench)\
**Post date:** [August 4, 2021, 9:56am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/3 "2021-08-04T09:56:19Z")

</div>

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:

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"

---

<div class="post-metadata">

**Author:** ![Ege\_Gunes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ege_gunes/32/4595_2.png) [@Ege\_Gunes](https://forums.percona.com/u/Ege_Gunes)\
**Post date:** [August 4, 2021, 10:26am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/4 "2021-08-04T10:26:52Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![AnandaKumar\_Kench](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/anandakumar_kench/32/4143_2.png) [@AnandaKumar\_Kench](https://forums.percona.com/u/AnandaKumar_Kench)\
**Post date:** [August 4, 2021, 11:23am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/5 "2021-08-04T11:23:31Z")

</div>

> [@AnandaKumar\_Kench](#):
>
> kubectl -n ns5 get secrets mysql-a22-pxc-db -o jsonpath=“{.data.root}” | base64 --decode

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

---

<div class="post-metadata">

**Author:** ![Ege\_Gunes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ege_gunes/32/4595_2.png) [@Ege\_Gunes](https://forums.percona.com/u/Ege_Gunes)\
**Post date:** [August 4, 2021, 11:49am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/6 "2021-08-04T11:49:36Z")

</div>

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`:

```auto
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.

---

<div class="post-metadata">

**Author:** ![AnandaKumar\_Kench](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/anandakumar_kench/32/4143_2.png) [@AnandaKumar\_Kench](https://forums.percona.com/u/AnandaKumar_Kench)\
**Post date:** [August 5, 2021, 4:21am UTC](https://forums.percona.com/t/stop-mysql-in-xtradbcluster-on-kubernetes/11645/7 "2021-08-05T04:21:35Z")

</div>

> [@Ege\_Gunes](#):
>

Thank you.

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

Thanks,  
Anand
