月度归档:2011年03月

站群建设方案猜想

 
 
一,内容获取


(1)关键词
指定基本关键词,以“减肥”为例。通过各大搜索引擎搜索基本关键词时显示的相关搜索,扩展关键词,也就是长尾词。继续以长尾词进行扩展,再次得到的长尾词判断是否包含基本关键词,如“减肥”,如果包含,保存此关键词。按此方法嵌套扩展所有关键词。
(2)抓取网页地址
用库中保存的关键字从各大搜索引擎抓取搜索结果中的网址。
(3)抓取内容
利用正文提取算法,提取正文。提取正文后,根据多种情况判断提取后的正文是否为可用的正文,比如,排除列表页面,排除不规范页面。
(4)小结
上面所提到的内容基本没有技术难度,熟悉脚本编程的很容易写出整套程序。
关于能获取到的内容数据量。以“减肥”为例,可以扩展长尾词3万个以上,每个词可以抓到取2000个以上的网页网址,去除重复,去除正文不可用网址。至少有1000以上。也就是说,整套程序写好后,指定“减肥”这个词,3000万篇相关主题的文章,轻松到手,一个采集规则都不用写。
这些只是最基本的思路,成熟的蜘蛛程序需要做的远不止这些。

二,硬件投入


主要的两个需要解决的问题:1、大量域名,2、大量IP。
本人认为最佳的解决方案:
(1)国内机房投入高配机器,CPU处理能力要强,硬盘容量要大,RAID10必备,保证数据安全的同时提高机器性能。初期机器要数台,中期要数十台,后期要数百台甚至更多。
(2)美国机房准备好稳定的服务器,配置要低,降低成本,分配到的IP数量一定要多,越多越好,反向代理到国内的机器上。
把数据放在国内,并且集中在一起,是为了在特殊情况人可以方便进入机房进行处理。本文中的方案如果实施的话,每天增加的文章数量将以百万千万计,数据量以数G甚至数十G计,这样的数据量放到国外,传输都成问题,如果分散,也不方便管理。
发展中期,必须搞定门路,可以大批量域名bei案,以应对可能发生的百度对国外IP的特殊处理,在必要的时候可以在国内购入大量虚拟空间进行变相的反向代理(原理同小偷,不过全部原文输出,不需要使用正则处理,执行效率无压力)。

三,人员投入(初期)


(1)程序员,2-3名。
负责蜘蛛程序开发。
(2)网站主题策划,3-5名。
负责规划网站类型、主题、以及指定相关关键字。同时需要熟悉CMS程序安装,基本设置。
(3)SEOer,3-5名。
任务只有一个,搞定百度。
(4)服务器系统维护管理员,1名。

四,站群目标


三年内,至少要有1万个网站成活,揽入国内10分之1的网络访问量,月盈利8位数。

最后,这可以当作科幻文章看看,有人打算实施的话,发家了我不求报酬,赔光家底别来找我就成。
不过,早以N年前,就有人以团队方式运作过站群,这是真的。

测试Atom处理器上小鸡的性能

母鸡atomN270,1G RAM,ubuntu8.04 server,无X界面.
小鸡196M RAM,128M swap,1G disk,debian lenny.
========================================================================
   BYTE UNIX Benchmarks (Version 5.1.2)

   System: vm01: GNU/Linux
   OS: GNU/Linux — 2.6.24-28-xen — #1 SMP Fri Feb 11 18:08:50 UTC 2011
   Machine: i686 (unknown)
   Language: en_US.utf8 (charmap="ANSI_X3.4-1968", collate="ANSI_X3.4-1968")
   CPU 0: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (3211.8 bogomips)
          Hyper-Threading, MMX, Physical Address Ext
   21:00:05 up  7:48,  1 user,  load average: 0.37, 0.11, 0.03; runlevel 2

————————————————————————
Benchmark Run: Sun Mar 13 2011 21:00:05 – 21:28:24
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables        3956963.5 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                      542.5 MWIPS (10.1 s, 7 samples)
Execl Throughput                                736.5 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        146061.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           42203.5 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        385825.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                              304830.5 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  54291.2 lps   (10.0 s, 7 samples)
Process Creation                               1680.6 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   1055.6 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    141.7 lpm   (60.1 s, 2 samples)
System Call Overhead                         421064.3 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    3956963.5    339.1
Double-Precision Whetstone                       55.0        542.5     98.6
Execl Throughput                                 43.0        736.5    171.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     146061.5    368.8
File Copy 256 bufsize 500 maxblocks            1655.0      42203.5    255.0
File Copy 4096 bufsize 8000 maxblocks          5800.0     385825.4    665.2
Pipe Throughput                               12440.0     304830.5    245.0
Pipe-based Context Switching                   4000.0      54291.2    135.7
Process Creation                                126.0       1680.6    133.4
Shell Scripts (1 concurrent)                     42.4       1055.6    249.0
Shell Scripts (8 concurrent)                      6.0        141.7    236.1
System Call Overhead                          15000.0     421064.3    280.7
                                                                   ========
