版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
在使用Linux系统时,有时候需要用到yum进行软件安装,但自带yum 工具需要注册,极大不便,这里介绍如何替换自带的yum工具,安装使用免费的yum工具。
一,卸载旧yum工具
首先查询已安装的yum相关软件包。
rpm -qa | grep yum
例如:
依次,删除软件包
-
rpm
-e
yum-utils-1
.1
.31-50
.el7
.noarch
--nodeps
-
rpm
-e
PackageKit-yum-1
.1
.5-1
.el7
.x86_64
--nodeps
-
rpm
-e
yum-langpacks-0
.4
.2-7
.el7
.noarch
--nodeps
-
rpm
-e
yum-3
.4
.3-154
.el7
.noarch
--nodeps
-
rpm
-e
yum-metadata-parser-1
.1
.4-10
.el7
.x86_64
--nodeps
-
rpm
-e
yum-rhn-plugin-2
.0
.1-9
.el7
.noarch
--nodeps
二 下载新的软件包
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/python-kitchen-
1.1.
1-
5.el7.noarch.rpm
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/python-chardet-
2.2.
1-
1.el7_1.noarch.rpm
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/yum-
3.4.
3-
161.el7.centos.noarch.rpm
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/yum-metadata-parser-
1.1.
4-
10.el7.x86_64.rpm
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/yum-utils-
1.1.
31-
50.el7.noarch.rpm
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/yum-updateonboot-
1.1.
31-
50.el7.noarch.rpm
-
wget
http:/
/mirrors.aliyun.com/centos
/7/os
/x86_64/Packages/yum-plugin-fastestmirror-
1.1.
31-
50.el7.noarch.rpm
安装新软件包:
rpm -ivh python-* rpm -ivh yum-*
三, 下载.repo文件,创建缓存
-
-
curl -o /etc/yum.repos.d/CentOS-Base.repo http:
//mirrors.aliyun.com/repo/Centos-7.repo
-
或者
-
wget -O /etc/yum.repos.d/CentOS-Base.repo http:
//mirrors.aliyun.com/repo/Centos-7.repo
修改 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 - mirrors.aliyun.com
-
failovermethod=priority
-
baseurl=http:
//mirrors.aliyun.com/centos/7/os/$basearch/
-
http:
//mirrors.aliyuncs.com/centos/7/os/$basearch/
-
http:
//mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
-
gpgcheck=
1
-
gpgkey=http:
//mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#released updates
-
[updates]
-
name=CentOS
-7 - Updates - mirrors.aliyun.com
-
failovermethod=priority
-
baseurl=http:
//mirrors.aliyun.com/centos/7/updates/$basearch/
-
http:
//mirrors.aliyuncs.com/centos/7/updates/$basearch/
-
http:
//mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
-
gpgcheck=
1
-
gpgkey=http:
//mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#additional packages that may be useful
-
[extras]
-
name=CentOS
-7 - Extras - mirrors.aliyun.com
-
failovermethod=priority
-
baseurl=http:
//mirrors.aliyun.com/centos/7/extras/$basearch/
-
http:
//mirrors.aliyuncs.com/centos/7/extras/$basearch/
-
http:
//mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
-
gpgcheck=
1
-
gpgkey=http:
//mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#additional packages that extend functionality of existing packages
-
[centosplus]
-
name=CentOS
-7 - Plus - mirrors.aliyun.com
-
failovermethod=priority
-
baseurl=http:
//mirrors.aliyun.com/centos/7/centosplus/$basearch/
-
http:
//mirrors.aliyuncs.com/centos/7/centosplus/$basearch/
-
http:
//mirrors.cloud.aliyuncs.com/centos/7/centosplus/$basearch/
-
gpgcheck=
1
-
enabled=
0
-
gpgkey=http:
//mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#contrib - packages by Centos Users
-
[contrib]
-
name=CentOS
-7 - Contrib - mirrors.aliyun.com
-
failovermethod=priority
-
baseurl=http:
//mirrors.aliyun.com/centos/7/contrib/$basearch/
-
http:
//mirrors.aliyuncs.com/centos/7/contrib/$basearch/
-
http:
//mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/
-
gpgcheck=
1
-
enabled=
0
-
gpgkey=http:
//mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
启动yum, 生成缓存
yum clean all && yum makecache fast
调试, 可以自己尝试安装需要的软件
yum install -y kinstall