【Linux】yum安装

weixin_43132192 2024-10-02 12:07:03 阅读 89

一、删除原来的yum源

1、检查yum源:

<code>rpm -qa | grep yum

2、删除原来的yum源

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

3、防止系统自带的插件subscription-manager订阅管理器进行注册

vi /etc/yum/pluginconf.d/subscription-manager.conf

#enabled=1

二、拷贝这三个安装包

如果没有可以从这个地址下载:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

yum-3.4.3-168.el7.centos.noarch.rpm

yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

三、安装三个包

1、使用以下命令一次性安装3个包

rpm -ivh yum-*

2、检查是否安装成功

rpm -qa |grep yum

四、配置repo文件

1、在linux中进入etc文件,备份yum.repos.d文件

cd /etc

mv yum.repos.d yum.repos.d.bak

mkdir yum.repos.d

2、下载repo文件

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、修改下载好的repo文件

下载好的repo文件应该在etc/yum.repos.d目录下,里面应该也只有一个文件,直接vim 文件名

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

把repo文件里所有 $releasever全部替换成版本号7

操作如下:

按下i键,然后按:

输入命令:

%s/$releasever/7/g

替换完毕后,按Esc,然后 :wq 保存退出vim模式

2)-3)也可以手工放入

# 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

4、清除缓存

yum clean all

5、重新生成缓存

yum makecache

6、yum 更新

yum update

yum clean all && yum makecache && yum update



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。