System Benchmarks Index Score                                         233.5

下面是2K3系统下Vmware虚拟linux的性能,256M RAM,得分只有103.9。XEN完胜。
http://wifizoo.net/?post=165

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.2)

   System: ubuntu: GNU/Linux
   OS: GNU/Linux — 2.6.24-16-server — #1 SMP Thu Apr 10 13:58:00 UTC 2008
   Machine: i686 (unknown)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Atom(TM) CPU 230 @ 1.60GHz (3222.0 bogomips)
          MMX, Physical Address Ext, SYSENTER/SYSEXIT
   08:36:59 up  9:07,  1 user,  load average: 0.05, 0.02, 0.00; runlevel 2

————————————————————————
Benchmark Run: Thu Aug 19 2010 08:36:59 – 09:05:22
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables        2680248.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                      529.4 MWIPS (10.1 s, 7 samples)
Execl Throughput                                301.3 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks         64000.7 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           17947.4 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        206245.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                              129787.1 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                   9248.0 lps   (10.0 s, 7 samples)
Process Creation                                544.4 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                    560.7 lpm   (60.1 s, 2 samples)
Shell Scripts (8 concurrent)                     72.0 lpm   (60.4 s, 2 samples)
System Call Overhead                         149410.0 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    2680248.6    229.7
Double-Precision Whetstone                       55.0        529.4     96.3
Execl Throughput                                 43.0        301.3     70.1
File Copy 1024 bufsize 2000 maxblocks          3960.0      64000.7    161.6
File Copy 256 bufsize 500 maxblocks            1655.0      17947.4    108.4
File Copy 4096 bufsize 8000 maxblocks          5800.0     206245.4    355.6
Pipe Throughput                               12440.0     129787.1    104.3
Pipe-based Context Switching                   4000.0       9248.0     23.1
Process Creation                                126.0        544.4     43.2
Shell Scripts (1 concurrent)                     42.4        560.7    132.2
Shell Scripts (8 concurrent)                      6.0         72.0    120.0
System Call Overhead                          15000.0     149410.0     99.6
                                                                   ========
System Benchmarks Index Score                                         103.9

ubuntu-8.04-server二进制安装xen

在ubuntu10.04上面编译xen失败,只好换种方式,用二进制包直接安装。
Ubuntu 9.10 使用的是 grub 2.0,被证实一些 bug 会导致 Xen 不能在 grub 2.0 的引导下正常启动,既然如此,尽量减少不必要的麻烦,干脆在8.04上面安装。
上网本,1G RAM,ATOM N270,安装Ubuntu 8.04,无X界面。
安装支持 Xen 的相关工具:

# apt-get install ubuntu-xen-server
下载和安装支持 Xen 的 Linux 内核:
http://security.debian.org/debian-security/pool/updates/main/l/linux-2.6/linux-modules-2.6.26-2-xen-686_2.6.26-26lenny2_i386.deb

http://security.debian.org/debian-security/pool/updates/main/l/linux-2.6/linux-image-2.6.26-2-xen-686_2.6.26-26lenny2_i386.deb

# dpkg -i linux-modules-2.6.26-2-xen-686_2.6.26-26lenny2_i386.deb
# dpkg -i linux-image-2.6.26-2-xen-686_2.6.26-26lenny2_i386.deb

安装成功后,检查 Xen 内核是否已经装好:
cat /boot/grub/menu.lst
重启系统后检查一下是否是 Xen 的内核以及 Xen 是否启动:
root@ubuntu
:~# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   587     2     r—–    117.3

创建和安装 guest
# cd /etc/xen-tools
# gedit xen-tools.conf

45  dir = /home
128 size   = 1Gb
133 dist   = lenny

163 gateway   = 192.168.2.1
164 netmask   = 255.255.255.0
165 broadcast = 192.168.2.255

187 passwd = 1
214 mirror = http://free.nchc.org.tw/debian

257 serial_device = hvc0
274 output    = /home/domains

