kuboard使用的etcd空间清理(3个etcd)

1.查看当前kuboard使用的etcd情况

[root@master kuboard]# kubectl get pods -n kuboard -o wide|grep etcd
kuboard-etcd-6vg9h            1/1     Running   0          22m   192.168.1.106   node2    <none>           <none>
kuboard-etcd-75tr4            1/1     Running   0          22m   192.168.1.108   master   <none>           <none>
kuboard-etcd-wb7xr            1/1     Running   0          22m   192.168.1.105   node1    <none>           <none>

 

2.逐一清理每个etcd,下面以kuboard-etcd-6vg9h为例子

2.1查看当前etcd的情况

[root@master kuboard]# ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" --write-out=table endpoint status
+--------------------+-----------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
|      ENDPOINT      |       ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+--------------------+-----------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| 192.168.1.106:2381 | 10625e75540c6b8 |  3.4.16 |  455 kB |     false |      false |        70 |       1307 |               1307 |        |
+--------------------+-----------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+

 

2.2 找到etcd数据存储路径

[root@master kuboard]# kubectl describe pod kuboard-etcd-6vg9h -n kuboard
...
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  data:
    Type:          HostPath (bare host directory volume)
    Path:          /usr/share/kuboard/etcd
...

 

2.3 进入到etcd数据目录中查看

[root@node2 snap]# pwd
/usr/share/kuboard/etcd/member/snap
[root@node2 snap]# ls -al
total 576
drwx------ 2 root root     16 Sep 30 09:25 .
drwx------ 4 root root     29 Sep 30 09:25 ..
-rw------- 1 root root 483328 Sep 30 09:59 db

 

[root@node2 wal]# pwd
/usr/share/kuboard/etcd/member/wal
[root@node2 wal]# ls -al
total 125000
drwx------ 2 root root       64 Sep 30 09:25 .
drwx------ 4 root root       29 Sep 30 09:25 ..
-rw------- 1 root root 64000000 Sep 30 09:59 0000000000000000-0000000000000000.wal
-rw------- 1 root root 64000000 Sep 30 09:25 0.tmp

 

# 压缩旧版本
[root@master kuboard]#ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" compact $(ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*')

 

 

或是找到旧版本号
[root@master kuboard]#ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*'
上面的命令会输出一个旧版本号,如下:
839
然后执行下面的命令进行压缩
[root@master kuboard]#ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" compact 839

 

 

 

# 整理多余的空间
[root@master kuboard]#ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" defrag

执行这个命令后数据明显变少了

[root@node2 snap]# ls -al
total 128
drwx------ 2 root root     16 Sep 30 10:01 .
drwx------ 4 root root     29 Sep 30 09:25 ..
-rw------- 1 root root 131072 Sep 30 10:01 db

 

# 取消告警信息(之前有nospace的告警)
[root@master kuboard]#ETCDCTL_API=3 etcdctl --endpoints="192.168.1.106:2381" alarm disarm

 

posted @ 2025-09-30 10:08  slnngk  阅读(25)  评论(0)    收藏  举报