Linux下安装YUM源及配置

操作系统版本:centos7

[root@linux-node3 ~]# uname -r
3.10.0-514.el7.x86_64

一、将现有的yum源卸载

[root@linux-node3 ~]# rpm -qa yum
yum-3.4.3-150.el7.centos.noarch
[root@linux-node3 ~]# rpm -qa | grep yum | xargs rpm -e --nodeps  #这一步一定要执行,而且要将所有的组件卸载掉,如果卸载不干净,后面安装会有问题
[root@linux-node3 ~]# rpm -qa yum

这里写图片描述

二、从centos官网上下载和yum有关的rpm包

1、下载rpm包

[root@linux-node3 ~]# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@linux-node3 ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
[root@linux-node3 ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@linux-node3 ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

备注:如果是centos6,应下载以下rpm包

http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm

2、安装

[root@linux-node3 ~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm --force --nodeps

[root@linux-node3 ~]# rpm -ivh yum-* --force --nodeps

[root@linux-node3 ~]# rpm -qa yum    #查看是否已经安装上
yum-3.4.3-158.el7.centos.noarch

 

三、检测安装的yum是否有问题,执行命令进行测试 
这里写图片描述

备注: 
1、不同的操作系统版本,要从官网上下载不同的rpm包,官网地址”http://mirror.centos.org/centos/“,然后根据自己操作系统的版本选择即可。 
2、如果出现安装好以后,yum还是不能用的情况,那肯是是原有的yum没有删除干净,再次执行以下命令,重新安装yum即可。

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

3、如果有需要导入证书的情况,请从官网上找到链接,导入即可

rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

 

四、运行yum命令。安装软件

    yum install vsftpd*

五、yum的配置文件 /etc/yum.repos.d/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 - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页