# mkdir /home/domains
# xen-create-image –hostname=vm01 –ip=192.168.2.188 –mac=00:16:00:00:00:16
安装成功后要注意,要修改/etc/xen/vm01.cfg文件
添加
kernel      = '/boot/vmlinuz-2.6.24-28-xen'
ramdisk     = '/boot/initrd.img-2.6.24-28-xen'
否则启动会报错VmError: Boot loader didn't return any data!
另外修改disk        = [
                  'file:/home/domains/vm01/disk.img,sda2,w',
                  'file:/home/domains/vm01/swap.img,sda1,w',

              ]
为disk        = [
                  'tap:aio:/home/domains/vm01/disk.img,sda2,w',
                  'tap:aio:/home/domains/vm01/swap.img,sda1,w',

              ]

否则运行xm create vm01.cfg 报错:Error: Device 2049 (vbd) could not be connected. Failed to find an unused loop
或Device (vbd) 2049  could not be connected. losetup /dev/loop0

修改完毕,运行xm create vm01.cfg

成功启动虚拟机vm01

点击查看原图

点击查看原图

参考http://trac.nchc.org.tw/cloud/wiki/Xen_Lab1

http://ubuntuforums.org/archive/index.php/t-769142.html

贴一下我的配置文件 vm01.cfg

ubuntu-10.04编译安装xen4.0.1

ubuntu-10.04编译安装XEN4.0.1

系统是desktop-i386,已经装了X界面,蛋疼拿来玩一把虚拟化,记录下过程,以备以后用得上。

首先安装需要的软件包:
#  apt-get install gcc g++ make patch libssl-dev bzip2 gettext \
zlib1g-dev python libncurses5-dev libjpeg62-dev libx11-dev \
libgcrypt11-dev pkg-config bridge-utils bcc bin86 libpci-dev \
libsdl-dev python-dev texinfo libc6-dev uuid-dev bison flex fakeroot \
build-essential crash kexec-tools makedumpfile  libncurses5 \
libncurses5-dev iasl gawk
# apt-get build-dep linux

安装 Xen hypervisor 和 tools:
http://www.xen.org/products/xen_source.html
下载最新的 Xen 源代码,然后解开、编译、安装
# tar zxvf xen-4.0.0.tar.gz
# cd xen-4.0.0/
# make xen tools stubdom
# sudo make install-xen install-tools install-stubdom
make stubdom 的时候会从网上自动下载一些东西,所以如果是用代理上网的话需要在自己根目录下的 .wgetrc 里加上代理服务器

,以便 wget 能通过代理正常下载:
# vi .wgetrc
http_proxy = http://proxy.vpsee.com:3128/

use_proxy = on
加入到自动启动脚本中:
# sudo update-rc.d xend defaults 20 21
# sudo update-rc.d xendomains defaults 21 20

安装 Xen 内核
# cd
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.8.tar.bz2

# tar -xjf linux-2.6.31.8.tar.bz2

# wget http://gentoo-xen-kernel.googlecode.com/files/xen-patches-2.6.31-10.tar.bz2

# mkdir xenpatch-2.6.31.8
# cd xenpatch-2.6.31.8
# tar -xjf ../xen-patches-2.6.31-10.tar.bz2
# cd ..

# cd linux-2.6.31.8
# for i in `ls ../xenpatch-2.6.31.8/`; do patch -p1 < ../xenpatch-2.6.31.8/"#i"; done
配置内核,直接把系统已经存在的配置文件拷过来然后在此基础上修改:
root@hasee:/mnt/gcc/linux-2.6.31.8
# cp /boot/config-2.6.32-28-generic  .config

# cp /boot/config-2.6.31-14-server .config
# make menuconfig

点击查看原图

Processor type and features —>
  [*] Enable Xen compatible kernel
Networking support —>
  Networking options —>
    <*> 802.1d Ethernet Bridging
Device Drivers —>
  XEN —>
    [*] Privileged Guest (domain 0)
     Backend driver support
       Block-device backend driver
       Block-device tap backend driver
       Block-device tap backend driver 2
       Network-device backend driver
       PCI-device backend driver
       SCSI backend driver
       USB backend driver
    <*> Block-device frontend driver
    <*> Network-device frontend driver
     SCSI frontend driver
     USB frontend driver
    <*> Framebuffer-device frontend driver
    <*>   Keyboard-device frontend driver
    [*] Disable serial port drivers
    <*> Export Xen attributes in sysfs
        Xen version compatibility (3.3.0 and later) —>
           3.3.0 and later
配置好内核参数以后,保存配置文件、退出配置界面就可以开始编译 Linux 内核了:
 

PS:编译了一个晚上,最后发现报错,暂停折腾,有空再继续搞。