zoukankan      html  css  js  c++  java
  • 建立自己的Yum源

    转自http://kicklinux.com/setup-yum-repos-server/

    命令 reposync 可以直接同步yum源

    如/etc/yum.repos.d/cloudera-cdh4.repo

    合适的目录下 reposync cloudera-cdh4 就ok了

    #########更新#################

    rhel 5 使用 rhel6 或者 fedora 11 以上版本作为yum 源就会发生如下报错:

    [Errno -3] Error performing checksum

    原因: rhel 6 中 repomd.xml 文件使用 sha256 作为hash 算法 ,在rhel 5中 默认使用的是sha 作为hash 算法 ,倒是rhel5 读取 rhel 6 yum 源中的repomd.xml 出现问题

    解决办法: 将rhel 6 光盘中内容拷贝出来 ,createrepo  -s sha  ./   重新创建repo ,并制定默认算法 sha

    ##########更新完毕#################

    建立自己的yum服务源

    为了节省流量,提高效率,我们在机房内部署了自己的yum server。

    安装httpd服务。
    同步yum源到/var/www/html/linux下的目录

    /usr/bin/rsync -avzL --delete--exclude=SRPMS --exclude=i386 --exclude=isos rsync://mirrors.ustc.edu.cn/centos/6/ /var/www/html/linux/centos/x86_64/
    /usr/bin/rsync -avzL --delete rsync://mirrors.ustc.edu.cn/fedora-epel/6/x86_64 /var/www/html/linux/centos/epel/

    北京在线源
        rsync://mirrors.yun-idc.com/centos
        rsync://mirrors.yun-idc.com/epel 
       官方提供的所有镜像站http://www.centos.org/download/mirrors/
     

    添加自动化任务,每天夜里自动同步

    # vi /var/spool/cron/root 

    01***/usr/bin/rsync -avzL --delete--exclude=SRPMS --exclude=i386 --exclude=isos rsync://mirrors.ustc.edu.cn/centos/6/ /var/www/html/linux/centos/x86_64/

    01***/usr/bin/rsync -avzL --delete rsync://mirrors.ustc.edu.cn/fedora-epel/6/x86_64 /var/www/html/linux/centos/epel/
    # service httpd start

    在某一台机器上创建和修改以下文件

    [root@vm2 yum.repos.d]# more 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--Base#mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=os baseurl=http://172.16.1.101/linux/centos/x86_64/os/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#released updates[updates] name=CentOS--Updates#mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=updates baseurl=http://172.16.1.101/linux/centos/x86_64/updates/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that may be useful[extras] name=CentOS--Extras#mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=extras baseurl=http://172.16.1.101/linux/centos/x86_64/extras/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages[centosplus] name=CentOS--Plus#mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=centosplus baseurl=http://172.16.1.101/linux/centos/x86_64/centosplus/x86_64/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users[contrib] name=CentOS--Contrib#mirrorlist=http://mirrorlist.centos.org/?release=&arch=&repo=contrib baseurl=http://172.16.1.101/linux/centos/x86_64/contrib/x86_64/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6[root@vm2 yum.repos.d]# more epel.repo [epel] name=ExtraPackagesforEnterpriseLinux6- $basearch baseurl=http://172.16.1.101/linux/centos/epel/$basearch#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=http://172.16.1.101/linux/centos/epel/RPM-GPG-KEY-EPEL-6[epel-debuginfo] name=ExtraPackagesforEnterpriseLinux6- $basearch -Debug baseurl=http://172.16.1.101/linux/centos/epel/$basearch/debug#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=http://172.16.1.101/linux/centos/epel/RPM-GPG-KEY-EPEL-6 gpgcheck=1[epel-source] name=ExtraPackagesforEnterpriseLinux6- $basearch -Source baseurl=http://172.16.1.101/linux/centos/epel/SRPMS#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch failovermethod=priority enabled=0#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgkey=http://172.16.1.101/linux/centos/epel/RPM-GPG-KEY-EPEL-6 gpgcheck=1

    测试一下,一切正常。

    附一个脚本:

    #!/bin/bash
    ## rsync mirror centos and epel with yun-idc 
    ## visit http://mirrors.yun-idc.com/centos/5/
    ##       http://mirrors.yun-idc.com/centos/6/
    ##       http://mirrors.yun-idc.com/epel/5/
    ##       http://mirrors.yun-idc.com/epel/6/
    
    Rsync="/usr/bin/rsync"
    Options="-azvL  --exclude=SRPMS/  --exclude=xen --exclude=SCL/  --exclude=ppc64/ --exclude=ppc/--exclude=cr/ --exclude=fasttrack/ --exclude=isos/ --bwlimit=2000"
    Reporoot="/opt/apache/htdocs/repo/"
    Centos5="$Reporoot/5/"
    Centos5epel="$Reporoot/epel/5/"
    Centos6="$Reporoot/6/"
    Centos6epel="$Reporoot/epel/6/"
    
    Logdir="$Reporoot/logs/"
    Date=`date +%Y-%m-%d`
    Logfile="$Logdir/$Date.log"
    Resultfile="$Logdir/$Date.log.res"
    
    Checkres(){
        if [ $? == 0 ];then
           echo -e "33[1;32m $1 Rsync is success!33[0m" >> $Resultfile
        else
           echo -e "33[1;31m $1 Rsync is fail!33[0m" >> $Resultfile
        fi
    }
    
    Checkdir(){
        if [ ! -d $1 ];then
            mkdir -p $1
        fi
    }
    Checkdir $Logdir
    Rsyncrepo(){
        Checkdir $2
        $Rsync $Options $1 $2 >> $Logfile
        Checkres $1
    }
    
    Rsyncrepo rsync://mirrors.yun-idc.com/centos/5/ $Centos5
    Rsyncrepo rsync://mirrors.yun-idc.com/centos/6/ $Centos6
    Rsyncrepo rsync://mirrors.yun-idc.com/epel/5/ $Centos5epel
    Rsyncrepo rsync://mirrors.yun-idc.com/epel/6/ $Centos6epel
  • 相关阅读:
    catboost原理以及Python代码
    lightgbm原理以及Python代码
    stacking算法原理及代码
    python自动化之爬虫模拟登录
    python自动化之爬虫原理及简单案例
    python自动化之PDF
    input type="file"鼠标无法变小手
    typescript中类和接口的区别
    TypeScript基础类型
    微信小程序-获取input值的两种方法
  • 原文地址:https://www.cnblogs.com/cmsd/p/3586407.html
Copyright © 2011-2022 走看看