RHEL7配置yum源

redhat 默认自带的 yum 源需要注册才能更新。想不花钱也可以更新,就需要替换掉redhat的yum源。

  1. 检查是否安装yum包

查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:

[root@localhost ~]# rpm -qa |grep yum

  1. 删除redhat自带的yum包

卸载上面显示的所有yum包:

[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)

[root@localhost ~]# rpm -qa |grep yum (再次查看)

[root@localhost ~]# (无信息显示表示已经卸载完成。)

  1. 下载新的yum包

使用wget下载网易镜像中Centos7.1.1503的yum包

[root@localhost ~]# wget http://mirrors.163.com/centos/7.1.1503/os/x86_64/Packages/yum-3.4.3-125.el7.centos.noarch.rpm

[root@localhost ~]# wget http://mirrors.163.com/centos/7.1.1503/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

[root@localhost ~]# wget http://mirrors.163.com/centos/7.1.1503/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-29.el7.noarch.rpm

[root@localhost ~]# wget http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 

  1. 安装yum软件包

使用下面的命令安装解决包的依赖问题:

 

[root@localhost ~]#

rpm --import RPM-GPG-KEY-CentOS-7

[root@localhost ~]# rpm -ivh yum-*换yum源

 

进入yum资源仓库目录

[root@localhost ~]# cd /etc/yum.repos.d

下载163的源

[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

  1. 编辑repo

用vim 打开repo

[root@localhost yum.repos.d]# vim CentOS6-Base-163.repo

用vim在一般模式使用下面的命令把$releasever全部替换为版本号,即7.1.1503。

:1,$s/$releasever/7.1.1503/g

用同样的方法把所有RPM-GPG-KEY-CentOS-6修改为RPM-GPG-KEY-CentOS-7

:1,$s/RPM-GPG-KEY-CentOS-6/RPM-GPG-KEY-CentOS-7/g

最后,:wq保存退出vim

  1. 重建缓存(yum makecache)

清理原有缓存

[root@localhost yum.repos.d]# yum clean all

重建缓存,以提高搜索安装软件的速度

[root@localhost yum.repos.d]# yum makecache

  1. 更新系统(可选)

[root@localhost yum.repos.d]# yum update

 
  1. 安装tree进行测试

使用tree可以以树的结果显示目录,直观明了

[root@localhost ~]# yum –y install tree

安装完后输入:tree看看目录的结果,很酷吧 o(^▽^)o

PS:

1. 查看已经安装的源

[root@localhost ~]# yum repolist all
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
RHEL 7的在线yum源是通过Red Hat订阅提供的。要设置RHEL 7的在线yum源,请按照以下步骤进行操作: 1. 首先,确保你已经购买了有效的Red Hat订阅,并且拥有订阅账户。 2. 登录到你的RHEL 7服务器。 3. 打开终端,并使用root用户或具有sudo权限的用户。 4. 运行以下命令来备份现有的yum源文件: ``` cp /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.bak ``` 5. 编辑yum源文件: ``` vi /etc/yum.repos.d/redhat.repo ``` 6. 将文件中的"enabled=0"改为"enabled=1",以启用在线yum源。 7. 添加你的Red Hat订阅信息。在文件末尾添加以下内容: ``` [rhel-7-server-rpms] name = Red Hat Enterprise Linux 7 Server (RPMs) baseurl = https://cdn.redhat.com/content/rhel/server/7/$releasever/$basearch/os gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [rhel-7-server-extras-rpms] name = Red Hat Enterprise Linux 7 Server - Extras (RPMs) baseurl = https://cdn.redhat.com/content/rhel/server/7/$releasever/$basearch/extras/os gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release enabled = 1 [rhel-7-server-optional-rpms] name = Red Hat Enterprise Linux 7 Server - Optional (RPMs) baseurl = https://cdn.redhat.com/content/rhel/server/7/$releasever/$basearch/optional/os gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release enabled = 1 ``` 8. 保存并退出文件。 9. 清除和重建yum缓存: ``` yum clean all yum makecache ``` 现在,你的RHEL 7服务器应该已经配置了在线yum源,可以使用yum命令来安装和更新软件包了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值