I installed elasticsearch 6.6.1 on Ubuntu 14.04 but ran into some difficulties. I wish to completely uninstall elasticsearch and install an older version. When I ran

sudo apt-get --purge autoremove elasticsearch 

An error message popped out:

Removing elasticsearch (6.6.1) ... Stopping elasticsearch service...Failed to issue method call: Unit elasticsearch.service not loaded. dpkg: error processing package elasticsearch (--remove): subprocess installed pre-removal script returned error exit status 5 Failed to issue method call: Unit systemd-sysctl.service failed to load: No such file or directory. See system logs and 'systemctl status systemd-sysctl.service' for details. ### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd sudo systemctl daemon-reload sudo systemctl enable elasticsearch.service ### You can start elasticsearch service by executing sudo systemctl start elasticsearch.service chown: cannot access ‘/var/lib/elasticsearch’: No such file or directory dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: elasticsearch 

I am not sure about the elasticseach.service as I don't think I have that file. I also already used

sudo rm -rf /var/lib/elasticsearch/ sudo rm -rf /etc/elasticsearch 

I tried to reinstall elasticsearch and then use the uninstall but using the apt-get install elasticsearch yielded a similar error:

Setting up elasticsearch (6.6.1) ... Failed to issue method call: Unit systemd-sysctl.service failed to load: No such file or directory. See system logs and 'systemctl status systemd-sysctl.service' for details. chown: cannot access ‘/var/lib/elasticsearch’: No such file or directory dpkg: error processing package elasticsearch (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: elasticsearch E: Sub-process /usr/bin/dpkg returned an error code (1) 

Before I realized I should probably use apt-get to remove elasticsearch, I am not sure if I screw up there. Any help is appreciated!

1 Answer

I followed the error messages down a rabbit hole but eventually I used

ls -l /var/lib/dpkg/info | grep -I elasticsearch 

and then removing those files. This solved the dpkg error 1 that kept appearing. After using sudo apt-get update elasticsearch no longer seems to be on the server.

This was the last solution posted from here and you can try the other solutions first if you get a similar error of uninstalling.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy