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

全部博文(120)

文章存档

2010年(84)

2009年(36)

我的朋友

分类: LINUX

2009-12-19 02:04:28

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

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源同步服务器可在下面链接查找:


rsync -aqzH --delete --delay-updates rsync://mirror.centos.net.cn/centos/5/  /var/ftp/pub/CentOS

 rsync -aqzH --delete --delay-updates rsync://mirrors.163.com/centos/5.4/  /var/ftp/pub/CentOS


[root@host66 ~]# cat /etc/yum.repos.d/ftp-host66.repo
[updates]
name=CentOS-$releasever - updates
baseurl=ftp://192.168.5.66/pub/CentOS/updates
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[base]
name=CentOS-$releasever - base
baseurl=ftp://192.168.5.66/pub/CentOS/os
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[fasttrack]
name=CentOS-$releasever - fasttrack
baseurl=ftp://192.168.5.66/pub/CentOS/fasttrack
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[extras]
name=CentOS-$releasever - extras
baseurl=ftp://192.168.5.66/pub/CentOS/extras
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[contrib]
name=CentOS-$releasever - contrib
baseurl=ftp://192.168.5.66/pub/CentOS/contrib
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[centosplus]
name=CentOS-$releasever - centosplus
baseurl=ftp://192.168.5.66/pub/CentOS/centosplus
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[addons]
name=CentOS-$releasever - addons
baseurl=ftp://192.168.5.66/pub/CentOS/addons
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5












以下内容来自网络::

CentOS5构建本地yum仓库 由Linux系统中文网(Linux521.com)编辑收集整理,除Linux521注明原创文章外,其版权归原作者所有。如果您在学习中遇到问题欢迎在下面的评论中留言,我们会尽全力解答您的问题。;项目中大量使用CentOS5作为运行平台,测试需要经常安装系统,每次要升级的文件越来越多,构建内部仓库一来方便安装,二来方便升级。。。

[服务端]

创建基本仓库,copy DVD或者CD文件(减少网络下载量)

Copy the RPMs from the CDs/DVD to /var/www/html/centos/5/base.

1. mount -o loop,ro CentOS-xxxxx.iso /mnt

2. cp -r /mnt /var/www/html/centos/5/base
同步远端仓库

3./usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5/os/i386/ /var/www/html/centos/5/os/i386/

同步update仓库

例子:

/usr/bin/rsync -avrt rsync://rsync.muug.mb.ca/centos/5/updates/i386/ /opt/repos/yum/centos/5/updates/i386/

镜像在这里的列表中选中快的




客户端使用仓库

[base]
name=CentOS-$releasever - Base
baseurl=
#mirrorlist=
#baseurl=
gpgcheck=1
gpgkey=
#released updates

[update]
name=CentOS-$releasever - Updates
baseurl=
#mirrorlist=
#baseurl=
gpgcheck=1
gpgkey=

===================================================================================================================================================

11推出后,Linux在桌面上的易用性大为提高,具备在办公/开发的可能性。
但才发布几天,yum update要下载的包竟然接近200M, 没办法,这是开源软件无法避免的,补丁频繁肯定。
为了避免内网机器重复下载相同文件,可以创建一个升级仓库内网私用。
-
[服务端仓库创建和配置]
1.安装创建仓库的工具
yum install createrepo


2.创建目录结构
mkdir -p /xxxxxxx/repos/yum//base/11/i386
mkdir -p /xxxxxxx/repos/yum//updates/11/i386
注:/xxxxxxx/是任意选定的文件系统路径

