前言:
本文先讲述配置yum, 再讲述安装yum,因为一般系统会已经安装有yum了的,可以直接输入指令yum
-回车确认(如下述 安装-第6点)。
一、配置yum
1、查看看是否存在yum
[root@localhost ~]# rpm -qa|grep yum
yum-langpacks-0.4.2-7.el7.noarch
yum-3.4.3-168.el7.centos.noarch
PackageKit-yum-1.1.10-2.el7.centos.x86_64
yum-utils-1.1.31-54.el7_8.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
2、备份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
3、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
阿里云yum(2024最新yum:https://developer.aliyun.com/mirror/)
centos 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
centos 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
网易yum(2024最新yum:http://mirrors.163.com/.help/)
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
4、清除缓存
yum clean all
5、新建缓存
yum makecache
完成!!!
===================================================================
二、安装yum
注:请确认你是否能访问centos官网(https://vault.centos.org/7.2.1511/os/x86_64/Packages/ ),或者是否有 国内的yum安装包(国内的最新yum的安装包我暂时没找到,下述的安装包为centos官网的)
1、删除yum安装包(建议先备份相关的yum文件再做删除,不然环境重要的话,后悔都来不及)
[root@localhost ~]# rpm -aq|grep yum|xargs rpm -e --nodeps
2、查看:
[root@localhost ~]# rpm -qa|grep yum
4、进入centos官网获取yum的安装包
(https://vault.centos.org/7.2.1511/os/x86_64/Packages/)
wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
[root@localhost opt]# ll (下载得如下文件)
total 1304
-rw-r--r--. 1 root root 1272736 Dec 3 2015 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rw-r--r--. 1 root root 28348 Jul 3 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 30600 Nov 25 2015 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
[root@localhost opt]#
5、解压安装yum安装包
rpm -ivh yum-*
6、确认安装完成
[root@localhost ljh]# yum
Loaded plugins: fastestmirror
You need to give some command
Usage: yum [options] COMMAND
List of Commands:
check Check for problems in the rpmdb
check-update Check for available package updates
......略
标签:centos,CentOS,repo,Base,yum,安装,el7
From: https://www.cnblogs.com/lanjianhua/p/18357189