1. 尽管有很多的免费镜像提供yum源服务,但是还是有必要建立自己的yum服务器,主要出于以下几点考虑:

  l 网络速度:访问互联网可能比较慢

  l 节省带宽:如果有大量的服务器,架设自己的yum源可以有效节省互联网带宽

  l 联网限制:对于有些内网服务器,不能连接到互联网

  l 对于RHEL(Redhat Enterprise Linux),需要购买服务

  l 便于发布自己开发的rpm包

  2. 找到适合你的站点的yum同步源,主要是CentOS标准软件仓库、epel、以及rpmforge

  CentOS标准仓库选择列表

  Asian:

  http://www.centos.org/modules/tinycontent/index.php?id=32

  North American

  http://www.centos.org/modules/tinycontent/index.php?id=30

  Epel源选择列表

  http://mirrors.fedoraproject.org/publiclist/EPEL/

  Rpmforge源

  http://apt.sw.be/

  要选尽量离你的local服务器近的地区,并支持RSYNC,方便更新同步

  我选择的是Linux Kernel Archives

  CentOS标准软件仓库

  rsync://mirrors.kernel.org/centos

  Epel源

  rsync://mirrors.kernel.org/fedora-epel

  Rpmforge源

  rsync://ftp-stud.fht-esslingen.de/dag

  rsync://mirror.cpsc.ucalgary.ca/dag

  3. 编写同步脚本,根据需求进行自动同步

  [root@cc-system-manager1 bin]# vi update_yum_source.sh

  #!/bin/bash

  #==========================================

  # Program : update_yum_source.sh

  # Info : 定期同步官方 yum 源到本机

  # Version : 2013.03.05 First Release

  #==========================================

  Date=`date +%Y%m%d`

  LogFile="/tmp/update_yum_source.log"

  CentOSTrunkVer="5"

  CentOSCurrentVer="5.9"

  RsyncBin="/usr/bin/rsync"

  RsyncPerm="-avrt --delete --exclude=debug/ --exclude=isos/"

  CentOS_Trunk_Ver_Path="/servers/yum_update/$CentOSTrunkVer"

  CentOS_Current_Ver_Path="/servers/yum_update/$CentOSCurrentVer"

  YumSiteList="rsync://mirrors.kernel.org/centos"

  echo "---- $Date `date +%T` Begin ----" >>$LogFile

  # centos 5

  $RsyncBin $RsyncPerm $YumSiteList/$CentOSTrunkVer/

  $CentOS_Trunk_Ver_Path/ >> $LogFile

  # centos 5.9

  $RsyncBin $RsyncPerm $YumSiteList/$CentOSCurrentVer/

  $CentOS_Current_Ver_Path/ >> $LogFile

  echo "---- $Date `date +%T` End ----" >> $LogFile

  [root@cc-system-manager1 bin]# vi update_epel_source.sh

  #!/bin/bash

  #==========================================

  # Program : update_epel_source.sh

  # Info : 定期同步官方 epel 源到本机

  # Version : 2013.03.05 First Release

  #==========================================

  Date=`date +%Y%m%d`

  LogFile="/tmp/update_epel_source.log"

  RsyncBin="/usr/bin/rsync"

  RsyncPerm="-avrt --delete --exclude=4/ --exclude=4AS/ --exclude=4ES/ --exclude=4WS/ --exclude=6/ --exclude=testing/"

  #============ epel ==============

  epelSite="rsync://mirrors.kernel.org/fedora-epel"

  epelLocalPath="/servers/epel"

  echo "---- $Date `date +%T` Begin ----" >>$LogFile

  # epel

  $RsyncBin $RsyncPerm $epelSite $epelLocalPath >> $LogFile

  echo "---- $Date `date +%T` End ----" >> $LogFile

  [root@cc-system-manager1 bin]# vi update_rpmforge_socure.sh

  #!/bin/bash

  #==========================================

  # Program : update_rpmforge_source.sh

  # Info : 定期同步官方 rpmforge 源到本机

  # Version : 2013.03.05 First Release

  #==========================================

  Date=`date +%Y%m%d`

  LogFile="/tmp/update_rpmforge_source.log"

  RsyncBin="/usr/bin/rsync"

  RsyncPerm="-avrt --delete --exclude=i386/ --exclude=ppc/ --exclude=source/"

  # rpmforge

  #rpmforgeSite="rsync://apt.sw.be/redhat/el5/en/"

  rpmforgeSite="rsync://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/"

  rpmforgeLocalPath="/servers/rpmforge"

  echo "---- $Date `date +%T` Begin ----" >>$LogFile

  # rpmforge

  $RsyncBin $RsyncPerm $rpmforgeSite $rpmforgeLocalPath >> $LogFile

  echo "---- $Date `date +%T` End ----" >> $LogFile

  4. 在apache的配置文件里做好相应的软连接或者修改主目录指向

  cd /var/www/html/

  ln -s /servers/yum_update/ yum

  ln -s /servers/epel epel

  ln -s /servers/rpmforge rpmforge

  5. 分别创建3个repo的配置文件,指向本地源所在的服务器,注意目录

  [root@cc-monitor yum.repos.d]# vi CentOS-Base.repo

  [base]

  name=CentOS-$releasever - Base

  baseurl=http://172.25.6.8/yum/$releasever/os/$basearch/

  gpgcheck=1

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  #released updates

  [updates]

  name=CentOS-$releasever - Updates

  baseurl=http://172.25.6.8/yum/$releasever/updates/$basearch/

  gpgcheck=1

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  #packages used/produced in the build but not released

  [addons]

  name=CentOS-$releasever - Addons

  baseurl=http://172.25.6.8/yum/$releasever/addons/$basearch/

  gpgcheck=1

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  #additional packages that may be useful

  [extras]

  name=CentOS-$releasever - Extras

  baseurl=http://172.25.6.8/yum/$releasever/extras/$basearch/

  gpgcheck=1

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  #additional packages that extend functionality of existing packages

  [centosplus]

  name=CentOS-$releasever - Plus

  baseurl=http://172.25.6.8/yum/$releasever/centosplus/$basearch/

  gpgcheck=1

  enabled=0

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  #contrib - packages by Centos Users

  [contrib]

  name=CentOS-$releasever - Contrib

  baseurl=http://172.25.6.8/yum/$releasever/contrib/$basearch/

  gpgcheck=1

  enabled=0

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  [root@cc-monitor yum.repos.d]# vi epel.repo

  [epel]

  name=Extra Packages for Enterprise Linux 5 - $basearch

  baseurl=http://172.25.6.8/epel/5/$basearch

  failovermethod=priority

  enabled=1

  gpgcheck=1

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

  [epel-debuginfo]

  name=Extra Packages for Enterprise Linux 5 - $basearch - Debug

  baseurl=http://172.25.6.8/epel/5/$basearch/debug

  failovermethod=priority

  enabled=0

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

  gpgcheck=1

  [epel-source]

  name=Extra Packages for Enterprise Linux 5 - $basearch - Source

  baseurl=http://172.25.6.8/epel/5/SRPMS

  failovermethod=priority

  enabled=0

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

  gpgcheck=1

  [root@cc-monitor yum.repos.d]# vi rpmforge.repo

  [rpmforge]

  name = RHEL $releasever - RPMforge.net - dag

  baseurl = http://172.25.6.8/rpmforge/$basearch/rpmforge

  enabled = 1

  protect = 0

  gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge

  gpgcheck = 1

  [rpmforge-extras]

  name = RHEL $releasever - RPMforge.net - extras

  baseurl = http://172.25.6.8/rpmforge/$basearch/extras

  enabled = 0

  protect = 0

  gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge

  gpgcheck = 1

  [rpmforge-testing]

  name = RHEL $releasever - RPMforge.net - testing

  baseurl = http://172.25.6.8/rpmforge/$basearch/testing

  enabled = 0

  protect = 0

  gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge

  gpgcheck = 1

  6. 检查gpg key是否完整

  [root@cc-monitor ~]# ll /etc/pki/rpm-gpg/

  total 24

  -rw-r--r-- 1 root root 1512 Apr 25 2010 RPM-GPG-KEY-beta

  -rw-r--r-- 1 root root 1504 Apr 25 2010 RPM-GPG-KEY-CentOS-5

  -rw-r--r-- 1 root root 1698 Apr 15 2012 RPM-GPG-KEY-EPEL

  如果缺少gpg key可以用rpm导入

  #在本地yum源服务器

  wget http://apt.sw.be/RPM-GPG-KEY.dag.txt

  mv RPM-GPG-KEY.dag.txt RPM-GPG-KEY-rpmforge

  #在需要yum安装的客户端执行

  rpm --import http://172.25.6.8/rpmforge/RPM-GPG-KEY-rpmforge

  7. 测试三种Yum源是否可行

  #情况缓存

  [root@cc-monitor ~]# yum clean all

  Loaded plugins: fastestmirror

  Cleaning up Everything

  #列出可用的仓库一共有22465的可用包

  [root@cc-monitor ~]# yum repolist

  repo id repo name status

  addons enabled: 0 CentOS-5 - Addons

  base enabled: 3,641 CentOS-5 - Base

  epel enabled: 7,244 Extra Packages for Enterprise Linux 5 - x86_64

  extras enabled: 266 CentOS-5 - Extras

  rpmforge enabled: 11,158 RHEL 5 - RPMforge.net - dag

  updates enabled: 156 CentOS-5 - Updates

  repolist: 22,465

  测试CentOS标准软件仓库

  [root@cc-monitor ~]# yum install nspr nspr-devel

  Loaded plugins: fastestmirror

  Determining fastest mirrors

  Resolving Dependencies

  --> Running transaction check

  ---> Package nspr.i386 0:4.9.2-2.el5_9 set to be updated

  ---> Package nspr.x86_64 0:4.9.2-2.el5_9 set to be updated

  ---> Package nspr-devel.i386 0:4.9.2-2.el5_9 set to be updated

  ---> Package nspr-devel.x86_64 0:4.9.2-2.el5_9 set to be updated

  --> Finished Dependency Resolution

  测试epel

  [root@cc-monitor ~]# yum install nginx

  Loaded plugins: fastestmirror

  Loading mirror speeds from cached hostfile

  Setting up Install Process

  Resolving Dependencies

  --> Running transaction check

  ---> Package nginx.x86_64 0:0.8.55-2.el5 set to be updated

  --> Processing Dependency: libxslt.so.1()(64bit) for package: nginx

  --> Processing Dependency: libgd.so.2()(64bit) for package: nginx

  --> Processing Dependency: libexslt.so.0()(64bit) for package: nginx

  --> Processing Dependency: libGeoIP.so.1()(64bit) for package: nginx

  --> Running transaction check

  ---> Package GeoIP.x86_64 0:1.4.8-1.el5 set to be updated

  ---> Package gd.x86_64 0:2.0.33-9.4.el5_4.2 set to be updated

  --> Processing Dependency: pkgconfig for package: gd

  --> Processing Dependency: libXpm.so.4()(64bit) for package: gd

  ---> Package libxslt.x86_64 0:1.1.17-4.el5_8.3 set to be updated

  --> Running transaction check

  ---> Package libXpm.x86_64 0:3.5.5-3 set to be updated

  ---> Package pkgconfig.x86_64 1:0.21-2.el5 set to be updated

  --> Finished Dependency Resolution

  测试rpmforge

  [root@cc-monitor ~]# yum install htop

  Loaded plugins: fastestmirror

  Loading mirror speeds from cached hostfile

  rpmforge

  Setting up Install Process

  Resolving Dependencies

  --> Running transaction check

  ---> Package htop.x86_64 0:1.0.2-1.el5.rf set to be updated

  --> Finished Dependency Resolution

