-
安装包
python-iniparse-0.4-9.el7.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-3.4.3-168.el7.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
下载地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/ -
删除自带的yum包
rpm -qa|grep yum|xargs rpm -e --nodeps -
安装
#先装下面两个包
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
#下面的两个包一起安装
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
- 备份配置文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- 更改配置文件
vim /etc/yum.repos.d/CentOS-Base.repo
#将这里面的内容全部删掉,替换成以下内容;
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/6.8/updates/$basearch/
gpgcheck=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/6.8/extras/$basearch/
gpgcheck=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://vault.centos.org/6.8/centosplus/$basearch/
gpgcheck=1
enabled=0
- 清除原来的源配置
yum clean all
- 安装现在的yum源,这一步也是测试新安装的yum源有没有安装成功
yum install yum
如果这条命令能执行成功,就说明新安装的yum源已经正确配置好了。
可能出现报错
file:///mnt/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/repodata/repomd.xml Tryi
意思是本地的镜像没有挂载
解决办法就是把本地源关闭:
vi /etc/yum.repos.d/CentOS-Media.repo
将enabled=1改成enabled=0
sudo mount /dev/cdrom /mnt
ls -l /mnt
再重新yum install yum
- 更新yum源到本地
yum list
若后续使用yum出现问题:
例如:No package xxx available
思路:出现这种问题的原因是要安装的软件包默认不在centos的光盘yum仓库中,因此我们需要配置 epel仓库
解决方法:
#1、配置阿里云网络源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#2、配置epel源
yum install -y epel-release
标签:CentOS,centos,rpm,repo,redhat,yum,安装,el7
From: https://www.cnblogs.com/lim-sy/p/16805643.html