Last active
February 19, 2021 02:28
-
-
Save pichuang/7e09bc88d46f9d4a1272ea38da0de075 to your computer and use it in GitHub Desktop.
WIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
etcd_node=`oc get pods -n openshift-etcd -l app=etcd -o=jsonpath='{.items[0].spec.nodeName}'` | |
ssh -i ~/.ssh/dmz-ocp4-rsa core@$etcd_node | |
id=$(sudo crictl ps --name etcdctl | awk 'FNR==2{ print $1}') && sudo crictl exec -it $id /bin/bash | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@master0 ~]# etcdctl endpoint status -w table --cluster | |
-bash: etcdctl: command not found | |
[root@master0 ~]# id=$(sudo crictl ps --name etcdctl | awk 'FNR==2{ print $1}') && sudo crictl exec -it $id /bin/bash | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster | |
[root@master0 /]# ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
[root@master0 /]# rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
[root@master0 /]# etcdctl compact $rev | |
compacted revision 34743 | |
[root@master0 /]# unset ETCDCTL_ENDPOINTS | |
[root@master0 /]# etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
Finished defragmenting etcd member[https://localhost:2379] | |
[root@master0 /]# etcdctl endpoint status -w table --cluster | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
| https://192.168.76.1:2379 | 5d9ec24d066fd4f1 | 3.4.9 | 43 MB | false | false | 6 | 39773 | 39773 | | | |
| https://192.168.76.3:2379 | 9716d0ced1aa6dd8 | 3.4.9 | 78 MB | true | false | 6 | 39773 | 39773 | | | |
| https://192.168.76.2:2379 | b56b2984143eb82f | 3.4.9 | 78 MB | false | false | 6 | 39773 | 39773 | | | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
[root@master0 /]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh -i ~/.ssh/dmz-ocp4-rsa core@master1.dmz.ocp4.local | |
The authenticity of host 'master1.dmz.ocp4.local (192.168.76.2)' can't be established. | |
ECDSA key fingerprint is SHA256:gN18QVcIkp0Ll705CQ9I4qdmIEO0Y7N0WGkz1fetO+M. | |
ECDSA key fingerprint is MD5:ad:dc:9c:be:5c:c9:ec:fc:ee:9a:cc:bc:fe:79:83:2d. | |
Are you sure you want to continue connecting (yes/no)? yes | |
Warning: Permanently added 'master1.dmz.ocp4.local,192.168.76.2' (ECDSA) to the list of known hosts. | |
Red Hat Enterprise Linux CoreOS 46.82.202010091720-0 | |
Part of OpenShift 4.6, RHCOS is a Kubernetes native operating system | |
managed by the Machine Config Operator (`clusteroperator/machine-config`). | |
WARNING: Direct SSH access to machines is not recommended; instead, | |
make configuration changes via `machineconfig` objects: | |
https://docs.openshift.com/container-platform/4.6/architecture/architecture-rhcos.html | |
--- | |
[core@master1 ~]$ id=$(sudo crictl ps --name etcdctl | awk 'FNR==2{ print $1}') && sudo crictl exec -it $id /bin/bash | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster | |
[root@master1 /]# ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
[root@master1 /]# rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
[root@master1 /]# etcdctl compact $rev | |
compacted revision 35243 | |
[root@master1 /]# unset ETCDCTL_ENDPOINTS | |
[root@master1 /]# etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
Finished defragmenting etcd member[https://localhost:2379] | |
[root@master1 /]# etcdctl endpoint status -w table --cluster | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
| https://192.168.76.1:2379 | 5d9ec24d066fd4f1 | 3.4.9 | 43 MB | true | false | 7 | 40398 | 40398 | | | |
| https://192.168.76.3:2379 | 9716d0ced1aa6dd8 | 3.4.9 | 78 MB | false | false | 7 | 40398 | 40398 | | | |
| https://192.168.76.2:2379 | b56b2984143eb82f | 3.4.9 | 42 MB | false | false | 7 | 40398 | 40398 | | | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
[root@master1 /]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh -i ~/.ssh/dmz-ocp4-rsa core@master2.dmz.ocp4.local | |
Red Hat Enterprise Linux CoreOS 46.82.202010091720-0 | |
Part of OpenShift 4.6, RHCOS is a Kubernetes native operating system | |
managed by the Machine Config Operator (`clusteroperator/machine-config`). | |
WARNING: Direct SSH access to machines is not recommended; instead, | |
make configuration changes via `machineconfig` objects: | |
https://docs.openshift.com/container-platform/4.6/architecture/architecture-rhcos.html | |
--- | |
Last login: Fri Feb 19 02:23:03 2021 from 192.168.76.100 | |
[core@master2 ~]$ id=$(sudo crictl ps --name etcdctl | awk 'FNR==2{ print $1}') && sudo crictl exec -it $id /bin/bash | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster | |
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
etcdctl compact $rev | |
unset ETCDCTL_ENDPOINTS | |
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
etcdctl endpoint status -w table --cluster | |
[root@master2 /]# ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}') | |
[root@master2 /]# rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1) | |
[root@master2 /]# etcdctl compact $rev | |
compacted revision 37406 | |
[root@master2 /]# unset ETCDCTL_ENDPOINTS | |
[root@master2 /]# etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag | |
Finished defragmenting etcd member[https://localhost:2379] | |
[root@master2 /]# etcdctl endpoint status -w table --cluster | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
| https://192.168.76.1:2379 | 5d9ec24d066fd4f1 | 3.4.9 | 46 MB | false | false | 9 | 43006 | 43006 | | | |
| https://192.168.76.3:2379 | 9716d0ced1aa6dd8 | 3.4.9 | 45 MB | true | false | 9 | 43006 | 43005 | | | |
| https://192.168.76.2:2379 | b56b2984143eb82f | 3.4.9 | 46 MB | false | false | 9 | 43006 | 43006 | | | |
+---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |
[root@master2 /]# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment