昨天接到客户投诉说ES数据目录已达到100%了,当时第一想法监控组怎么监控的80%报警为什么没有监控出来,经问监测组是几天前接到报警,并忽略了,我当时那个崩溃,并有想骂人的冲动,这是现网,不是测试时环境,竟然有这么不负责的同事我也是醉的,我登录服务器一看磁盘空间最糟的100%,另几个99%,刚搭建两个月的集群出现空间不足,当时说没有这么大的数据量,我自己给自己挖了一个大坑,把数据存在一个磁盘上。
当时能想到的两个方案:
方案一把其他磁盘做一个大的LVM卷组,之后 做一个大的盘,好处处理方便,但是缺点会导致数据集中存储,会影响后续的插入性能和查询性能,当时就把此方案作为万不得已的方案了。
方案二:通过配置path.logs 配置多个磁盘,但是由于对ES了解不是很深,紧会搭建和简单的使用,此方案在我理解的层面上应该是可行的,但是客户说给出可行的证据,无奈只能在搭建一个ES集群进行测试,罗列证据了。(最终是用该方案解决的)
测试datanode10 放两个目录/data01,/data02目录下:看如下目录结构记清楚
[root@datanode10 nodes]# tree /data01/es5/data/nodes/0/indices/
/data01/es5/data/nodes/0/indices/
├── _2nXGRdBQWqEtALngH_xaQ
│ ├── 0
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.tlog
│ │ └──translog.ckp
│ ├── 1
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.tlog
│ │ └──translog.ckp
│ ├── 2
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.tlog
│ │ └──translog.ckp
│ ├── 3
│ │ ├──index
│ │ │ ├── _0.cfe
│ │ │ ├── _0.cfs
│ │ │ ├── _0.si
│ │ │ ├── segments_4
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-2.ckp
│ │ ├──translog-2.tlog
│ │ ├──translog-3.tlog
│ │ └──translog.ckp
│ ├── 4
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.tlog
│ │ └──translog.ckp
│ └── _state
│ └──state-12.st
└── ZytkImACR4CkB53vG4XyNw
├── 0
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 3
│ ├──index
│ │ ├──_0.cfe
│ │ ├──_0.cfs
│ │ ├──_0.si
│ │ ├──segments_1
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
└── _state
└── state-7.st
32 directories, 53 files
[root@datanode10 nodes]#
[root@datanode10 nodes]# tree /data02/es5/data/nodes/0/indices/
/data02/es5/data/nodes/0/indices/
├── _2nXGRdBQWqEtALngH_xaQ
│ └── _state
│ └──state-12.st
└── ZytkImACR4CkB53vG4XyNw
├── 1
│ ├──index
│ │ ├──segments_1
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 2
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 4
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
└── _state
└── state-7.st
16 directories, 17 files
[root@datanode10 nodes]# tree /data01/es5/data/nodes/0/indices/
/data01/es5/data/nodes/0/indices/
├── _2nXGRdBQWqEtALngH_xaQ
│ ├── 0
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-2.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.ckp
│ │ ├──translog-2.tlog
│ │ ├──translog-3.tlog
│ │ └──translog.ckp
│ ├── 1
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-2.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.ckp
│ │ ├──translog-2.tlog
│ │ ├──translog-3.tlog
│ │ └──translog.ckp
│ ├── 2
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-2.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.ckp
│ │ ├──translog-2.tlog
│ │ ├──translog-3.tlog
│ │ └──translog.ckp
│ ├── 3
│ │ ├──index
│ │ │ ├── _0.cfe
│ │ │ ├── _0.cfs
│ │ │ ├── _0.si
│ │ │ ├── segments_4
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-2.st
│ │ └──translog
│ │ ├──translog-2.ckp
│ │ ├──translog-2.tlog
│ │ ├──translog-3.ckp
│ │ ├──translog-3.tlog
│ │ ├──translog-4.tlog
│ │ └──translog.ckp
│ ├── 4
│ │ ├──index
│ │ │ ├── segments_2
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-2.st
│ │ └──translog
│ │ ├──translog-1.ckp
│ │ ├──translog-1.tlog
│ │ ├──translog-2.ckp
│ │ ├──translog-2.tlog
│ │ ├──translog-3.tlog
│ │ └──translog.ckp
│ └── _state
│ └──state-21.st
└── ZytkImACR4CkB53vG4XyNw
├── 0
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 1
│ ├──index
│ │ ├──segments_3
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 2
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 3
│ ├──index
│ │ ├──_0.cfe
│ │ ├──_0.cfs
│ │ ├──_0.si
│ │ ├──segments_3
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-2.ckp
│ ├──translog-2.tlog
│ ├──translog-3.tlog
│ └──translog.ckp
├── 4
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-0.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
└── _state
└── state-16.st
44 directories, 80 files /data02里的分片都自动同步到/data01上了
You have new mail in /var/spool/mail/root
[root@datanode08 opt]# tree /data01/es5/data/nodes/0/indices/
/data01/es5/data/nodes/0/indices/
├── _2nXGRdBQWqEtALngH_xaQ
│ ├── 0
│ │ ├──index
│ │ │ ├── segments_4
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.tlog
│ │ └──translog.ckp
│ ├── 1
│ │ ├──index
│ │ │ ├── segments_4
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.tlog
│ │ └──translog.ckp
│ ├── 2
│ │ ├──index
│ │ │ ├── segments_4
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.tlog
│ │ └──translog.ckp
│ ├── 3
│ │ ├──index
│ │ │ ├── _0.cfe
│ │ │ ├── _0.cfs
│ │ │ ├── _0.si
│ │ │ ├── segments_6
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.tlog
│ │ └──translog.ckp
│ ├── 4
│ │ ├──index
│ │ │ ├── segments_4
│ │ │ └── write.lock
│ │ ├──_state
│ │ │ └── state-1.st
│ │ └──translog
│ │ ├──translog-1.tlog
│ │ └──translog.ckp
│ └── _state
│ └──state-13.st
└── ZytkImACR4CkB53vG4XyNw
├── 0
│ ├──index
│ │ ├──segments_1
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-1.ckp
│ ├──translog-1.tlog
│ ├──translog-2.tlog
│ └──translog.ckp
├── 1
│ ├──index
│ │ ├──segments_2
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-1.ckp
│ ├──translog-1.tlog
│ ├──translog-2.tlog
│ └──translog.ckp
├── 2
│ ├──index
│ │ ├──segments_1
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-1.ckp
│ ├──translog-1.tlog
│ ├──translog-2.tlog
│ └──translog.ckp
├── 3
│ ├──index
│ │ ├──_0.cfe
│ │ ├──_0.cfs
│ │ ├──_0.si
│ │ ├──segments_5
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-1.tlog
│ └──translog.ckp
├── 4
│ ├──index
│ │ ├──segments_1
│ │ └──write.lock
│ ├──_state
│ │ └──state-1.st
│ └──translog
│ ├──translog-1.ckp
│ ├──translog-1.tlog
│ ├──translog-2.tlog
│ └──translog.ckp
└── _state
└── state-16.st
44 directories, 66 files
结论 datanode10 机器上 /data02里的分片都自动同步到/data01上了,且数据被打散到机器datanode08机器的/data01磁盘上,实现了自动平衡数据功能。