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?
According to the documentation the data is stored in a folder called "data" in the elastic search root directory.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With