Delete data folder

I am experimenting, I got some bad data loaded on to elasticsearch so thought to reload and deleted the path.data folder. The command rm -rf * removed many things but

ls: cannot access global-12.st: No such file or directory
ls: cannot access node-0.st: No such file or directory
total 0
?????????? ? ? ? ?            ? global-12.st
?????????? ? ? ? ?            ? node-0.st

I am unable to chown also. Please help me to delete these folders.

Also tried to restart elasticsearch thinking it could have a temporary status. But elasticsearch didn't start and threw following exception :

org.elasticsearch.bootstrap.StartupException: ElasticsearchException[java.io.IOException: failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/node-0.st]]; nested: IOException[failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/node-0.st]]; nested: NoSuchFileException[/home/elk/elasticsearch/data/nodes/0/_state/node-0.st];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.3.2.jar:6.3.2]
Caused by: org.elasticsearch.ElasticsearchException: java.io.IOException: failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/node-0.st]

You should never delete the path.data directory from an active Elasticsearch installation, that will likely cause data loss. The only time I've done so is when I've stopped all nodes to install a new cluster and don't want any old data to remain. The path.data directory is both where your data resides but also the cluster state.

If you want to erase "bad data" you should instead do a Delete Index on the "bad" index. That way you leave the data directory, with its system indices and cluster information, safe and untouched.

I'm not sure what happened in your situation but I would probably start from scratch and install a new copy of Elasticsearch, erasing all traces of the old, broken one.

What I did was use a different path for the data. But just wondering if we can delete it as production should not have junk in it.

Oh, I see. Well, if you've changed the value of path.data and restarted the node so that it uses the new path, the old data directory is just like any other directory and can be deleted.

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