Ubuntu 14.04 清除 ElasticSeach

Ubuntu 14.04 清除 ElasticSeach

我在 Ubuntu 14.04 上安装了 elasticsearch 6.6.1,但遇到了一些困难。我希望完全卸载 elasticsearch 并安装旧版本。当我运行

sudo apt-get --purge autoremove elasticsearch

弹出错误信息:

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

我不确定 elasticseach.service 是否可用,因为我认为我没有该文件。我也已经使用过

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

我尝试重新安装 elasticsearch,然后使用卸载,但使用 apt-get install elasticsearch 出现了类似的错误:

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)

在我意识到我应该使用 apt-get 来删除 elasticsearch 之前,我不确定我是否搞砸了。任何帮助都非常感谢!

答案1

我沿着错误信息走得很艰难,但最终我使用了

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

然后删除这些文件。这解决了一直出现的 dpkg 错误 1。使用后sudo apt-get updateelasticsearch 似乎不再在服务器上。

这是这里发布的最后一个解决方案https://itsfoss.com/dpkg-returned-an-error-code-1/如果您遇到类似的卸载错误,您可以先尝试其他解决方案。

相关内容