转自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 [ $? == ];then
echo -e "\033[1;32m $1 Rsync is success!\033[0m" >> $Resultfile
else
echo -e "\033[1;31m $1 Rsync is fail!\033[0m" >> $Resultfile
fi
} Checkdir(){
if [ ! -d $ ];then
mkdir -p $
fi
}
Checkdir $Logdir
Rsyncrepo(){
Checkdir $
$Rsync $Options $ $ >> $Logfile
Checkres $
} 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

建立自己的Yum源的更多相关文章

  1. Centos6.5建立本地YUM源

    很多情况下公司的服务器是不允许连外网的,那么安装软件的时候就很不方便了,这里就需要建立一个本地YUM源了. 文件位置:/etc/yum.repos.d/    后缀一定是.repo结束. 下面我们搭建 ...

  2. 虚拟机centos7配置本地yum源

    在虚拟机中要使用yum命令,就要先配置一下yum源,下面就分享一下这个过程: 1. 挂载iso到vmware,首先得确保CD/DVD连接到镜像.可以这样操作 2. 执行下面的命令 # mkdir /m ...

  3. CentOS下建立本地YUM源并自动更新

    1. 尽管有很多的免费镜像提供yum源服务,但是还是有必要建立自己的yum服务器,主要出于以下几点考虑: l 网络速度:访问互联网可能比较慢 l 节省带宽:如果有大量的服务器,架设自己的yum源可以有 ...

  4. 本地yum源建立

    一.openstack(ocata)本地yum源的建立: 1.配置yum缓存: vi /etc/yum.conf 把yum.conf配置改为: [main] cachedir=/var/cache/y ...

  5. createrepo 建立本地yum源

    linux使用createrepo制作本地yum源   目录 linux使用createrepo制作本地yum源 安装createrepo软件包 进入本地rpm包目录 执行完后可以看到生成的repod ...

  6. Centos6.4 本地yum源配置

    由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地yum源配置. 1.首先将需要rpm库添加到系统中: 1).虚拟机中安装的lin ...

  7. centos yum源配置

    5步搞定yum源配置 作者小波/QQ463431476欢迎转载! 第一步: 卸载原来的yum [root@localhost home]#rpm -qa|grep yum|xargs rpm -e - ...

  8. Centos 6.0将光盘作为yum源的设置方法

    在使用Centos 的时候,用yum来安装软件包是再方便不过了,但是如果在无法连接互联网的情况下,yum就不好用了. 下面介绍一种方式,就是将Centos安装光盘作为yum源,然后使用yum来安装软件 ...

  9. linux系统下yum源的搭建

    1.建立挂载点 系统默认在 /mnt目录 1>创建挂载点 mkdir -p /mnt/cdrom   参数-p是需要时创建目标目录的上层目录,但即使这些目录已存在也不当作错误处理 2>查看 ...

随机推荐

  1. ThinkPHP 3.2.2 在 volist 多重循环嵌套中使用 if 判断标签

    今天在 ThinkPHP 3.2.2 的试图模板中使用多重循环,用来把相应类别下对应的文章都依次循环出来,但是无论如何只能循环出类别,类别下的文章无法循环出,( 错误 ) 代码如下: <voli ...

  2. javascript中的eval()函数应用以及要点

    eval是干嘛用的?eval是直接将一段字符串作为参数,交给JS引擎预编译器进行动态分析并执行代码.如下: //调试台输出,你可以理解为console.log,再不理解就理解成alert也没事 var ...

  3. PHP7革新与性能优化

    有幸参与2015年的PHP技术峰会(PHPCON),听了鸟哥(惠新宸)的关于PHP7的新特性和性能优化的分享,一切都令人感到激动.鸟哥是国内最权威的PHP专家,他的分享有很多非常有价值的东西,我通过整 ...

  4. OmniThreadLibrary 3.03b发布了

    虽然版本号升的不大,但这也是一个重要的版本.作者发现了一个长期存在的bug,就是建立一个线程,如果不指定线程的优先级则默认设置为idle.(正确的应是Normal) 看一下具体的改动情况: 新功能: ...

  5. 十 mybatis逆向工程

    1       逆向工程 1.1     什么是逆向工程 mybaits需要程序员自己编写sql语句,mybatis官方提供逆向工程 可以针对单表自动生成mybatis执行所需要的代码(mapper. ...

  6. http协议(转)

    主要还是为了存放状态码··· 剖析 HTTP 协议   目录 HTTP 概述 HTTP 消息结构 HTTP 请求 HTTP 响应 HTTP 状态码 参考 回到顶部 HTTP 概述 HTTP 是什么? ...

  7. FW nexus docker

    原文地址: http://www.cnblogs.com/wzy5223/p/5410990.html Nexus 3.0 可以创建三种docker仓库: 1. docker (proxy)     ...

  8. mysql源码重启

    1.通过rpm包安装的MySQL service mysqld restart /etc/inint.d/mysqld start 2.从源码包安装的MySQL // linux关闭MySQL的命令 ...

  9. python socket 选项

    一.int socket(int domain, int type, int protocol) 1.domain -- 指定使用何种的地址类型 PF_INET, AF_INET: Ipv4网络协议P ...

  10. QTextCodec::makeDecoder函数,plugins需要是动态链接库

    QT中的QString内容使用Unicode作为文本编码.但是实际系统中通常采用的是其他编码,例如GBK,utf8等.为了便于兼容这些格式,QT中还设置了两个字符串类型: QCString类: C类型 ...