当前位置:首页 » 《关注互联网》 » 正文

【Linux】yum安装

21 人参与  2024年09月27日 09:20  分类 : 《关注互联网》  评论

点击全文阅读


一、删除原来的yum源

1、检查yum源:

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 /etcmv yum.repos.d yum.repos.d.bakmkdir 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.comfailovermethod=prioritybaseurl=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=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates]name=CentOS-7 - Updates - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful[extras]name=CentOS-7 - Extras - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=1gpgkey=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.comfailovermethod=prioritybaseurl=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=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users[contrib]name=CentOS-7 - Contrib - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

4、清除缓存

yum clean all

5、重新生成缓存

yum makecache

6、yum 更新

yum updateyum clean all && yum makecache && yum update

点击全文阅读


本文链接:http://zhangshiyu.com/post/165192.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1