在 CentOS 上安装 MongoDB 时出现 Yum 错误?

在 CentOS 上安装 MongoDB 时出现 Yum 错误?

我正在使用 Centos 6.6 (x86_64) 尝试安装可用的最稳定的 mongodb 版本。但我遇到了这个错误(这可能看起来重复,但以前的答案都不适合我)

[root@localhost home]# sudo yum install -y mongodb-org
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * extras: ftp.iitm.ac.in
 * updates: centos.01link.hk
http://repo.mongodb.org/yum/redhat/%24releaserver/mongodb-org/3.0/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: mongodb-org-3.0. Please verify its path and try again

我的仓库:

vim /etc/yum.repos.d/mongodb-org-3.0.repo

[mongodb-org-3.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releaserver/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1

尝试过

yum clean all
yum check
yum erase apf
yum erase upgrade 

也尝试过

sudo sed -i 's/https/http/g' /etc/yum.repos.d/mongodb-org-3.0.repo

我的 yum.conf

[root@localhost home]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[root@localhost home]# 

请帮我解决这个问题!

我还设置了 SELinux=permissive 修复了 sim 指出的错误后,我收到以下错误

[root@localhost Hubatrix]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base extras mongodb-org-3.0 updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@localhost Hubatrix]# cat /etc/yum.repos.d/mongodb-org-3.0.repo
[mongodb-org-3.0]
name=MongoDB Repository 
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/repodata/repomd.xml
gpgcheck=0
enabled=1

[root@localhost Hubatrix]# sudo yum install -y mongodb-org
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
base                                                                                                                          | 3.7 kB     00:00     
base/primary_db                                                                                                               | 4.6 MB     01:21     
extras                                                                                                                        | 3.4 kB     00:00     
extras/primary_db                                                                                                             |  31 kB     00:00     
https://repo.mongodb.org/yum/redhat/6/mongodb-org/3.0/x86_64/repodata/repomd.xml/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: mongodb-org-3.0. Please verify its path and try again

答案1

该错误非常清楚yum

http://repo.mongodb.org/yum/redhat/%24releaserver/mongodb-org/3.0/x86_64/repodata/repomd.xml:[Errno 14] PYCURL ERROR 22 -“请求的 URL 返回错误:404 未找到”

该 URL 的另一端没有可供yum下载的文件,因此出现 404。将该 URL 放入浏览器中,然后开始导航以查看实际存在哪些文件。

这是我浏览他们的存储库时的正确 URL:

我怀疑他们移动了一些东西,但没有重新生成repomd.xml 文件。您可以通过手动下载软件包然后使用yum install ..安装来解决此问题。

打字错误

但我认为您的存储库文件中有一个拼写错误:

基本网址=https://repo.mongodb.org/yum/redhat/$releaserver/mongodb-org/3.0/x86_64/

应该是这样的:

基本网址=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/

答案2

如果您的存储库配置很脏,就会发生这种情况。

尝试这个

sudo rm -rf /etc/yum.repos.d/mongod*
sudo yum clean all

然后再次创建repo

sudo vi /etc/yum.repos.d/mongodb-org-3.4.repo

然后添加这个:

[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

然后运行以下命令:

sudo yum install -y mongodb-org

答案3

我通过删除/$releaserver并替换链接中的 7Server解决了此问题http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/,因此请尝试用此更改替换该链接。

答案4

清理缓存对我有用:

sudo yum clean all

相关内容