查看etc文件第一列和第三列(Etcd的db文件很大)

Etcd运行一段时间后,发现db占用的空间很大,将etcd内的数据导出,发现只有180多k,为什么会占用这么多空间呢?,我来为大家讲解一下关于查看etc文件第一列和第三列?跟着小编一起来看一看吧!

查看etc文件第一列和第三列(Etcd的db文件很大)

查看etc文件第一列和第三列

Etcd运行一段时间后,发现db占用的空间很大,将etcd内的数据导出,发现只有180多k,为什么会占用这么多空间呢?

[root@node3snap]#pwd /var/lib/etcd/member/snap [root@node3snap]#ll-lh total509M -rw-r--r--1rootroot390KJun1412:31000000000001a198-0000000001357eb0.snap -rw-r--r--1rootroot390KJun1413:11000000000001a198-000000000135a5c3.snap -rw-r--r--1rootroot390KJun1413:52000000000001a198-000000000135ccd5.snap -rw-r--r--1rootroot390KJun1414:29000000000001a198-000000000135f3e6.snap -rw-r--r--1rootroot391KJun1414:50000000000001a19a-0000000001361af7.snap -rw-------1rootroot523MJun1415:05db

看一下一下etcd官方的说明

since etcd keeps an exact history of its keyspace, this history should be periodically compacted to avoid performance degradation and eventual storage space exhaustion。

意思就是etcd保存了keys的历史信息,所以会占用的空间比较大,需要周期的进行压缩,以避免出现性能下降和存储资源耗尽,继续看官方说明

After compacting the keyspace, the backend database may exhibit internal fragmentation. Any internal fragmentation is space that is free to use by the backend but still consumes storage space. The process of defragmentation releases this storage space back to the file system. Defragmentation is issued on a per-member so that cluster-wide latency spikes may be avoided

大概的意思是定期压缩etcd 的db后,虽然释放了一些空间,但是只能被etcd使用,并不能被宿主机使用,根据上面的解释,如果不是etcd突然释放大量keys或者etcd需求大量磁盘的场景下,只需要执行compact就可以了,执行defrag是对硬盘的一些操作而已。

解决方法:

etcd的启动参数增加ETCD_AUTO_COMPACTION_RETENTION=1,如果需要释放硬盘空间,可以执行defrag命令,如下所示:

[root@node2snap]#etcdctl--endpointshttp://10.110.17.119:2379defrag Finisheddefragmentingetcdmember\[http://10.110.17.119:2379\] [root@node2snap]#ll-lh total3.0M -rw-r--r--1rootroot390KJun1413:08000000000001a198-000000000135a24e.snap -rw-r--r--1rootroot390KJun1413:48000000000001a198-000000000135c961.snap -rw-r--r--1rootroot390KJun1414:27000000000001a198-000000000135f072.snap -rw-r--r--1rootroot390KJun1414:48000000000001a19a-0000000001361783.snap -rw-r--r--1rootroot390KJun1415:09000000000001a19b-0000000001363e96.snap -rw-------1rootroot18MJun1415:20db

附:

Etcd默认的db 配额是2GB,etcd主要用于存储元数据,这个一般就够用了。

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页