1.事实上,很多时候会用到本地的yum服务器,不仅仅是因为国内的镜像少,速度慢,不连线到公网的机器有时候也有这个必要
2.本文是以实际环境为例,简单的说明一下配置情况,办法很土,呵呵
3.环境(CentOS 5 32位)
一台web服务器,在公网,内网ip是192.168.1.7
另外一台db服务器只在内网,ip是192.168.1.8
4.找一台速度较快的带rsync服务的镜像网站
从这里找:http://www.centos.org/modules/tinycontent/index.php?id=13
我选了新加坡的一个:rsync://mirror.averse.net/centos/5.2/ 具体根据自己的网络情况而定
5.192.168.1.7正好是web服务器,直接就可以利用,找一个web目录,例如:/www/wwwroot/yum 随便绑定个域名,例如:www.yum.com、
# mkdir -p /www/wwwroot/yum
在192.168.1.8上/etc/hosts里指定www.yum.com到192.168.1.7,这样访问www.yum.com就可以直接访问此目录
6.同步需要的软件到web目录下,例如:(由于系统的32位的,我屏蔽了x86_64目录,debug的东西也用不到,所以也屏蔽了debug,还需要有屏蔽,自己根据需要来,–exclude支持正则的 :))
# rsync -avrt rsync://mirror.averse.net/centos/5.2/ --exclude=debug/ --exclude=x86_64/ --exclude=isos/ /www/wwwroot/yum/centos/5/
# rsync -avrt rsync://mirror.averse.net/centos/RPM-GPG-KEY-CentOS-5 /www/wwwroot/yum/centos/
等待完成……
完成了之后,可以做一个计划任务,隔段时间更新一下,
7.在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
8.在内网192.168.1.8上就可以正常使用yum来安装或者升级软件啦
嘟嘟鱼
新年快乐!