[zz]搭建centos6.0本地yum源(32位)

也可以直接 wget -c -r -np -e robots=off  http://vault.centos.org/6/os/x86_64/

               wget -c -r -np -e robots=off http://mirrors.sohu.com/centos/6/os/x86_64/

-c 断点续传 
-r 递归下载,下载指定网页某一目录下(包括子目录)的所有文件 
-nd 递归下载时不创建一层一层的目录,把所有的文件下载到当前目录 
-np 递归下载时不搜索上层目录。

-e robots=off  忽略robots协议

1.同步源到本地服务器

rsync -avzLP --delete --exclude=SRPMS/ --exclude=x86_64/ --exclude=isos/ rsync://mirrors.sohu.com/centos/6.0/ /opt/centos/i386/

sohu的源同步好像有点慢,这里有个加拿大的源,速度还可以

rsync -avzLP --delete --exclude=SRPMS/ --exclude=x86_64/ --exclude=isos/ rsync://rsync.muug.mb.ca/centos/6.0/ /opt/centos/i386/

2.搭建本地web服务(apache)

  • 在Apache中加上下面的虚拟机
<VirtualHost *:80>
DocumentRoot /opt/centos
<Directory "/opt/centos">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

3.编辑本地YUM服务器所使用的.repo文件 vim /etc/yum.repos.d/CentOS-Base.repo (当然,编辑之前最好备份一份)

[updates]
name=CentOS-$releasever - updates
baseurl=http://192.168.5.30/$basearch/updates/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[base]
name=CentOS-$releasever - base
baseurl=http://192.168.5.30/$basearch/os/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[fasttrack]
name=CentOS-$releasever - fasttrack
baseurl=http://192.168.5.30/$basearch/fasttrack/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-$releasever - extras
baseurl=http://192.168.5.30/$basearch/extras/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[contrib]
name=CentOS-$releasever - contrib
baseurl=http://192.168.5.30/$basearch/contrib/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[centosplus]
name=CentOS-$releasever - centosplus
baseurl=http://192.168.5.30/$basearch/centosplus/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[addons]
name=CentOS-$releasever - addons
baseurl=http://192.168.5.30/$basearch/addons/$basearch
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

说明: 上面的 192.168.5.30 是本地yum源服务器IP, gpgkey一定要是 RPM-GPG-KEY-CentOS-6,如果没有 请下载

wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

然后将这个新的 CentOS-Base.repo 下载到需要客户机上的/etc/yum.repos.d/ 下面, 执行 yum clean all , yum update 就可以升级了

就是如此简单.

posted @ 2012-05-27 14:42  zaleilynn  阅读(292)  评论(0编辑  收藏  举报