Chinaunix首页 | 论坛 | 博客
  • 博客访问: 303172
  • 博文数量: 35
  • 博客积分: 825
  • 博客等级:
  • 技术积分: 913
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-11 09:44
文章分类

全部博文(35)

文章存档

2013年(10)

2012年(24)

2010年(1)

我的朋友

分类: LINUX

2012-09-27 10:56:36

这两天需要做一个本地的yum源  开始是打算自己来安排整个目录结构 不聊得到高人指点 可以直接用rsync网络上的源  参考了这篇文章 准备用的源 写了一个小脚本来做这件事情 直接上代码吧

点击(此处)折叠或打开

  1. #!/bin/sh
  2. # sync yum centos 5 repos
  3. # mirror url:
  4. #
  5. #
  6. # author: pengfei xue
  7. Date=`date +%Y%m%d`
  8. rsyncBin="/usr/bin/rsync"
  9. function rsync_yum_repo()
  10. {
  11. repo_name=$1
  12. # build rsync paramters
  13. case $repo_name in
  14. ustc)
  15. logFile="/var/log/rsync_yum/ustc_$Date.log"
  16. excludeFile="/var/ftp/pub/CentOS/ustcExclude.list"
  17. rsyncParameters="-avrt --delete --exclude-from $excludeFile"
  18. mirrorUrl="rsync://mirrors.ustc.edu.cn/centos/"
  19. localSyncPath="/var/ftp/pub/CentOS/ustc/"
  20. ;;
  21. sohu)
  22. logFile="/var/log/rsync_yum/sohu_$Date.log"
  23. excludeFile="/var/ftp/pub/CentOS/sohuExclude.list"
  24. rsyncParameters="-avrt --delete --exclude-from $excludeFile"
  25. mirrorUrl="rsync://mirrors.sohu.com/dag/redhat/"
  26. localSyncPath="/var/ftp/pub/CentOS/sohu/"
  27. ;;
  28. esac
  29. # begin to sync
  30. echo "---- $Date `date +%T` Begin ----" >> $logFile
  31. $rsyncBin $mirrorUrl $rsyncParameters $localSyncPath >> $logFile 2>&1
  32. echo "---- $Date `date +%T` End ----" >> $logFile
  33. }
  34. for repo in ustc sohu
  35. do
  36. rsync_yum_repo $repo
  37. done


在用rsync时 写了一个exclude文件 把一些不想要的目录或者文件放在了这个文件中 文件内容如下 我们用的发行版是Centos5.4 所以一些其它的版本的文件都给过滤掉 centos5系列的整个镜像源有11G左右的大小 好在之前建的分区足够大 不然就挂了 

点击(此处)折叠或打开

  1. debug
  2. isos
  3. i386
  4. 2
  5. 2.*
  6. 3
  7. 3.*
  8. 4
  9. 4.*
  10. 6
  11. 6.*
  12. build
  13. dostools
  14. graphics
  15. Archive-Update-in-Process-mirrors.ustc.edu.cn
  16. HEADER.html
  17. TIME
  18. HEADER.images

阅读(4223) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~

pengphy2012-10-09 14:37:49

如果自建的源中的rpm文件发生变更 比如添加了新的rpm  此时需要更新源的 信息  可以使用这个命令:
createrepo --update your_repo_dir

pengphy2012-09-28 11:10:04

配置好yum源后 yum makecache报了错
Not using downloaded repomd.xml because it is older than what we have

可以yum clean all