环境:
CentOS 5 32位
一台web服务器,在公网,内网ip是192.168.1.7
另外一台db服务器只在内网,ip是192.168.1.8
1,找一台速度较快的带rsync服务的镜像网站
从这里找:http://www.centos.org/modules/tinycontent/index.php?id=13
选了新加坡的一个:rsync://mirror.averse.net/centos/5.2/ 具体根据自己的网络情况而定
2,192.168.1.7正好是web服务器,直接就可以利用,找一个web目录,例如:/www/wwwroot/yum 随便绑定个域名,例如:www.yum.com、
在192.168.1.8上/etc/hosts里指定www.yum.com到192.168.1.7,这样访问www.yum.com就可以直接访问此目录
3,同步需要的软件到web目录下,例如:(由于系统的32位的,我屏蔽了x86_64目录,debug的东西也用不到,所以也屏蔽了debug,还需要有屏蔽,自己根据需要来,--exclude支持正则的 :))
等待完成……
完成了之后,可以做一个计划任务,隔段时间更新一下,
4,在192.168.1.8上配置yum,打开/etc/yum.repos.d/CentOS-Base.repo
替换内容:
[base]
name=CentOS-5 - Base
baseurl=http://www.yum.com/yum/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
#released updates
[update]
name=CentOS-5 - Updates
baseurl=http://www.yum.com/yum/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 - Addons
baseurl=http://www.yum.com/yum/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5 - Extras
baseurl=http://www.yum.com/yum/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 - Plus
baseurl=http://www.yum.com/yum/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5 - Contrib
baseurl=http://www.yum.com/yum/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
#packages in testing
[testing]
name=CentOS-5 - Testing
baseurl=http://www.yum.com/yum/centos/5/testing/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://www.yum.com/yum/centos/RPM-GPG-KEY-CentOS-5
5,在内网192.168.1.8上,即可正常使用yum来安装或升级软件了。
使用本地yum源服务器的好处就是速度快,呵呵。