3.复制DVD的文件到到base目录
mount -o loop,ro 11-i386-DVD.iso /mnt/iso
cp -v /mnt/iso/Packages/* /xxxxxxx/repos/yum//base/11/i386
umount /mnt/iso

4.DVD光盘只包含基本的安装包集合,如果需要安装包,先执行下面:(不同镜像任选其一)
rsync -avrt –progress rsync://ftp.jaist.ac.jp/pub/Linux//releases/11/Everything/i386/os/Packages/ /xxxxxxx/repos/yum/fedora/base/11/i386
rsync -avrt –progress rsync://mirror.anl.gov//linux/releases/11/Everything/i386/os/Packages/ /xxxxxxx/repos/yum/fedora/base/11/i386
1rsync语法要求严格,目录同步不能缺少源路径最后的”/”
2:请在页面中中找一个合用的rsync镜像

5.创建仓库所需要的数据结构文件
createrepo /xxxxxxx/repos/yum//base/11/i386
会生成/xxxxxxx/repos/yum//base/11/i386/repodata目录,里面包含若干xmlgz文件

6.同步updates目录
rsync -avrt –progress rsync://ftp.jaist.ac.jp/pub/Linux//updates/11/i386/ –exclude=debug/ /xxxxxxx/repos/yum/fedora/updates/11/i386

7.生成cron任务定期自动更新updates
crontab -e (每天晚上240分更新)
40 2 * * * /usr/bin/rsync -avrt rsync://mirror.anl.gov//linux/updates/8/i386/ –exclude=debug/ /xxxxxxx/repos/yum/fedora/updates/11/i386

8.配置httpd供访问

基本上就是生成别名或命名虚拟主机方式进行访问了
下面是基于名称的虚拟主机的配置方式
cat 000-default
NameVirtualHost *:80

DocumentRoot “/var/www/html”

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all



ServerAdmin admin@localdomain
DocumentRoot /xxxxx/repos
ServerName updates.domain.net
DirectoryIndex index.html
LogLevel debug
ErrorLog logs/updates.domain.net-error_log
CustomLog logs/updates.domain.net-access_log common

 
Options Indexes
Order allow,deny
allow from all

[客户端配置]
touch /etc/yum.repos.d/local.repos

vi /etc/yum.repos.d/local.repos
内容如下:
[base-local]
name= $releasever - $basearch
failovermethod=priority
baseurl=/base/$releasever/$basearch



enabled=1
gpgcheck=0

[updates-local]
name= $releasever - $basearch - Updates
failovermethod=priority
baseurl=/updates/$releasever/$basearch/
enabled=1
gpgcheck=0

最后把原来的repos文件中baseupdates有关的改为enabled=0
然后在客户端执行yum update可以体验本地飞速update~~…


CentOS5构建本地yum仓库
项目中大量CentOS5作为运行平台,测试需要经常安装系统,每次要升级的文件越来越多,构建内部仓库一来方便安装,二来方便升级。。。

[]
创建基本仓库,copy DVD或者CD文件(减少网络下载量)
Copy the RPMs from the CDs/DVD to /var/www/html/centos/5/base.
1. mount -o loop,ro CentOS-xxxxx.iso /mnt
2. cp -r /mnt /var/www/html/centos/5/base
同步远端仓库
3./usr/bin/rsync -avrt –delete rsync://rsync.muug.mb.ca/centos/5/os/i386/ /var/www/html/centos/5/os/i386/
同步update仓库
例子:
/usr/bin/rsync -avrt rsync://rsync.muug.mb.ca/centos/5/updates/i386/ /opt/repos/yum/centos/5/updates/i386/

镜像在这里的列表中选中快的

客户端使用仓库

[base]
name=CentOS-$releasever - Base
baseurl=
#mirrorlist=
#baseurl=
gpgcheck=1
gpgkey=
#released updates

[update]
name=CentOS-$releasever - Updates
baseurl=
#mirrorlist=
#baseurl=
gpgcheck=1
gpgkey=

http://hi.baidu.com/suantop/blog/item/7f82e9b549d2a6c436d3ca99.html

在公网的服务器中找一个apache发布一个目录
例如/var/www/html/centos

找一台速度较快的带rsync服务的镜像网站


同步需要的软件到web目录下,例如:(由于系统的32位的,我屏蔽了x86_64目录,debug的东西也用不到,所以也屏蔽了debug,还需要有屏蔽,自己根据需要来,--exclude支持正则的 :))

# rsync -avrt rsync://centos.ustc.edu.cn/centos/5.4/ --exclude=debug/ --exclude=x86_64/ --exclude=isos/ /var/www/html/centos/5.4/

公网也很快 所以可以全部下载只是不要x86_64


# rsync -avrt rsync://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 /var/www/html/centos5.4/

然后到
/etc/yum.repos.d/

# wget

# cp CentOS-Base.repo.5 CentOS-Base.repo
把里面内容的baseurl替换为自己的

然后就可以客户端升级了

wget
wget



/os/i386/CentOS/centos-release-5-4.el5.centos.1.i386.rpm

在公网的服务器中找一个apache发布一个目录

下面尝试下载一个文件
rsync -avrt rsync://centos.ustc.edu.cn/centos/5.4/os/i386/CentOS/centos-release-5-4.el5.centos.1.i386.rpm /var/www/html
-a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD
-v, --verbose 详细模式输出
-r, --recursive 对子目录以递归模式处理
-t, --times 保持文件时间信息


列远程机的文件列表。这类似于rsync传输,不过只要在命令中省略掉本地机信息即可。如:rsync -v rsync://172.16.78.192/www

[root@mail html]# rsync -avrt rsync://mirror.averse.net/centos/RPM-GPG-KEY-CentOS-5 /var/www/html/
[root@mail html]# rsync -avrt rsync://centos.ustc.edu.cn/centos/5.4/os/i386/CentOS/centos-release-5-4.el5.centos.1.i386.rpm /var/www/html/









# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=
gpgcheck=1
gpgkey=

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=
gpgcheck=1
gpgkey=

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=
gpgcheck=1
gpgkey=

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=
gpgcheck=1
gpgkey=

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=
gpgcheck=1
enabled=0
gpgkey=

19. 01.

1.事实上,很多时候会用到本地的yum服务器,不仅仅是因为国内的镜像少,速度慢,不连线到公网的机器有时候也有这个必要

2.本文是以实际环境为例,简单的说明一下配置情况,办法很土,呵呵

3.环境(CentOS 5 32位)
一台web服务器,在公网,内网ip192.168.1.7
另外一台db服务器只在内网,ip192.168.1.8

4.找一台速度较快的带rsync服务的镜像网站
从这里找:

我选了新加坡的一个:rsync://mirror.averse.net/centos/5.2/ 具体根据自己的网络情况而定

5.192.168.1.7正好是web服务器,直接就可以利用,找一个web目录,例如:/www/wwwroot/yum 随便绑定个域名,例如:
# mkdir -p /www/wwwroot/yum
192.168.1.8/etc/hosts里指定192.168.1.7,这样访问就可以直接访问此目录

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:///yum/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5

#released updates
[update]
name=CentOS-5 - Updates
baseurl=http:///yum/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-5 - Addons
baseurl=http:///yum/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5 - Extras
baseurl=http:///yum/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 - Plus
baseurl=http:///yum/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-5 - Contrib
baseurl=http:///yum/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5

#packages in testing
[testing]
name=CentOS-5 - Testing
baseurl=http:///yum/centos/5/testing/$basearch/
gpgcheck=1
enabled=0
gpgkey=http:///yum/centos/RPM-GPG-KEY-CentOS-5

8.在内网192.168.1.8上就可以正常使用yum来安装或者升级软件啦

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/updates/i386/ /opt/CentOS/updates/

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/addons/i386/ /opt/CentOS/addons

/

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/centosplus/i386/ /opt/CentOS/centosplus/

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/extras/i386/ /opt/CentOS/extras/

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/fasttrack/i386/ /opt/CentOS/fasttrack/

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/os/i386/i386/ /opt/CentOS/os/

/usr/bin/rsync -avrt --delete rsync://rsync.muug.mb.ca/centos/5.4/updates/i386/ /opt/CentOS/updates/

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