Redhat7使用centos7的YUM的方法

系统环境:Red Hat Enterprise Linux Server release 7.2 (Maipo)

1、通过直接只用centos7的网络YUM仓库,发现检查不到任何数据包

[root@mysq51 ~]# cat /etc/redhat-release        #当前为Redhat7.2系统
Red Hat Enterprise Linux Server release 7.2 (Maipo)

[root@mysq51 ~]# cat /etc/yum.repos.d/CentOS-Base.repo 
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


[root@mysq51 ~]# yum repolist            #没有检查到软件包
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
源标识                                             源名称                                                状态
base/7Server/x86_64                                CentOS-7Server - Base                                 0
extras/7Server/x86_64                              CentOS-7Server - Extras                               0
updates/7Server/x86_64                             CentOS-7Server - Updates                              0
repolist: 0

[root@mysq51 ~]#

2、修改YUM仓库文件

将$releasever替换成7:

sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo     或者 vi  /etc/yum.repos.d/CentOS-Base.repo           :%s/$releasever/7/g

重新加载YUM仓库,可以检查到数据包

[root@mysq51 ~]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo    #修改配置
[root@mysq51 ~]# cat  /etc/yum.repos.d/CentOS-Base.repo 
[base]
name=CentOS-7 - Base
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/7/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-7 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


[root@mysq51 ~]# yum clean all        #清空YUM缓存
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
正在清理软件源: base extras updates
Cleaning up everything
[root@mysq51 ~]# yum repolist        #检查域名数据包
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                | 2.9 kB  00:00:00     
updates                                                                                               | 2.9 kB  00:00:00     
(1/4): base/x86_64/group_gz                                                                           | 153 kB  00:00:00     
(2/4): extras/x86_64/primary_db                                                                       | 227 kB  00:00:00     
(3/4): base/x86_64/primary_db                                                                         | 6.1 MB  00:00:01     
(4/4): updates/x86_64/primary_db                                                                      | 6.5 MB  00:00:04     
源标识                                                   源名称                                                        状态
base/x86_64                                              CentOS-7 - Base                                               10,072
extras/x86_64                                            CentOS-7 - Extras                                                460
updates/x86_64                                           CentOS-7 - Updates                                             1,898
repolist: 12,430
[root@mysq51 ~]# 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值