安装Elasticsearch 7失败:依赖冲突问题求助
Hey there, let's work through the problems you ran into while upgrading Elasticsearch from 6 to 7 using RPM packages. I notice two key issues in your output: a GPG signature warning and a dependency conflict error. Here's how to resolve them and complete the upgrade properly.
1. First, Fix the GPG Signature Warning
That NOKEY warning pops up because your system doesn't recognize Elastic's official signing key. Let's import it first to avoid security warnings and potential issues later:
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
2. Resolve the Dependency Conflict Error
The error elasticsearch < 7.0.0 is obsoleted by elasticsearch-0:7.0.0-1.x86_64 happens because you used rpm --install—this command is for fresh installs, not upgrades. Since you already have Elasticsearch 6 installed, you need to use the upgrade flag instead.
Option 1: Direct Upgrade (Recommended)
Use the -Uvh flag to upgrade your existing installation. This will replace the old version while preserving your configuration files (though you’ll want to check for breaking changes in ES7 afterward):
sudo rpm -Uvh elasticsearch-7.0.0-x86_64.rpm
Option 2: Uninstall Old Version First (If Upgrade Fails)
If the direct upgrade hits unexpected snags, you can uninstall the old version first—make sure to back up your data and config files first!:
- Stop the Elasticsearch service:
sudo systemctl stop elasticsearch - Back up your data directory (default is
/var/lib/elasticsearch) and config file (/etc/elasticsearch/elasticsearch.yml):sudo cp -r /var/lib/elasticsearch /var/lib/elasticsearch_backup sudo cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.backup - Uninstall the old version:
sudo rpm -e elasticsearch - Install the new RPM:
sudo rpm --install elasticsearch-7.0.0-x86_64.rpm
3. Post-Upgrade Steps
After installing ES7:
- Review your
elasticsearch.ymlfile—ES7 has several breaking changes from ES6 (e.g., removedtypemappings, adjusted network settings). You’ll need to update any deprecated settings. - Start the Elasticsearch service and check its status:
sudo systemctl start elasticsearch sudo systemctl status elasticsearch - Verify the upgrade worked by checking the version:
curl -XGET 'http://localhost:9200/'
Quick Recap of Your Original Issue
Your core problem was using rpm --install instead of rpm -Uvh for an upgrade. The RPM installer saw the existing ES6 package and threw a conflict because ES7 obsoletes all older versions. Adding the upgrade flag tells RPM to replace the old package instead of trying to install alongside it.
内容的提问来源于stack exchange,提问作者Andy Bajka

