RHEL7.4配置CentOS Yum(阿里云)

由于没有购买RedHat的服务,所以RHEL7.3在yum更新的时候由于没有更新源造成更新失败,于是把RedHat的更新源设置成阿里的更新源。
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

运行后,在/etc/yum.repos.d/目录生成CentOS-Base.repo文件。
运行yum makecache生成缓存。
RHEL7.4配置CentOS Yum(阿里云)_第1张图片
有报错:
http://mirrors.aliyuncs.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.

Ctrl+z,结束执行,修改CentOS-Base.repo文件。将文件中的$releasever改成7

编辑/yum.repos.d文件,将http链接中的$releasever修改为7.4.1708
# cd /etc/yum.repos.d/
# vim CentOS-Base.repo
光标放置在对应行,使用下面命令,将$releasever替换为7.4.1708
:s /$releasever/7.4.1708

[root@bogon yum.repos.d]# cat 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 use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/os/$basearch/
http://mirrors.aliyuncs.com/centos/7.4.1708/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/updates/$basearch/
http://mirrors.aliyuncs.com/centos/7.4.1708/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/extras/$basearch/
http://mirrors.aliyuncs.com/centos/7.4.1708/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/7.4.1708/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/7.4.1708/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

运行 yum clean all 清除原有缓存
运行 yum makecache 获取yum列表



你可能感兴趣的:(Linux)