红帽7如何换用yum源

小编亲身经历告诉你如何换yum源

虽然redhat系统安装好默认带有yum,但是因为redhat不像CentOs的yum源免费供用户使用,所以需要换源才能使用。对于小白来说,找到了各种换源方式,但是貌似许多都有着问题,所以我亲自试过的方法分享给大家。

基本的换源流程是:

首先要删除redhat系统自带的yum软件包;

然后根据需要下载所需要的软件包;

最后新建repo配置文件,配置环境。

1、查看系统已经安装的yum源

rpm -qa| grep yum

2、删除原来的yum安装包

rpm -aq | grep yum | xargs rpm -e --nodeps

3、查看是否删除yum源

rpm -qa| grep yum

4、下载需要的安装包

小编提供了国内几个免费的yum源的网站
*
1、 阿里云网络源地址:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

2、网易163网络源地址:http://mirrors.163.com/

3、CentOS网络源地址:http://centos.ustc.edu.cn/centos/

进入网站后可以使用 CTRL+F 输入关键字查找对应的安装包即可

或者采用下面的方式直接在虚拟机上下载

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.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-45.el7.noarch.rpm

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rp

  • 小编建议可以先在官网上把需要用到的安装包下载好,然后从windows上传到虚拟机中进行安装,这种方式对于小白来说比较容易,不容易出错。

5、安装

    rpm -ivh yum-*

如果安装过程中遇到错误,再下载安装包然后安装就行。

6、新建repo配置文件

vim /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 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

7、清理缓存

yum -y clean all
yum -y makecache

以上就是redhat的换国内yum源的方法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值