Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move elasticsearch data directory?

I have a default installation of Elasticsearch. It seems to be storing it's data in

/var/lib/elasticsearch/elasticsearch/nodes 

So two questions:

If I want to move my data to another location on the same machine (let's say /foo/bar for example)

1) What level in the /var/lib/elasticsearch tree do I copy? and

2) What is the relevant setting for path.data in elastisearch.yml?

like image 484
Chris Curvey Avatar asked Feb 02 '16 02:02

Chris Curvey


People also ask

Where is Elasticsearch data stored?

According to the documentation the data is stored in a folder called "data" in the elastic search root directory.

How is Elasticsearch data stored?

Elasticsearch stores data as JSON documents. Each document correlates a set of keys (names of fields or properties) with their corresponding values (strings, numbers, Booleans, dates, arrays of values, geolocations, or other types of data).


2 Answers

A. You need to move the elasticsearch folder, i.e. that's the folder which bears the same name as your cluster.name configured in the elasticsearch.yml file.

B. You need to modify the path.data setting in the elasticsearch.yml file to the new folder you've moved the data to.

So, say you are currently using /var/lib/elasticsearch and you want to move the data folder to /foo/bar, here is what you need to do:

> mv /var/lib/elasticsearch /foo/bar 

Then in elasticsearch.yml modify path.data to:

path.data: /foo/bar 

You'll end up with your data being stored in /foo/bar/elasticsearch instead of /var/lib/elasticsearch. Make sure that the elasticsearch process can access your new folder.

like image 152
Val Avatar answered Sep 18 '22 14:09

Val


I want to add an annoying problem that I encountered when I was doing @Val's helpful guidance. After I did:

> mv /var/lib/elasticsearch /foo/bar 

I set the

path.data: /foo/bar

But Elasticsearch did not run correctly. For example xpack security (formarly shield) authantication password turned back to its default "changeme". And also when I want to list indices, nothing shown up. Then I set the

path.data: /foo/bar/elasticsearch/

The last slash at the end of the "elasticsearch" is important I think. May be I am confusing but it solved my problem.

like image 44
Ceyhun Avatar answered Sep 20 '22 14:09

Ceyhun