Linux系统更换yum源

Linux简介

目前在长期稳定运行的网站服务器、处理大量数据的集群系统以及需要协同工作的环境中都大量采用Linux系统。相较于Windows系统而言,Linux系统具有以下优势:

1.稳定且有效率 2.免费或少许费用 3.漏洞少且快速修补 4.多任务多用户 5.更加安全的用户及文件权限策略 6.适合小内核程序的嵌入系统 7.相对不耗资源

图片

常见的Linux系统有如下几种:

红帽企业版(RedHat Enterprise Linux):RHEL是全世界内使用最广泛的Linux系统。

社区企业操作系统(Communicity Enterprise Operating System, CentOS ):RHEL重新编译发布的免费Linux系统。

Fedora:红帽公司发布的桌面版系统套件。

openSUSE:德国的一款著名Linux系统。

Gentoo:具有极高的自定制性,操作复杂。

Debian:稳定性、安全性强,可以良好地支持各种硬件架构。

Ubuntu:对新款硬件具有极强的兼容能力。

然而没有注册的RHEL是无法使用yum来安装软件的,为此需要将yum源更换成CentOS的免费源来解决包的依赖问题。

更换yum源

打开虚拟机(作者的红帽是装在虚拟机上的)终端执行

rpm -qa | grep yum

系统将会显示自带的yum源,
删除系统自带的yum组件

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

进入网易163源镜像地址,在路径centos/7/os/x86_64/Packages/下载(可以在物理机上下载或者在虚拟机上使用wget下载)python-iniparse-0.4-9.el7.noarch、python-iniparse-0.4-9.el7.noarch、yum-3.4.3-161.el7.centos.noarch、yum-metadata-parser-1.1.4-10.el7.x86_64、yum-plugin-fastestmirror-1.1.31-50.el7.noarch这五个包。

安装软件包

rpm -ivh yum-*
# 此时会报依赖的错误
rpm >= 0:4.11.3-35 is needed by yum-3.4.3-161.el7.centos.noarch

下载rpm-4.11.3-35.el7.x86_64包并重新安装

rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps
rpm -ivh yum-*

更新yum源文件,可以下载使用163的yum源文件CentOS6-Base-163,放在/etc/yum.repo.d目录下

vim /etc/yum.repos.d/CentOS-Base.repo

内容如下,将$releasever改成7即可

# 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
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-7 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/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/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-7 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/7/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

清除yum缓存

yum clean all
# 生成缓存
yum makeche
# 查看新源
yum repolist
yum repolist
repo id                      repo name                             status
!base/x86_64                 CentOS-$7 - Base - 163.com             8,652
!extras/x86_64               CentOS-$7 - Extras - 163.com           275
!updates/x86_64              CentOS-$7 - Updates - 163.com          1,707
repolist: 10,634

yum源已更换成功,下面就可以自由使用yum安装软件啦。

附:本文所需rpm及repo
提取码:rp3l

参考:

Linux就该这么学

https://blog.youkuaiyun.com/eddy_chan/article/details/54728385

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值