如何安装 CentOS 存储库?

如何安装 CentOS 存储库?

我遇到的情况是,应该存在于/etc/yum.repos.d/(如centos-base.repo)中的库存回购文件不存在。我需要安装它们。我确信这很简单,但经过几个小时的搜索,似乎我没有正确搜索它。

基本上我有一个带有自定义存储库的服务器,但对我来说毫无用处。我需要 epel,epel 也需要centos-base.repo。我还需要 postgres 存储库。

答案1

在以下目录中创建一个名为 Centos-Base.repo 的文件 /etc/yum.repos.d

vi /etc/yum.repos.d/Centos-Base.repo

将以下信息放入文件中:

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=2

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=2

保存并运行。

yum clean all 

然后跑。

yum repolist

如果您将其复制到 putty via 中vi,请确保仔细检查换行符。我必须修复复制粘贴过程中发生的一些编辑。

答案2

您可以使用以下命令手动重新安装centos-release-rpm:

rpm -ivh --replacepkgs --replacefiles centos-release*.rpm

答案3

对我来说,问题通过清理所有存储库并添加新存储库来解决这里考虑到我的 CentOS 版本:

# yum clean all

# rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

# rpm -Uvh http://dl.atrpms.net/all/atrpms-repo-7-7.el7.x86_64.rpm

# rpm -Uvh http://repo.webtatic.com/yum/el7/webtatic-release.rpm

相关内容