CentOS下建立本地YUM源并自动更新的更多相关文章

  1. 为CentOS 6 配置本地YUM源

    在网上找了很多为CentOS 6配置本地YUM源的方法,其中有很多是与网络相关的,我只想配个自己用的,结果就发现这个方法比较简单实用,就转过来了. 环境:CentOS 6.0 默认的yum是以网络来安 ...

  2. [转载]CentOS 7 创建本地YUM源

    本文中的"本地YUM源"包括三种类型:一是直接使用CentOS光盘作为本地yum源,优点是简单便捷,缺点是光盘软件包可能不完整(centos 7 Everything 总共才6.5 ...

  3. CentOS 6.x 本地yum源配置与使用

    系统默认已经安装了可使用yum的软件包,所以可以直接配置: # mount  /dev/cdrom  /mnt                                挂载镜像,可以写到配置文件 ...

  4. CENTOS 6-7的本地YUM源配置

    本文档适合CENTOS 6-7的本地YUM源配置 cd /media cd CentOS_6.8_Final/ cd Packages 创建目录拷贝文件 mkdir /yum cp * /yum 配置 ...

  5. CentOS 6.5本地yum源、局域网离线yum仓库(断网情况下轻松安装各种依赖包)

    在工作中, 公司的服务器大部分都禁止连接外网的,初始化系统,测试某些产品时,往往缺一些软件或依赖包,一个个上传到机器,如此浪费时间,浪费金钱,en...yum能够自动查找并解决rpm包之间的依赖关系, ...

  6. CentOS 6.6下配置本地yum源与网络yum源

    一.本地yum源 1.系统默认已经安装了可使用yum的软件包,所以可以直接配置: [root@localhost ~]# cd /etc/yum.repos.d/                    ...

  7. CentOS 8配置本地yum源及DNF简介

    CentOS 8更改了软件包的安装程序,取消了 yum 的配置方法,改而使用了dnf 作为安装程序.虽然改变了软件包的安装方式,但是 dnf 还是能兼容使用 yum 的配置文件和命令的使用方法. 小提 ...

  8. CentOS 手动配置本地yum源(参考CentOS7 制作 CentOS6本地yum源)

    将原有/etc/yum.repos.d/目录下的文件名全部改为(*.bak),如(红色标记) [root@localhost ~]# cd /etc/yum.repos.d/ [root@localh ...

  9. CentOS 7 配置本地 YUM源

    以VMware中使用ISO光盘为例配置本地Yum源 配置步骤:1.安装好CentOS 7后,使用root账户登陆系统#将安装CentOS所使用的iso光盘挂载到/mnt目录下 mount -t iso ...

随机推荐

  1. 初识DSP

    初识DSP 1.TI DSP的选型主要考虑处理速度.功耗.程序存储器和数据存储器的容量.片内的资源,如定时器的数量.I/O口数量.中断数量.DMA通道数等.DSP的主要供应商有TI,ADI,Motor ...

  2. Palindrome Partitioning——LeetCode

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  3. String的equals方法和==

    String类的对象是字符串常量,一切看起来改变了String对象的操作,其实只是改变了字符串引用变量所引用的字符串罢了. Java中的字符串存放在一个公共的存储池中,引用指向存储池中相应的位置,编译 ...

  4. 技能CDDemo(点击鼠标左键实现技能界面旋转)

    using UnityEngine; using System.Collections; using UnityEngine.UI; public class HealthController : M ...

  5. JSP具体篇——out

    out对象 out对象用于在web浏览器上输出信息,而且管理应用server上的输出缓冲区.在使用out对象输出数据时.能够对数据缓冲区进行操作.及时清除缓冲区中残留的数据.为其它输出让出缓冲空间. ...

  6. USACO lamps

    IOI 98称号.然后,它似乎没有很困难.即使我能做到这一点微弱的残留物.所有的button按两次不按,高达因此实际上总的等效按4二级,首先C往下<=4,则搜索将能直接照射,总共只有16状态(事 ...

  7. 修改MySQL引擎

    1. 显示MySQL支持的引擎:show engines;

  8. JS和利用openssl的object C加密得到相同的aes加密密文

    这是之前接到的一个工作内容,项目原本的登录操作是获得账号和密码以后,对密码进行一遍MD5加密,然后传递账号和密文到cgi文件.在c中获取到账户以后,从数据库中获取到密码,对密码进行一次MD5的加密,然 ...

  9. sql数据库之间数据的转录

    private void Form1_Load(object sender, EventArgs e) { BindDataBase(combDataBaseNew, , ""); ...

  10. form表单提交

    1.form表单提交.html页面失败 <%--客户端form--%> <form id="form2" action="LoginOne.html&q ...