卸载Elasticsearch时遭遇RPM命令执行异常问题求助
Hey there, let's break down what's going on here and fix this quickly:
The Root Cause
You ran into two straightforward issues here:
- When you tried
rpm -i elasticsearch-6.2.3.rpm, the system correctly flagged that the package was already installed—makes sense, since your goal was to uninstall it in the first place. - The real hangup is your uninstall command:
rpm --erase elasticsearch-6.2.3.rpmtargets the local RPM file name, butrpm --eraserequires the name of the already installed package (not the disk file). That's exactly why you got the "package is not installed" error.
Step-by-Step Fix
Confirm the exact installed package name
Run this command to list all Elasticsearch packages currently on your system:rpm -qa | grep elasticsearchFrom your original error message, we already know this will output something like
elasticsearch-6.2.3-1.noarch—that's the actual package name you need to target.Run the correct uninstall command
Use the package name from the previous step (not the .rpm file name) withrpm --erase:rpm --erase elasticsearch-6.2.3-1.noarchIf there's only one Elasticsearch package installed, you can simplify it to:
rpm --erase elasticsearchVerify the uninstallation
Double-check that the package is gone by running the grep command again:rpm -qa | grep elasticsearchIf you get no output, Elasticsearch has been successfully uninstalled.
Quick Extra Tip
If you ever need to reinstall or upgrade Elasticsearch later, use rpm -Uvh elasticsearch-6.2.3.rpm instead of rpm -i—the -U flag tells RPM to upgrade the package if it's already installed, which avoids the "already installed" warning you saw earlier.
内容的提问来源于stack exchange,提问作者Stuttgarter Hofbrau

