Chinaunix首页 | 论坛 | 博客
  • 博客访问: 324374
  • 博文数量: 120
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 1290
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-19 01:46
文章分类

全部博文(120)

文章存档

2010年(84)

2009年(36)

我的朋友

分类:

2010-03-10 15:57:50

通过NFS共享YUM源的实现方法               by sunzz 2010-03-10


服务器端:
1.服务器上YUM源同步网络YUM源
[root@host66 ~]# crontab -l
# rsync yum source
00 02 * * * /usr/bin/rsync -aqrtzH --delete --exclude=SRPMS/ --exclude=x86_64/ --exclude=isos/ rsync://rsync.muug.mb.ca/centos/5.4/  /var/ftp/pub/centos/i386/

2.服务器通过NFS共享YUM源
[root@host66 ~]# cat /etc/exports  
/var/ftp/pub/cnetos/i386  *(ro,sync)

客户端:
1.将NFS源共享到本地:(有三种方法)
a.直接 mount 192.168.5.66:/var/ftp/pub/centos/i386 /var/ftp/pub/cnetos/i386 ,可将挂载写到/etc/rc.local(同前面的那样)
b.写到/etc/fstab中   192.168.5.66:/var/ftp/pub/centos/i386    /var/ftp/pub/centos/i386   nfs   ro,intr   0  0
c.通过autofs实现自动挂载
[root@host66 ~]# echo '/var/ftp/pub/centos/ /etc/auto.nfs' >> /etc/auto.master
[root@host66 ~]# echo 'i386 -fstype=nfs 192.168.5.66:/var/ftp/pub/centos/i386' >> /etc/auto.nfs
[root@host66 ~]# chkconfig autofs on
[root@host66 ~]# service autofs restart
2.配置.repo文件(备份/etc/yum.repos.d目录中所有文件到别的地方,然后将下面的写到里面)
[root@host66 ~]# cat /etc/yum.repos.d/local.repo
[updates]
name=CentOS-$releasever - Updates
baseurl=file:///var/ftp/pub/centos/i386/updates/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[base]
name=CentOS-$releasever - base
baseurl=file:///var/ftp/pub/centos/i386/os/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[fasttrack]
name=CentOS-$releasever - fasttrack
baseurl=file:///var/ftp/pub/centos/i386/fasttrack/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[extras]
name=CentOS-$releasever - extras
baseurl=file:///var/ftp/pub/centos/i386/extras/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[contrib]
name=CentOS-$releasever - contrib
baseurl=file:///var/ftp/pub/centos/i386/contrib/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[centosplus]
name=CentOS-$releasever - centosplus
baseurl=file:///var/ftp/pub/centos/i386/centosplus/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[addons]
name=CentOS-$releasever - addons
baseurl=file:///var/ftp/pub/centos/i386/addons/i386
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

好了,整个配置完成了,客户端可以正常使用YUM安装软件了



------------------------------------------------------------------------

以下部分是比较快的源同步实例:(测试均 通过)

rsync -avrtzH --delete --exclude=SRPMS/ --exclude=x86_64/ --exclude=isos/ rsync://rsync.kddilabs.jp/centos/5.4/  /tmp/centos/
rsync -avrtzH --delete --exclude=SRPMS/ --exclude=x86_64/  --exclude=isos/ rsync://rsync.muug.mb.ca/centos/5.4/  /tmp/centos/
rsync -avrtzH --delete --exclude=SRPMS/ --exclude=x86_64/ --exclude=isos/ rsync://mirror.aarnet.edu.au/centos/5.4/  /tmp/centos/

RSYNC源同步服务器可在下面链接查找:

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