点击上方蓝字”运维笔谈”,对话回复 “阿里云k8s” 可以获取《阿里云Kubernetes项目实战手册》PDF
Etcd广泛应用于分布式系统中,如Kubernetes、服务发现、消息队列、负载均衡、分布式锁等场景。它提供了强大的数据管理能力,适用于需要高可用、一致性及数据共享的分布式应用。etcd为了防止性能下降其存储大小配额默认设置为2GB(当然我们可以修改为最高8GB)。
今天遇到一个问题,由于etcd是默认配置,其磁盘配置为2GB的配额,目前出现了数据写入失败的情况。
/ # etcdctl put frank JingLiError: etcdserver: mvcc: database space exceeded/ # etcdctl --endpoints etcd-0.etcd:2379,etcd-1.etcd:2379,etcd-2.etcd:2379 endpoint status --write-out=table+------------------+------------------+---------+---------+-----------+-----------+------------+| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |+------------------+------------------+---------+---------+-----------+-----------+------------+| etcd-0.etcd:2379 | f8a8*** | 3.3.8 | 2.1 GB | false | 951 | 7898831 || etcd-1.etcd:2379 | 9de5*** | 3.3.8 | 2.1 GB | false | 951 | 7898831 || etcd-2.etcd:2379 | 7760*** | 3.3.8 | 2.1 GB | true | 951 | 7898831 |+------------------+------------------+---------+---------+-----------+-----------+------------+

那么如何来解决2GB空间配额满的问题,除了增加配额,我们也可以压缩数据,整理碎片释放下部分空间。下面我简单罗列了下处理过程:
1、执行碎片整理
etcdctl defrag
2、手动触发压缩
etcdctl --endpoints=<etcd-endpoint> compact 7898831
3、检查状态已经压缩到了1.2GB了。
/ # etcdctl --endpoints etcd-0.etcd:2379,etcd-1.etcd:2379,etcd-2.etcd:2379 endpoint status --write-out=table+------------------+------------------+---------+---------+-----------+-----------+------------+| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |+------------------+------------------+---------+---------+-----------+-----------+------------+| etcd-0.etcd:2379 | f8a8*** | 3.3.8 | 1.2 GB | false | 951 | 7900975 || etcd-1.etcd:2379 | 9de5*** | 3.3.8 | 1.2 GB | false | 951 | 7900975 || etcd-2.etcd:2379 | 7760*** | 3.3.8 | 1.2 GB | true | 951 | 7900975 |+------------------+------------------+---------+---------+-----------+-----------+------------+
然而再测试写入,还是提示database space exceeded(空间超出)
/ # etcdctl put aa bbError: etcdserver: mvcc: database space exceeded
迫不得已,我尝试了挨个重启每个etcd实例后还是无法写入
4、查看告警列表 etcdctl alarm list,发现有两条告警:
/ # etcdctl alarm listmemberID:179** alarm:NOSPACEmemberID:113** alarm:NOSPACE
5、手动解除告警 etcdctl alarm disarm
/ # etcdctl alarm disarmmemberID:179** alarm:NOSPACEmemberID:113** alarm:NOSPACE
解除之后,etcd可以正常写入了。

文章转载自运维笔谈,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




