搭建Debian7&&openstack私有源

      Debian7的正式版已经发布了,虽然debian官方已经有指定的中国地区的官方源,但是为了加快软件包的安装速度,决定搭建一套公司自己的源,之所以用debian7,主要是ubuntu12.10和新的硬件磨合起来问题有点多,而又想使用openstack,所以需要用debian7,debian还是很稳定的。

    之前讲过ubuntu和centos的源的搭建,所以打算用apt-mirror同步一个源,apt-mirror用法可以参考http://my.oschina.net/guol/blog/113146

    Debian中国官方源地址:http://ftp.cn.debian.org/debian

下面开始配置/etc/apt/mirror.list配置文件:

############# config ##################
 set base_path    /opt/mirror/debian7
 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
############# end config ##############
###mirror additional architectures
deb-amd64 http://ftp.cn.debian.org/debian wheezy main contrib non-free
deb-i386 http://ftp.cn.debian.org/debian wheezy main contrib non-free
deb-amd64 http://ftp.cn.debian.org/debian wheezy-updates main contrib non-free
deb-i386 http://ftp.cn.debian.org/debian wheezy-updates main contrib non-free
deb-amd64 http://ftp.cn.debian.org/debian/ wheezy-proposed-updates main contrib non-free
deb-i386 http://ftp.cn.debian.org/debian/ wheezy-proposed-updates main contrib non-free
deb-amd64 http://ftp.cn.debian.org/debian wheezy-backports main contrib non-free
deb-i386 http://ftp.cn.debian.org/debian wheezy-backports main contrib non-free
   在官网上面有alpha, amd64, arm, armel, armhf, hppa, hurd-i386, i386, ia64, kfreebsd-amd64,kfreebsd-i386, m68k, mipsel, mips, powerpc, s390, s390x, sh, sparc,source等体系架构的源,我们只需要同步i386和amd64架构的即可。


    开始同步之后速度还是很快的,根据我mirror.list的设置,我的源同步到本地的/opt/mirror/debian7目录下,在/opt/mirror/debian7/mirror/ftp.cn.debian.org/debian里面可以看到两个目录,一个dist,一个pool,dist里面是debian7的版本更新类wheezy、wheezy-backports、wheezy-proposed-updates、wheezy-updates,每个目录里面是包列表和认证信息,而真正的软件包是在pool目录里面的。

下来开始同步openstack的包信息:

    为什么要同步openstack,因为debian7自带的openstack版本有点老,而且更新有点慢,而openstack半年一个大版本,为了尝试新功能,所以需要搞一个更新快的openstack源。openstack包信息可以在archive.gplhost.com该网站同步。openstack的包比较小,这次我换一种方法同步,该网站提供了ftp更新方法,所以这次用lftp的mirror功能把openstack的包同步下来,同步下来的openstack包放在/opt/mirror/openstack目录下,同步操作如下:

lftp archive.gplhost.com
cd debian/pool
mirror -c -e -n openstack /opt/mirror/openstack/pool/
cd ../dists
mirror -c -e -n openstack /opt/mirror/openstack/dists/
cd ..
mirror -c -e -n repository_key.asc /opt/mirror/openstack/
quit
   可以看到openstack的包分别同步到pool和dists目录下了,这时候所需要的包就同步到本地了,开始可以搭建web服务器了

apt-get -y install apache2
    配置web的html内容

cd /var/www
ln -s /opt/mirror/debian7/mirror/ftp.cn.debian.org/debian debian7
ln -s /opt/mirror/openstack openstack
   修改/etc/apt/sources.list配置文件如下:192.168.34.34是我源服务器的IP

deb http://192.168.34.34/debian7 wheezy main contrib non-free
deb http://192.168.34.34/debian7 wheezy-updates main contrib non-free
deb http://192.168.34.34/debian7 wheezy-proposed-updates main contrib non-free
deb http://192.168.34.34/debian7 wheezy-backports main contrib non-free
deb http://192.168.34.34/openstack openstack main
  开始更新apt数据库信息

