当前位置:   article > 正文

redhat7配置yum repos软件仓库&远程yum_loaded plugins: product-id, search-disabled-repos,

loaded plugins: product-id, search-disabled-repos, subscription-manager

redhat7配置yum repos软件仓库&远程yum

Red Hat Enterprise Linux 7 安装后,执行yum命令是提示无可用yum repos(There are no enabled repos),报错信息如下:

[root@localhost opt]# yum install -y vim
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>
[root@localhost opt]# 

按照提示查看repolist为0:
[root@localhost opt]# yum repolist all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repolist: 0

[root@localhost opt]# ls -l /etc/yum.repos.d/
total 4
-rw-r--r--. 1 root root 358 Jul 13 19:37 redhat.repo

[root@localhost opt]# cat /etc/yum.repos.d/redhat.repo 
#
# Certificate-Based Repositories
# Managed by (rhsm) subscription-manager
#
# *** This file is auto-generated.  Changes made here will be over-written. ***
# *** Use "subscription-manager repo-override --help" if you wish to make changes. ***
#
# If this file is empty and this system is subscribed consider
# a "yum repolist" to refresh available repos
#
[root@localhost opt]# 

cat /etc/yum.repos.d/redhat.repo 查看软件仓库配置文件确实为空。

RedHatEnterpriseLinux 为了得系统更新并安装新软件,需要配置软件包存储库。

解决办法:

方法1)使用Redhat ISO配置本地软件仓库

mount /dev/cdrom  /mnt/
mkdir -p /opt/rhel7-iso
cp -r /mnt/*  /opt/rhel7-iso/
  #拷贝软件包

echo '
[RHEL_7]
name=RHEL_7_x86_64    #仓库名称
baseurl="file:///opt/rhel7-iso"  #仓库路径
gpgcheck=0
' > /etc/yum.repos.d/rhel7.repo

通过yum安装vim测试一下
yum install -y vim
命令执行后,会在 /opt/rhel7-iso 目录下生成一个 repodata 目录。

# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

repo id                                                                        repo name                                                                             status
RHEL_7                                                                         RHEL_7_x86_64                                                                         5,231
repolist: 5,231

配置提供局域网其他服务器的远程共享软件仓库
安装Apache(httpd)服务
yum install -y httpd

默认将网站的根目录指向 /var/www/html 目录
默认的主配置文件是 /etc/httpd/conf/httpd.conf 
配置存储在的 /etc/httpd/conf.d/ 目录

修改配置文件:
vim /etc/httpd/conf/httpd.conf 
ServerName 192.168.1.100:80

启动/查询/停止服务:
service  httpd  start
netstat -an |grep 80     #默认监听80端口
service  httpd stop

设置开机自启动服务
systemctl  enable  httpd.service

设置防火墙:
firewall-cmd --zone=public --add-port 80/tcp  --permanent
firewall-cmd --reload

cd /var/www/html/
创建一个测试页面:
touch '<html><head>yum repos server</head><body> rhel7.repo file: http://192.168.1.100/rhel7.repo , save to /etc/yum.repos.d/rhel7.repo </body></html>' > index.html

测试浏览器能正常访问:http://192.168.1.100/index.html
在 /var/www/html/ 下创建软件仓库目录 rhel7-iso。由于我已创建过了 /opt/rhel7-iso/,所以这里直接创建软连接(不再创建仓库软件包目录了):
ln -s /opt/rhel7-iso/  rhel7
浏览器测试能正常访问: http://192.168.1.100/rhel7/

在 /var/www/html/ 下创建文件  rhel7.repo for 其他机器可以远程下载
echo '
[RHEL_7]
name=RHEL_7_x86_64
baseurl="http://192.168.1.100/rhel7/"
gpgcheck=0
' > /var/www/html/rhel7.repo

其他局域网的机器,直接下载rhel7.repo或者直接手动创建 /etc/yum.repos.d/rhel7.repo 文件:

echo '
[RHEL_7]
name=RHEL_7_x86_64
baseurl="http://192.168.1.100/rhel7/"
gpgcheck=0
' > /etc/yum.repos.d/rhel7.repo

测试通过网络仓库进行 yum 安装:
yum install -y vim


方法2)配置Centos仓库
去阿里云下载一个OS对应的仓库:http://mirrors.aliyun.com/repo/
wget http://mirrors.aliyun.com/repo/Centos-7.repo
也可以直接 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-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

清除yum缓存
yum clean all

使用yum安装vim
yum install -y vim

方法2)使用subscription-manager
提示使用 subscription-manager 并遵循说明来注册您的 RHEL7 系统,从而启用 RHEL 的回购,这样的话,需要付费或试用 Redhat 订阅。
如果您只是想在不需要最新Redhat订阅的情况下进行游戏并安装软件,则可以安装下载的Redhat ISO映像,配置使用本地仓库,并从而克服 There are no enabled repos。
这个方法我没有尝试。

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/168797
推荐阅读
相关标签
  

闽ICP备14008679号