在做linux配置yum源的时候,笔者从网上找的教程, 然后发现各种报错,最后总结了一下,比较好用的一种方法是,复制一台yum源是正常的linux虚拟机对应的
/etc/yum.repos.d
目录下的文件,以下为笔者/etc/yum.repos.d目录下的文件
把该目录的文件全部清空,然后创建以上四个文件,把下方文件的内容拷入
CentOS-Base.repo文件的内容如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should usethis forCentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can trythe
# remarkedout baseurl=line instead.
#
#
[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/
gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#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/
gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#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/
gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#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/
gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
CentOS-Debuginfo.repo内容如下:
# CentOS-Debug.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should usethis forCentOS updates
# unless you are manually picking other mirrors.
#
# All debug packagesfrom all the various CentOS-7releases
# are merged into a single repo, split by BaseArch
#
# Note: packagesinthe debuginfo repo are currently not signed
#
[debug]
name=CentOS-7 -Debuginfo
baseurl=http://debuginfo.centos.org/7/$basearch/
gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
enabled=0#
CentOS-Sources.repo文件内容如下:
# CentOS-Sources.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should usethis forCentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can trythe
# remarkedout baseurl=line instead.
#
#
[base-source]
name=CentOS-$releasever -Base Sources
baseurl=http://vault.centos.org/centos/$releasever/os/Source/
gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates-source]
name=CentOS-$releasever -Updates Sources
baseurl=http://vault.centos.org/centos/$releasever/updates/Source/
gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras-source]
name=CentOS-$releasever -Extras Sources
baseurl=http://vault.centos.org/centos/$releasever/extras/Source/
gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus-source]
name=CentOS-$releasever -Plus Sources
baseurl=http://vault.centos.org/centos/$releasever/centosplus/Source/
gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
CentOS-Vault.repo文件内容如下:
# placeholder fornow
# #
# CentOS Vault contains rpmsfrom older releases in the CentOS-7# tree.
#
# Atthis point in 7.0.1406, we have no older release
根据里边的代码内容来看,CentOS-Vault.repo文件似乎没有什么作用,应该可以不需要该文件,笔者也未对其进行验证,如有兴趣的可以自己不加该文件进行验证是否能正确配置yum源。
最后通过以下命令进行验证是否成功设置yum源
yum clean all
yum makecache
yum update
yum repolist
yum update对应的命令截图过长,截图部分