Data Path Change


I am interested in best practices for changing the default data and log path in the elasticsearch.yml file. I have found various references on the web about how this is done (a simple copy of the data as well as a snapshot restore to a new path) but it is unclear to me which is the recommended way from Elastic. Is there a definitive best practice on how to change the default data and log path?

Thank you.

Welcome to our community! :smiley:

There's not, no. As long as the node is shut down you can move it, then update the config and then restart.


Thank you for the response and the welcome!

So my plan of action will be the following based on my current understanding:

  1. create new data storage location i.e. /foo/bar/log and /foo/bar/lib
  2. chown elasticsearch:elasticsearch /foo/bar/log and /foo/bar/lib
  3. shutdown the single node elasticsearch.service that I want to change the path on.
  4. cp /var/lib/elasticsearch/ /foo/bar/
  5. cp /var/logs/elasticsearch/ /foo/bar/
  6. modify the elasticsearch.yml file and comment out the original path.logs and items, create new path.logs and paths.log entries to the new locations listed above.
  7. start the elasticsearch.service on the modified node.
  8. validate cluster is 'green' and searching data is functioning as expected.
  9. delete old data at old location at later time as needed/desired.

Is there anything else that I am missing from these order of operations or that I have missed completely?

Thank you.

Items 1 and 4+5 don't match and you're copying logs and data into /foo/bar/. Try cp /var/lib/elasticsearch /foo/bar/data and cp /var/logs/elasticsearch /foor/bar/logs, that way the names are clear.

I wouldn't be moving logs though to be honest, leave them in the system default location.

Understood. Thank you for the syntax error catch and recommendation.

In my case the data and logs are on an external NFS mounted storage device and that device is going away. So all data from the current nodes in the cluster needs to be 'migrated' to the new NFS storage system.

Beyond the cp example above, I am thinking that an array level migration of the data to the new storage system and then a modification of the underlying mount will be most efficient and clean. That will require a complete cluster shutdown upon cutover, but the paths and overall data structures will remain the same.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.