构建Amazon Linux 2 AMI时安装Cassandra遇Repo 404错误求助
在构建Amazon Linux 2的AMI时安装Cassandra,出现404错误导致安装失败,错误信息如下:
https://www.apache.org/dist/cassandra/redhat/311x/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
==> amazon-ebs.linux: https://www.apache.org/dist/cassandra/redhat/311x/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
==> amazon-ebs.linux: Trying other mirror.
==> amazon-ebs.linux:
==> amazon-ebs.linux:
==> amazon-ebs.linux: One of the configured repositories failed (Apache Cassandra),
==> amazon-ebs.linux: and yum doesn't have enough cached data to continue. At this point the only
==> amazon-ebs.linux: safe thing yum can do is fail. There are a few ways to work "fix" this:
==> amazon-ebs.linux:
==> amazon-ebs.linux: 1. Contact the upstream for the repository and get them to fix the problem.
==> amazon-ebs.linux:
==> amazon-ebs.linux: 2. Reconfigure the baseurl/etc. for the repository, to point to a working
==> amazon-ebs.linux: upstream. This is most often useful if you are using a newer
==> amazon-ebs.linux: distribution release than is supported by the repository (and the
==> amazon-ebs.linux: packages for the previous distribution release still work).
==> amazon-ebs.linux:
==> amazon-ebs.linux: 3. Run the command with the repository temporarily disabled
==> amazon-ebs.linux: yum --disablerepo=cassandra ...
==> amazon-ebs.linux:
==> amazon-ebs.linux: 4. Disable the repository permanently, so yum won't use it by default. Yum
==> amazon-ebs.linux: will then just ignore the repository until you permanently enable it
==> amazon-ebs.linux: again or use --enablerepo for temporary usage:
==> amazon-ebs.linux:
==> amazon-ebs.linux: yum-config-manager --disable cassandra
==> amazon-ebs.linux: or
==> amazon-ebs.linux: subscription-manager repos --disable=cassandra
==> amazon-ebs.linux:
==> amazon-ebs.linux: 5. Configure the failing repository to be skipped, if it is unavailable.
==> amazon-ebs.linux: Note that yum will try to contact the repo. when it runs most commands,
==> amazon-ebs.linux: so will have to try and fail each time (and thus. yum will be be much
==> amazon-ebs.linux: slower). If it is a very temporary problem though, this is often a nice
==> amazon-ebs.linux: compromise:
==> amazon-ebs.linux:
==> amazon-ebs.linux: yum-config-manager --save --setopt=cassandra.skip_if_unavailable=true
==> amazon-ebs.linux:
==> amazon-ebs.linux: failure: repodata/repomd.xml from cassandra: [Errno 256] No more mirrors to try.
==> amazon-ebs.linux: https://www.apache.org/dist/cassandra/redhat/311x/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
使用的Repo配置:
[cassandra] name=Apache Cassandra baseurl=https://www.apache.org/dist/cassandra/redhat/311x/ gpgcheck=1 repo_gpgcheck=1 gpgkey=https://www.apache.org/dist/cassandra/KEYS
安装步骤(此前正常执行,近期构建AMI时失败):
sudo yum install java-1.8.0-openjdk -y sudo mv /tmp/files/cassandra-repo /etc/yum.repos.d/cassandra311x.repo sudo yum clean all sudo yum update -y sudo rpm --import https://www.apache.org/dist/cassandra/KEYS sudo yum install cassandra -y
疑问:近期yum安装或Repo数据是否有变更?如何解决该问题?
原因分析
Apache Cassandra 3.11.x这类旧版本的官方RPM仓库已被归档迁移,原https://www.apache.org/dist/cassandra/redhat/311x/路径不再提供服务,从而触发404错误。
解决步骤
方法1:替换为归档仓库地址
修改Cassandra的repo配置文件/etc/yum.repos.d/cassandra311x.repo,将baseurl替换为归档仓库地址:
[cassandra] name=Apache Cassandra baseurl=https://archive.apache.org/dist/cassandra/redhat/311x/ gpgcheck=1 repo_gpgcheck=1 gpgkey=https://archive.apache.org/dist/cassandra/KEYS
之后重新执行安装命令:
sudo yum clean all sudo yum install cassandra -y
方法2:升级到受支持的Cassandra版本
若业务允许,建议升级到仍在维护的Cassandra版本(如4.x系列),其官方仓库地址仍有效。以4.1.x为例,repo配置如下:
[cassandra] name=Apache Cassandra baseurl=https://www.apache.org/dist/cassandra/redhat/41x/ gpgcheck=1 repo_gpgcheck=1 gpgkey=https://www.apache.org/dist/cassandra/KEYS
注意:升级前需确认业务兼容性,并做好数据备份。
方法3:手动下载RPM包安装
从Apache归档站点下载对应版本的Cassandra RPM包,上传到实例后执行手动安装:
sudo rpm -ivh cassandra-3.11.x-1.noarch.rpm
内容的提问来源于stack exchange,提问作者sudhakar s

