zoukankan      html  css  js  c++  java
  • 自己动手制作一个本地的yum仓库

    制作本地yum源有两种方式,第一种是使用光盘镜像,然后在本地进行安装。第二种是我们自己创建一个本地yum仓库,然后使用file的形式来向本地提供yum repo(也可以使用http的方式向外部提供,我们这里就自己给自己创建yum仓库)

    1、把从网上下载的rpm包放在本地的某个文件夹里面

    我们可以这样子下载,使用yum下载rpm包但是并不安装

    yum groupinstall "Development tools" --downloadonly --downloaddir=./
    [root@chaofeng yum]# pwd
    /data/yum                                                  #我是把RPM包放在了/data/yum目录下
    [root@chaofeng yum]# ls
    autoconf-2.69-11.el7.noarch.rpm          intltool-0.50.2-7.el7.noarch.rpm
    automake-1.13.4-3.el7.noarch.rpm         libquadmath-devel-4.8.5-36.el7.x86_64.rpm
    bison-3.0.4-2.el7.x86_64.rpm             libtool-2.4.2-22.el7_3.x86_64.rpm
    byacc-1.9.20130304-3.el7.x86_64.rpm      patch-2.7.1-10.el7_5.x86_64.rpm
    cscope-15.8-10.el7.x86_64.rpm            patchutils-0.3.3-4.el7.x86_64.rpm
    ctags-5.8-13.el7.x86_64.rpm              perl-Git-1.8.3.1-20.el7.noarch.rpm
    diffstat-1.57-4.el7.x86_64.rpm           rcs-5.9.0-5.el7.x86_64.rpm
    doxygen-1.8.5-3.el7.x86_64.rpm           redhat-rpm-config-9.1.0-87.el7.centos.noarch.rpm
    flex-2.5.37-6.el7.x86_64.rpm             rpm-build-4.11.3-35.el7.x86_64.rpm
    gcc-4.8.5-36.el7.x86_64.rpm              rpm-sign-4.11.3-35.el7.x86_64.rpm
    gcc-c++-4.8.5-36.el7.x86_64.rpm          subversion-1.7.14-14.el7.x86_64.rpm
    gcc-gfortran-4.8.5-36.el7.x86_64.rpm     swig-2.0.10-5.el7.x86_64.rpm
    gettext-devel-0.19.8.1-2.el7.x86_64.rpm  systemtap-3.3-3.el7.x86_64.rpm
    git-1.8.3.1-20.el7.x86_64.rpm            systemtap-devel-3.3-3.el7.x86_64.rpm
    indent-2.2.11-13.el7.x86_64.rpm

    2、下载制作本地yum的命令程序包

    创建仓库需要特定的程序包来完成。我们下载这个程序包

    yum install createrepo

    3、确保防火墙关闭状态

    4、开始创建yum仓库,在rpm包存放的所在的目录下执行createrepo命令。

    [root@chaofeng yum]# createrepo ./
    Spawning worker 0 with 29 pkgs
    Workers Finished
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    Generating sqlite DBs
    Sqlite DBs complete

    创建完成后我们会看到这个目录repodata,这个目录很是关键,

    5、在/etc/yum.repos.d目录下创建配置文件。(我这里是以本地file的形式给自己的主机提供yum源,如果你要在局域网内的其他主机可以访问到,则使用http或ftp的形式进行,比如:base=http://{当前yum源所在主机的IP}/{RPM软件包目录})

    [root@chaofeng yum.repos.d]# cat CentOS-BenDi.repo
    [Centos-BenDi]
    name=centos yum repo
    baseurl=file:///data/yum
    enabled=1
    gpgcheck=0
    priority=1

    7、更新本地缓存即可

    yum clean all
    yum makecache

    8、尝试安装一个本地存在的软件包gcc

    [root@chaofeng yum.repos.d]# yum install gcc
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.zju.edu.cn
     * epel: mirrors.tuna.tsinghua.edu.cn
     * extras: mirrors.163.com
     * updates: centos.mirrors.estointernet.in
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 gcc.x86_64.0.4.8.5-36.el7 将被 安装
    --> 解决依赖关系完成
    
    依赖关系解决
    
    ========================================================================================================
     Package            架构                  版本                                                   大小
    ========================================================================================================
    正在安装:
     gcc                x86_64                4.8.5-36.el7                Centos-BenDi                 16 M
    
    事务概要
    ========================================================================================================
    安装  1 软件包
    
    总下载量:16 M
    安装大小:37 M
    Is this ok [y/d/N]: y

    上面我们可以看到下载gcc包使用的正是我们刚刚我们制作的本地yum源。

    9、我们还可以这样子检测是否使用了本地yum源

    [root@chaofeng yum]# yum repolist
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.zju.edu.cn
     * epel: mirrors.tuna.tsinghua.edu.cn
     * extras: mirrors.163.com
     * updates: centos.mirrors.estointernet.in
    源标识                            源名称                                                          状态
    Centos-BenDi                      centos yum repo                                                     29
    base/7/x86_64                     CentOS-7 - Base                                                 10,019
    epel/x86_64                       Extra Packages for Enterprise Linux 7 - x86_64                  12,851
    extras/7/x86_64                   CentOS-7 - Extras                                                  321
    updates/7/x86_64                  CentOS-7 - Updates                                                 625
    repolist: 23,845

    你看第一个就是我们自己制作的本地yum源。

  • 相关阅读:
    面试精选:链表问题集锦
    经典排序算法总结与实现 ---python
    Python高级编程–正则表达式(习题)
    Python面试题汇总
    Python正则表达式
    Linux下的Libsvm使用历程录
    在 linux(ubuntu) 下 安装 LibSVM
    过拟合
    百度历年笔试面试150题
    MATLAB 的数据类型
  • 原文地址:https://www.cnblogs.com/FengGeBlog/p/10230311.html
Copyright © 2011-2022 走看看