[email protected]:apt# apt-get update
Hit http://192.168.34.34 wheezy Release.gpg
Hit http://192.168.34.34 wheezy-updates Release.gpg
Hit http://192.168.34.34 wheezy-proposed-updates Release.gpg
Hit http://192.168.34.34 wheezy-backports Release.gpg
Get:1 http://192.168.34.34 openstack Release.gpg [198 B]
Hit http://192.168.34.34 wheezy Release
Hit http://192.168.34.34 wheezy-updates Release
Hit http://192.168.34.34 wheezy-proposed-updates Release
Hit http://192.168.34.34 wheezy-backports Release
Hit http://192.168.34.34 openstack Release     
Hit http://192.168.34.34 wheezy/main amd64 Packages
Hit http://192.168.34.34 wheezy/contrib amd64 Packages
Hit http://192.168.34.34 wheezy/non-free amd64 Packages
Ign http://192.168.34.34 wheezy/contrib Translation-en
Ign http://192.168.34.34 wheezy/main Translation-en
Ign http://192.168.34.34 wheezy/non-free Translation-en
Ign http://192.168.34.34 openstack Release      
Hit http://192.168.34.34 wheezy-updates/main amd64 Packages
Hit http://192.168.34.34 wheezy-updates/contrib amd64 Packages
Hit http://192.168.34.34 wheezy-updates/non-free amd64 Packages
Hit http://192.168.34.34 wheezy-updates/contrib Translation-en
Hit http://192.168.34.34 wheezy-updates/main Translation-en
Hit http://192.168.34.34 wheezy-updates/non-free Translation-en
Get:2 http://192.168.34.34 wheezy-proposed-updates/main amd64 Packages/DiffIndex [7,819 B]
Hit http://192.168.34.34 wheezy-proposed-updates/contrib amd64 Packages
Get:3 http://192.168.34.34 wheezy-proposed-updates/non-free amd64 Packages/DiffIndex [229 B]
Hit http://192.168.34.34 wheezy-proposed-updates/contrib Translation-en
Get:4 http://192.168.34.34 wheezy-proposed-updates/main Translation-en/DiffIndex [7,819 B]
Get:5 http://192.168.34.34 wheezy-proposed-updates/non-free Translation-en/DiffIndex [229 B]
Hit http://192.168.34.34 wheezy-backports/main amd64 Packages
Hit http://192.168.34.34 wheezy-backports/contrib amd64 Packages
Hit http://192.168.34.34 wheezy-backports/non-free amd64 Packages
Hit http://192.168.34.34 wheezy-backports/contrib Translation-en
Hit http://192.168.34.34 wheezy-backports/main Translation-en
Hit http://192.168.34.34 wheezy-backports/non-free Translation-en
Ign http://192.168.34.34 openstack/main amd64 Packages/DiffIndex
Hit http://192.168.34.34 openstack/main amd64 Packages
Ign http://192.168.34.34 openstack/main Translation-en_US
Ign http://192.168.34.34 openstack/main Translation-en
Fetched 16.3 kB in 0s (127 kB/s)
Reading package lists... Done
W: GPG error: http://192.168.34.34 openstack Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 64AA94D00B849883
    发现后面的openstack没经过认证,进行如下操作进行认证:

[email protected]:apt-get install debian-keyring
[email protected]:gpg --keyring  /usr/share/keyrings/debian-keyring.gpg --recv-keys 64AA94D00B849883
gpg: requesting key 0B849883 from hkp server keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 0B849883: public key "Thomas Goirand (GPLHost Debian repo key) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1

[email protected]:gpg -a --export 64AA94D00B849883 | apt-key add -
OK
    再次进行更新

[email protected]:apt# apt-get update
Hit http://192.168.34.34 wheezy Release.gpg
Hit http://192.168.34.34 wheezy-updates Release.gpg
Hit http://192.168.34.34 wheezy-proposed-updates Release.gpg
Hit http://192.168.34.34 wheezy-backports Release.gpg
Get:1 http://192.168.34.34 openstack Release.gpg [198 B]
Hit http://192.168.34.34 wheezy Release
Hit http://192.168.34.34 wheezy-updates Release
Hit http://192.168.34.34 wheezy-proposed-updates Release
Hit http://192.168.34.34 wheezy-backports Release
Hit http://192.168.34.34 openstack Release     
Hit http://192.168.34.34 wheezy/main amd64 Packages
Hit http://192.168.34.34 wheezy/contrib amd64 Packages
Hit http://192.168.34.34 wheezy/non-free amd64 Packages
Ign http://192.168.34.34 wheezy/contrib Translation-en
Ign http://192.168.34.34 wheezy/main Translation-en
Ign http://192.168.34.34 wheezy/non-free Translation-en
Hit http://192.168.34.34 wheezy-updates/main amd64 Packages
Hit http://192.168.34.34 wheezy-updates/contrib amd64 Packages
Hit http://192.168.34.34 wheezy-updates/non-free amd64 Packages
Hit http://192.168.34.34 wheezy-updates/contrib Translation-en
Hit http://192.168.34.34 wheezy-updates/main Translation-en
Hit http://192.168.34.34 wheezy-updates/non-free Translation-en
Hit http://192.168.34.34 wheezy-proposed-updates/main amd64 Packages/DiffIndex
Hit http://192.168.34.34 wheezy-proposed-updates/contrib amd64 Packages
Hit http://192.168.34.34 wheezy-proposed-updates/non-free amd64 Packages/DiffIndex
Hit http://192.168.34.34 wheezy-proposed-updates/contrib Translation-en
Hit http://192.168.34.34 wheezy-proposed-updates/main Translation-en/DiffIndex
Hit http://192.168.34.34 wheezy-proposed-updates/non-free Translation-en/DiffIndex
Hit http://192.168.34.34 wheezy-backports/main amd64 Packages
Hit http://192.168.34.34 wheezy-backports/contrib amd64 Packages
Hit http://192.168.34.34 wheezy-backports/non-free amd64 Packages
Hit http://192.168.34.34 wheezy-backports/contrib Translation-en
Hit http://192.168.34.34 wheezy-backports/main Translation-en
Hit http://192.168.34.34 wheezy-backports/non-free Translation-en
Hit http://192.168.34.34 openstack/main amd64 Packages
Ign http://192.168.34.34 openstack/main Translation-en_US
Ign http://192.168.34.34 openstack/main Translation-en
Fetched 198 B in 0s (1,538 B/s)
Reading package lists... Done
[email protected]:apt#
    这样就更新正常了...


你可能感兴趣的:(源,私有,debian7)