Skip to content

Commit 908265f

Browse files
committed
docs,hack: support manual repair the Invalid Pod #331
1 parent b8cb91a commit 908265f

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

docs/rebuild.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Why need rebuild ?
2+
RadonDB cluster is semisynchronous replication mysql cluster. Because MySQL Semisynchronous Replication, It has a chance that the slave has more data than master, So when the xenon check it, It will lable the pod INVALID. When it happend, You
3+
need rebuild the INVALID pod.
4+
5+
# How to use ?
6+
Before you want to rebuild the pod, you need to manually check the security and consistency of the cluster.
7+
8+
```shell
9+
./hack/rebuild.sh PODNAME
10+
```
11+
**for example**
12+
```shell
13+
./hack/rebuild.sh sample-mysql-2
14+
```

hack/rebuild.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
## This script is used to rebuild the pod.
3+
## useage : ./rebuild.sh pod_name
4+
function check_pod_status(){
5+
POD_STATUS=$(kubectl get pods $POD_NAME -o jsonpath='{.status.phase}')
6+
if [ "$POD_STATUS" == "Running" ]; then
7+
echo "Pod $POD_NAME is running."
8+
else
9+
echo "Pod $POD_NAME is not running."
10+
exit 1
11+
fi
12+
}
13+
function rebuild_pod(){
14+
INVALID=$(kubectl exec -it $POD_NAME -c xenon -- xenoncli raft status | grep "INVALID")
15+
if [ -z $INVALID ]; then
16+
echo "Pod in Raft is not in invalid state, please check your cluster status."
17+
exit 1
18+
fi
19+
20+
kubectl exec -it $POD_NAME -c mysql -- rm -rf /var/lib/mysql/*
21+
22+
sleep 5
23+
kubectl delete pod $POD_NAME
24+
echo "Rebuild mysql success."
25+
}
26+
27+
if [ "$#" -ne 1 ]; then
28+
echo "Usage: $0 POD_NAME." >&2
29+
exit 1
30+
fi
31+
POD_NAME=$1
32+
echo "Rebuilding is danagerous job, Before doing this, please make sure your cluster data is safe and consistent."
33+
while true; do
34+
read -p "Do you want to do it (y/n)?" yn
35+
case $yn in
36+
[Yy]* ) check_pod_status; rebuild_pod;break;;
37+
[Nn]* ) exit;;
38+
* ) echo "Please answer yes or no.";;
39+
esac
40+
done
41+

0 commit comments

Comments
 (0)