1 搭建ubuntu 12.10源 web
如今讓咱們把sohu的ubuntu 12.10的源mirror到本地,先安裝apt-mirror工具: shell
apt-get install apt-mirror
/etc/apt/mirror.list mirror相關信息的配置 數據庫
因爲源的內容比較多,並且比較重要,全部同步下來的源內容咱們不放在本地磁盤,而是在共享存儲上劃出一塊空間,掛載在宿主機上,這樣在宿主機宕機或者硬盤故障的時候,可使共享存儲的內容在其餘宿主機上繼續發揮做用,本編中掛載在/opt/apt-source目錄下。 apache
set base_path /opt/apt-source set mirror_path $base_path/mirror set skel_path $base_path/skel set var_path $base_path/var set cleanscript $var_path/clean.sh set defaultarch <running host architecture> set postmirror_script $var_path/postmirror.sh set run_postmirror 0 set nthreads 40 set _tilde 0 deb-amd64 http://mirrors.sohu.com/ubuntu/ quantal main restricted universe multiverse deb-amd64 http://mirrors.sohu.com/ubuntu/ quantal-backports main restricted universe multiverse deb-amd64 http://mirrors.sohu.com/ubuntu/ quantal-proposed main restricted universe multiverse deb-amd64 http://mirrors.sohu.com/ubuntu/ quantal-security main restricted universe multiverse deb-amd64 http://mirrors.sohu.com/ubuntu/ quantal-updates main restricted universe multiverse deb-i386 http://mirrors.sohu.com/ubuntu/ quantal main restricted universe multiverse deb-i386 http://mirrors.sohu.com/ubuntu/ quantal-backports main restricted universe multiverse deb-i386 http://mirrors.sohu.com/ubuntu/ quantal-proposed main restricted universe multiverse deb-i386 http://mirrors.sohu.com/ubuntu/ quantal-security main restricted universe multiverse deb-i386 http://mirrors.sohu.com/ubuntu/ quantal-updates main restricted universe multiverse
開始在後臺同步sohu的源: ubuntu
nohup apt-mirror -c /etc/apt/mirror.list &
apt-get install apache2 cd /var/www ln -s /opt/apt-source/mirror/mirrors.sohu.com/ubuntu ubuntu把/etc/apt/sources.list文件的內容替換成以下(10.1.6.6):
deb http://10.1.6.6/ubuntu quantal main multiverse restricted universe deb http://10.1.6.6/ubuntu quantal-backports main multiverse restricted universe deb http://10.1.6.6/ubuntu quantal-proposed main multiverse restricted universe deb http://10.1.6.6/ubuntu quantal-updates main multiverse restricted universe deb http://10.1.6.6/ubuntu quantal-security main multiverse restricted universe
若是在設置mirror.list時,源設置的是'deb http://',則默認是同步64位的包,可是有些包安裝時須要32位的支持,因此還須要同步32位的源,就如上面配置文件設置。 centos
更新apt數據庫信息 緩存
apt-get update
2 搭建centos6源 工具
在搞定完ubuntu以後,想按照上面的思路把centos也搞定,google一番後,沒發現centos下有類似的工具,只能另換方法,決定直接從官方把整個源同步下來,到mirrors.kernel.org上一看,提供了三種方式mirror sources:HTTP、FTP、RSYNC,那就用rsync把它所有同步下來吧。 post
經過下面腳本進行同步 google
#!/bin/sh #rsync -avzL --delete -stats rsync://mirrors.kernel.org/centos/6/ /opt/apt-source/centos6/ rsync="/usr/bin/rsync -avzL --delete" mirror=rsync://mirrors.kernel.org/centos ver=6 arch="x86_64 i386" base="os updates centosplus isos fasttrack extras cr contrib" local=/opt/apt-source/centos6 for arch in $arch do for base in $base do remote=$mirror/$ver/$base/$arch/ if [ ! -e $local/$base/$arch ]; then mkdir -p "$local/$base/$arch" fi $rsync $remote $local/$base/$arch/ done done
[base] name=CentOS - Base baseurl=http://10.1.6.6/centos/6/os/$basearch/ gpgcheck=1 gpgkey=http://10.1.6.6/centos/6/os/$basearch/RPM-GPG-KEY-CentOS-6 #released updates [update] name=CentOS - Updates baseurl=http://10.1.6.6/centos/6/updates/$basearch/ gpgcheck=1 gpgkey=http://10.1.6.6/centos/6/os/$basearch/RPM-GPG-KEY-CentOS-6 #released extras [extras] name=CentOS - Extras baseurl=http://10.1.6.6/centos/6/extras/$basearch/ gpgcheck=1 gpgkey=http://10.1.6.6/centos/6/os/$basearch/RPM-GPG-KEY-CentOS-6 #released CentOSPlus [centosplus] name=CentOS - CentOSPlus baseurl=http://10.1.6.6/centos/6/centosplus/$basearch/ gpgcheck=1 gpgkey=http://10.1.6.6/centos/6/os/$basearch/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS - Contrib baseurl=http://10.1.6.6/centos/6/contrib/$basearch/ gpgcheck=1 gpgkey=http://10.1.6.6/centos/6/os/$basearch/RPM-GPG-KEY-CentOS-6更新yum源緩存信息
yum clean all yum makecache