RedHat7使用yum源安装依赖包

  • 由于Redhat版本的linux不能免费使用yum源安装依赖包,这导致不能愉快的安装Oracle的相关产品,本文就介绍一下如何在Redhat7上配置yum源
  • 首先查看一下Redhat7默认安装的yum,查询结果如下
[wen@localhost Desktop]$ rpm -qa | grep yum
  • 在这里插入图片描述

  • 发现默认有安装yum,先将其卸载

[wen@localhost Desktop]$ su - root                         //切换到root用户 进行卸载
Password: 
Last login: Sat Nov  2 19:50:09 CST 2019 on pts/0
[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps         //忽略依赖性 卸载
[root@localhost ~]# rpm -qa | grep yum             //再次查询是否还有yum相关的安装包,以确保卸载完全
  • 将准备好的yum安装包上传到虚拟主机,我是放在/home/yum目录下
    在这里插入图片描述
    在这里插入图片描述
  • 因为要替换,所以一定要是完整的一套,还有一个rhel-debuginfo.repo文件要配置。部分博客配置的不对,这个文件配置不对也是不行的,所以我是测试好的一套yum包给大家包括配置文件,需要的可以找我。执行: rpm -ivh *.rpm 一次性执行依赖包,因为包之间会相互依赖。
[root@localhost yum]# rpm -ivh *.rpm
  • 在这里插入图片描述
  • 新建配置文件/etc/yum.repos.d/CentOS-Base.repo,加入以下内容即可,不要改动,不要以为你很厉害,真的!然后保存退出
[root@localhost yum]# vi /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

在这里插入图片描述
然后执行yum clear all,就可以用yum来安装依赖包了

[root@node ~]# yum clear all

在这里插入图片描述

发布了57 篇原创文章 · 获赞 85 · 访问量 9615

猜你喜欢

转载自blog.csdn.net/qq_41944882/article/details/102875857