Delete data folder

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

ls: cannot access No such file or directory
ls: cannot access No such file or directory
total 0
?????????? ? ? ? ?            ?
?????????? ? ? ? ?            ?

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[ failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/]]; nested: IOException[failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/]]; nested: NoSuchFileException[/home/elk/elasticsearch/data/nodes/0/_state/];
        at org.elasticsearch.bootstrap.Elasticsearch.init( ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute( ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute( ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling( ~[elasticsearch-cli-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.Command.main( ~[elasticsearch-cli-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main( ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main( ~[elasticsearch-6.3.2.jar:6.3.2]
Caused by: org.elasticsearch.ElasticsearchException: failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/]

You should never delete the 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 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 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.