Redhat7更改网易yum源
说明
之前写了一篇关于Redhat6
更换Yum源的文章,时隔已久很多包都变了,正好最近搭建环境需要用到Redhat7.3
所以就再记录一下如何更换为国内最新最常用的yum源。
操作步骤
1.卸载系统自带包
[root@rhl73 ~]# rpm -qa | grep yum
- 查出以下包:
yum-utils-1.1.31-40.el7.noarch
yum-langpacks-0.4.2-7.el7.noarch
yum-rhn-plugin-2.0.1-6.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-150.el7.noarch
- 执行卸载
rpm -e yum-utils-1.1.31-40.el7.noarch --nodeps
rpm -e yum-langpacks-0.4.2-7.el7.noarch --nodeps
rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
rpm -e yum-rhn-plugin-2.0.1-6.el7.noarch --nodeps
rpm -e yum-3.4.3-150.el7.noarch --nodeps
# 或者执行
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa | grep python-urlgrabber|xargs rpm -e --nodeps
注意
:涉及到版本号的地方以你实际环境为准。
2.下载新的 yum 软件包
- 此处我就下载到repo目录下了。
# 进入repo目录
cd /etc/yum.repos.d
# 备份一下旧的repo
mv redhat.repo redhat.repo.bak
# 下载 yum 的相关安装包
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
# 下载 yum 安装包相关的依赖包
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpm
3.安装新yum
注意先装2个依赖包:
rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm
rpm -ivh rpm-4.11.3-45.el7.x86_64.rpm --force
接下来装其他:
rpm -ivh yum*
4.创建新的repo文件
还是在repo目录/etc/yum.repos.d
下,创建:CentOS-Base.repo
vim 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-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
5.生成缓存
依次执行命令:
yum clean all
yum makecache
测试更新wget
: