一.簡單說明
etcd的數據庫空間配額大小默認限制為2G,當數據達到2G的時候就不允許寫入。這里如果想繼續寫入,必須對歷史數據進行壓縮,或者調整etcd數據庫的空間配額大小限制。
二.具體配置
當空間配額滿載時,會提示mvcc: database space exceeded
2.1 查看etcd的配額使用量
[root@k8s001 ~]# export ETCDCTL_API=3
[root@k8s001 ~]# etcdctl endpoint status --write-out table
+----------------+------------------+---------+---------+-----------+-----------+------------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
+----------------+------------------+---------+---------+-----------+-----------+------------+
| 127.0.0.1:2379 | 8e9e05c52164694d | 3.3.10 | 7.8 MB | true | 3 | 3085227 |
+----------------+------------------+---------+---------+-----------+-----------+------------+
2.2 開啟磁盤碎片整理
1.獲取歷史版本號
[root@k8s001 ~]# export ETCDCTL_API=3
[root@k8s001 ~]# etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*'
8991138
2.壓縮舊版本
[root@k8s001 ~]# etcdctl compact 8991138
compacted revision 8991138
3.etcd進行碎片整理
[root@k8s001 ~]# etcdctl defrag
Finished defragmenting etcd member[127.0.0.1:2379]
4.查看etcd數據庫大小
[root@k8s001 ~]# etcdctl endpoint status --write-out table
+----------------+------------------+---------+---------+-----------+-----------+------------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
+----------------+------------------+---------+---------+-----------+-----------+------------+
| 127.0.0.1:2379 | 8e9e05c52164694d | 3.3.10 | 1.3 MB | true | 3 | 3089646 |
+----------------+------------------+---------+---------+-----------+-----------+------------+
2.3 修改etcd空間配額大小
1.修改systemd文件
[root@k8s001 ~]# cat /etc/systemd/system/etcd.service
......
--quota-backend-bytes=10240000000 # 這里單位是字節
......
2.重啟etcd服務
[root@k8s001 ~]# systemctl daemon-reload
[root@k8s001 ~]# systemctl restart etcd