如何将弹性搜索索引安全地移动到Linux中的另一个挂载? [英] How can I safely move Elasticsearch indices to another mount in Linux?

查看:166
本文介绍了如何将弹性搜索索引安全地移动到Linux中的另一个挂载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Ubuntu 机器中,我有一些索引实际上导致了一些空间问题。这些指标每天都在不断增长。

I'm having a number of indices which are actually causing some space issues at the moment in my Ubuntu machine. The indices keep growing on a daily basis.

所以我想把它移动到另一个装载目录,显然有更多的空间。我该如何安全地这样做?

So I thought of moving it to another mount directory which has more space apparently. How can I do this safely?

我必须确保现有的ES 索引 Kibana 图在做动作之后就足够安全了。

And I have to make sure that the existing ES indices and the Kibana graphs would be safe enough after the doing the move.

我所做的:遵循这个 SO ,并将 Elasticsearch 数据目录移动到目录(/ data / es_data)我需要,但在我这样做之后,我无法查看我现有的索引加上 Kibana 我创建的图表和仪表板

What I did: Followed this SO and moved my data directory of Elasticsearch somehow to the directory (/data/es_data) I needed, but after I did that, I couldn't view my existing indices plus the Kibana graphs and dashboards which I created as well.

我做错了?任何帮助都可以赞赏。

Am I doing something wrong? Any help could be appreciated.

推荐答案

FWIW如果是我,我会停止弹性搜索kibana(& logstash如果这是群集中唯一的弹性搜索节点),然后将旧数据目录移动到新位置,方法如下:

FWIW If it were me, I would stop elasticsearch & kibana (& logstash if this is the only elasticsearch node in the cluster) then move the old data dir to a new location out of the way:

sudo mv /var/lib/elasticsearch /var/lib/elasticsearch-old

然后设置新的卷(其应该至少比您在磁盘上的索引的大小大15%,因为弹性搜索将不会在具有少于15%可用空间的磁盘上创建新的索引)与文件系统,并找出它的UUID并准备挂载它:

Then set up the new volume (which should be at least 15% larger than the size of the indexes you have on disk as elasticsearch won't create new indexes on a disk with less than 15% free space) with a file system and find out it's UUID and get ready to mount it:

sudo fdisk /dev/sdX # New volume, use all the space
sudo mkfs.ext4 /dev/sdX1
ls -la /dev/disk/by-uuid/ | grep /dev/sdX1 # Or forget the grep and manually look for it

然后将以下内容添加到您的/ etc / fstab,用以前的命令替换为UUID:

Then add the following to your /etc/fstab, replacing with the UUID from previous command:

UUID=<RESPONSE> /var/lib/elasticsearch  ext4 defaults 0 0

使新目录成为旧的目录,它可能想要chowning(我认为所有者应该是弹性搜索,但您可以通过检查旧文件夹的所有权来确认),并且您要从旧的复制内容:

Make the new directory as the old one is gone, it probably wants chowning (I assume the owner should be elasticsearch but you can confirm by checking ownership of the old folder) and you want to copy the content from the old one:

sudo mkdir /var/lib/elasticsearch
sudo chown -R elasticsearch: /var/lib/elasticsearch
cp -rp /var/lib/elasticsearch-old/* /var/lib/elasticsearch

一旦所有的东西都完成复制,你应该可以开始弹性搜索备份,它应该找到索引,因为它们没有移动,配置不需要更新。

Once everything has finished copying across you should then be able to start elasticsearch back up, it should find the indexes as they haven't moved, config doesn't need updating.

一旦你开心,一切都正常工作,你可以删除/ var / lib / elasticsearch-old并回收你的空间。否则您可以恢复旧数据,并且应该继续工作。

Once you're happy that everything is working you can delete /var/lib/elasticsearch-old and reclaim your space. Failing that you can revert to the old data and it should continue to work.

这篇关于如何将弹性搜索索引安全地移动到Linux中的另一个挂载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