zoukankan      html  css  js  c++  java
  • YUM仓库配置与使用

    服务端

    修改yum配置文件
    yum下载软件不清空

    sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf

    创建目录给yum仓库使用

    mkdir -p /yum/centos7

    安装createrepo 软件,生成 yum 仓库数据库

    yum -y install createrepo yum-utils 

    初始化repodata索引文件

    yumdownloader tree # 只下载软件不安装
    createrepo -pdo /yum/centos7/ /yum/centos7/ #更新repodata索引文件

    提供yum服务
    可以用Apache或nginx提供web服务,但用Python的http模块更简单,适用于内网环境

    cd /yum/centos7/
    python -m SimpleHTTPServer 81 &>/dev/null &

    访问服务端ip查看http://ip:81
    添加rpm包

    yumdownloader pcre-devel openssl-devel # 只下载软件不安装
    createrepo --update /yum/centos7/ # 每加入一个rpm包就要更新一下

    客户端

    mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.ori
    cat >/etc/yum.repos.d/centos7.repo<<EOF
    [centos7]
    name=Server
    baseurl=http://10.0.0.41:81 #服务端ip
    enable=1
    gpgcheck=0
    EOF

    临时使用刚刚服务端创建的库

    yum --enablerepo=centos7 --disablerepo=base,extras,updates,epel list

    永久使用

    sed -i -e '19a enabled=0' -e '29a enabled=0' -e '39a enabled=0' /etc/yum.repos.d/CentOS-Base.repo

    测试

    注释/etc/resolv.conf的文件

    vim /etc/resolv.conf
    #nameserver 223.5.5.5
    #nameserver 223.6.6.6
    
    ping www.baidu.com #ping不通就行了
    ping: www.baidu.com: Name or service not known

    在服务端安装nginx,然后找nginx的rpm包

     yum -y install nginx
     cd /var/cache/yum/x86_64/7/ #nginx的rpm包目录
     find . -name '*.rpm' #查看此目录的rpm包

    服务端添加到自己的仓库

    find . -name '*.rpm'|xargs -i cp {} /yum/centos7
    find . -name '*.rpm' -exec cp {} /yum/centos7 ; #两种方法
    cd /yum/centos7/
    createrepo --update /yum/centos7/ # 每加入一个rpm包就要更新一下

    客服端重新加载yum缓存并下载nginx

    yum clean all
    yum makecache
    yum -y install nginx
  • 相关阅读:
    java使用递归删除非空目录
    关于Java日期的两道例题
    equals和==的区别
    从键盘读入个数不确定的整数,并判断读入的正数和负数的个数,输入为0时结束程序。
    输出所有的水仙花数
    99乘法表
    switch
    next()、nextInt()
    流程控制
    Scanner从键盘输入
  • 原文地址:https://www.cnblogs.com/rm580036/p/12762960.html
Copyright © 2011-2022 走看看