首页 技术 正文
技术 2022年11月16日
0 收藏 426 点赞 4,207 浏览 1081 个字

场景:做etcd数据镜像的时候出现如下错误  Error: etcdserver: mvcc: database space exceeded

通过查找官方文档https://coreos.com/etcd/docs/latest/op-guide/maintenance.html 确定解决方案,通过执行命令压缩etcd空间并且整理空间碎片即可

命令如下:

#使用API3
export ETCDCTL_API=
# 查看告警信息,告警信息一般 memberID: alarm:NOSPACE
etcdctl --endpoints=http://127.0.0.1:2379 alarm list# 获取当前版本
rev=$(etcdctl --endpoints=http://127.0.0.1:2379 endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*')
# 压缩掉所有旧版本
etcdctl --endpoints=http://127.0.0.1:2379 compact $rev
# 整理多余的空间
etcdctl --endpoints=http://127.0.0.1:2379 defrag
# 取消告警信息
etcdctl --endpoints=http://127.0.0.1:2379 alarm disarm

数据压缩完成之后数据大小和内存占用信息如下:

ETCD数据空间压缩清理 ETCD数据空间压缩清理

通过上图可以看出,压缩操作执行完之后数据库大小和内存占用率下降了很多,整体的性能也会有所提升

说明:

压缩ETCD空间也可以减少etcd程序的内存占用量,提高etcd性能,在没有问题的时候提前进行压缩也是明智的选择

通过线上实践发现还是设置自动压缩更靠谱,官方同样提供数据自动压缩方式,历史数据只保留一个小时的

详细信息可以参考官方文档: https://coreos.com/etcd/docs/latest/op-guide/maintenance.html

etcd can be set to automatically compact the keyspace with the --auto-compaction option with a period of hours:# keep one hour of history
$ etcd --auto-compaction-retention=

根据实践发现只配置auto-compaction-retention只会做碎片整理,不会实际减少空间大小; 如果需要减少大小还是需要使用etcdctl compact 和 etcdctl defrag清理空间

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,494
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,133
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297