配置本地centos yum源

232 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

在没有外网的情况下配置本地yum源

下载镜像

1)镜像地址:http://mirrors.aliyun.com/centos/7/isos/x86_64/
    下载文件:CentOS-7-x86_64-Everything-2009.iso  
    http://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-2009.iso
2)镜像说明
    打开centos官网,里面主要是以下几块内容
    1.DVD ISO : 最新版本基本版下载,带有常用的软件,无需自己下载安装(通常情况下),一般安装的是这个版本
    2.Everything ISO :最新版本完整版,带有大部分软件,无需自己下载安装(通常情况下),体积最大
    3.Minimal ISO:精简版,带有必备软件,其他软件需要自己下载安装,但是体积最小
    4.Older Versions:过往版本系统下载
    5.Need the Source:源码下载

挂载镜像文件

mkdir -p /mnt/centos7/  
mount -o loop CentOS-7-x86_64-Everything-2009.iso /mnt/centos7/

配置本地yum源

1)创建本地yum源配置文件
centos7本地yum源
vi /etc/yum.repos.d/CentOS7-local.repo

    #本源的名字(不能和其他重复)
    [CentOS7-local]
    name=CentOS7-local
    #步骤2中挂载镜像创建的目录
    baseurl=file:///mnt/centos7
    #启动yum源: 1-启用 0-不启用
    enabled=1
    #安全检测:  1-开启 0-不开启
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

ambari本地yum源配置
vi /etc/yum.repos.d/ambari-local.repo
    [ambari-local]
    name=ambari-local
    #步骤2中挂载镜像创建的目录
    baseurl=file:///data/app/ambari2.7.3/centos7/2.7.3.0-139
    #启动yum源: 1-启用 0-不启用
    enabled=1
    #安全检测:  1-开启 0-不开启
    gpgcheck=1
    gpgkey=file:///data/app/ambari2.7.3/centos7/2.7.3.0-139/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
    
centos远程yum源配置
/etc/yum.repos.d/CentOS7-remote.repo
    [CentOS7-remote]
    name=CentOS7-remote
    baseurl=http://11.51.197.6:18080/centos7
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    enabled=1
    priority=1	

2)更新yum源配置
    清除原有的
    yum clean all
    
    构建本地缓存
    yum makecache
    
    查看yum源仓库
    yum repolist
    
    查看yum源软件包
    yum list