<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="http://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:hanwoody</id>
  <title>HANIX</title>
  <subtitle>Hanix aims at Apps of uNIX</subtitle>
  <author>
    <name>威廉 · 汉木头</name>
  </author>
  <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/"/>
  <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom"/>
  <updated>2009-09-15T03:52:59Z</updated>
  <lj:journal userid="8328742" username="hanwoody" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://hanwoody.livejournal.com/data/atom" title="HANIX"/>
  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:42759</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/42759.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=42759"/>
    <title>kvm中的base_image妙用</title>
    <published>2009-09-15T03:52:59Z</published>
    <updated>2009-09-15T03:52:59Z</updated>
    <content type="html">转载自&lt;a href="http://www.linux-kvm.com/content/be-more-productive-base-images-part-1[23]"&gt;http://www.linux-kvm.com/content/be-more-productive-base-images-part-1[23]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There are some useful ways in which you can use qemu base images to build template virtual machines. If used wisely you can save yourself from ever having to install the same OS more than once. The main thing that you should be aware of when using base images is the dependency between images but once managed properly, you can save yourself a lot of time.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Qemu/KVM base images&lt;br /&gt;&lt;br /&gt;Base imaging was inherited from the qemu userspace component as an added feature of kvm. The idea behind the base image is simple. You build a disk image as you would build a normal image. You then build a new image using the first image as your base image, also known as the backing file. From this point on, kvm will only read from your base image (backing file). If anything needs to be written to your image, kvm will only write to the new image. It is, in effect, similar to a diff where all new data is written only to the new image while preserving the state of your backing file. As a sideffect, your working image will be the same size as your base image. This is where the qemu copy on write term came from.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Building your base image&lt;br /&gt;&lt;br /&gt;Your base image should be based on a template disk image that is a practical starting point for your needs. Personally I like to start with a base image that is at a state right after a fresh install; no patches, no applications, just the state of the machine right after installation and registration of the OS if it requires registration. You would start by using the usual qemu-img command as you normally would for creating your base image. For example, to install your base image for a windows xp base image you would create the image with the following command.&lt;br /&gt;&lt;br /&gt;qemu-img create -f qcow2 windows-master.qcow2 10G&lt;br /&gt;&lt;br /&gt;This image will be your base image. Once your image is created you boot the image and install the OS as you normally would with a command similar to the following:&lt;br /&gt;&lt;br /&gt;qemu-system-x86_64  -hda  windows-master.qcow2  -m  512  -boot d  -cdrom /home/user/isos/en_winxp_pro_with_sp2.iso&lt;br /&gt;&lt;br /&gt;Install your OS to completion and back up this image immediately. This is your new base image and you will not have to ever boot this image in life again.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Create a new image from your template base image&lt;br /&gt;&lt;br /&gt;Now that you have your base image you are ready to install a new image from this template. You would create your new image with the following command using the –b flag.&lt;br /&gt;&lt;br /&gt;qemu-img create -b windows-master.qcow2 -f  qcow2   windows-clone.qcow2&lt;br /&gt;&lt;br /&gt;This will create a new copy-on-write image called windows-clone.qcow2 which uses your original windows-master as your template base image. You don’t need to specify a filesize with this command as it will automatically set your new image to the same size as your base image. At this point run the following command on your new image and note the size of your new image.&lt;br /&gt;&lt;br /&gt; # qemu-img info windows-clone.qcow2&lt;br /&gt;&lt;br /&gt;image: windows-clone.qcow2&lt;br /&gt;file format: qcow2&lt;br /&gt;virtual size: 10G (10737418240 bytes)&lt;br /&gt;disk size: 56K&lt;br /&gt;cluster_size: 4096&lt;br /&gt;backing file: windows-master.qcow2 (actual path: windows-master.qcow2)&lt;br /&gt;&lt;br /&gt;Note the size of your new image is 10G , the size of your original base image and note how small your image is, 56 k. At this point, your new image is basically a clone of your base image and dependent on your base image being in the same state it was at the time your clone was created. For this reason, you should try to never boot your base image again as some data may be inadvertently be written to disk causing some inconsistencies. Boot up your new clone image with a command similar to the following&lt;br /&gt;&lt;br /&gt;qemu-system-x86_64  -hda  windows-clone.qcow2  -m 400&lt;br /&gt;&lt;br /&gt;You new clone will boot up and you will see that it is a perfect clone of your original base image. As you install patches, applications and write data to your new image you can see it growing in size but your base image will always remain unchanged from it’s original state. You can use the qemu-img command to verify this. Try installing some applications on your new clone then run the following commands on both your base image and your new clone.&lt;br /&gt;&lt;br /&gt;# qemu-img info windows-master.qcow2&lt;br /&gt;# qemu-img info windows-clone.qcow2&lt;br /&gt;&lt;br /&gt;You will see that your clone image is growing and your base image has remained the same size.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;What next?&lt;br /&gt;&lt;br /&gt;Using base images , you should never have to install your operating systems again after the first install. Perform your experiments on your new clone; if something goes wrong, simply delete your clone and recreate another clone. You can also have multiple clones running off of one base image without any problems.&lt;br /&gt;&lt;br /&gt;Now that you know how to build a base image and images hanging off of your base image, the next thing that you will want to do is “rebasing” your images. For the next post in this series, I’ll walk through how you can rebase your new image to build new up to date base images for cloning.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the first part of this series about using base images to be more productive, I discussed how you can use base images to build template disk images from which you can create copy on write clones. As a natural follow up to creating your clones, at some point you’ll want to update your base images with patches or applications that is a better starting point for a clone. Regardless of how well you planned your base images, you may find that you need to update your base images to minimize additional installation on your clones. You can achieve this by “rebasing” your disk images.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;What is Rebasing?&lt;br /&gt;&lt;br /&gt;Simply put, rebasing is the process of merging your current clone with your base image to create a new base image file that is completely different and independent from your original base image. You new base image will not have any dependency on your original base image and can be used for creating new clones. I think it’s good idea to always keep a base image with a pure install and additional rebased images for different purposes. For example, in a desktop environment one rebased image can be used for marketing department, another for customer service etc all built by merging different clones with an original single install base image. Rebasing can save you loads of time.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Creating your first rebased image&lt;br /&gt;&lt;br /&gt;Now that you understand what a rebased image is, let’s create one. I’ll use the same image names from the first part of the series for continuity. In order to rebase your image you only need to issue one single command. The command follows.&lt;br /&gt;&lt;br /&gt;qemu-img convert windows-clone.qcow2 –O qcow2 windows-marketing.qcow2&lt;br /&gt;&lt;br /&gt;That’s it. Your windows-marketing.qcow2 will be a new base image completely independent from the original base image (windows-master.qcow2) used to create windows-clone.qcow2. It will be a merge of the windows-clone.qcow2 and the original windows-master.qcow2 images from the original post. This means that even if you destroy your windows-master.qcow2, your new rebased image will not be affected since there’s no dependency.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;You now know what a rebased image is and how to create one. It only involves running a single command. Rebasing images can save you time by allowing you to create repurposed base images that you can use to deploy quickly and easily. In the next and last part of the series , I’ll explore another option recently added to qemu-img and how it might be used. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;There’s a lesser known option that was added fairly recently to kvm-71 as an addition to the qemu-img command. It allows you to create a copy on write image while using the convert option. This option will probably not be as useful as basing images and rebasing images but it should at least be an option that you’re aware of. It’s a new b argument for creating copy on write images from base images while converting formats.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;The syntax &lt;br /&gt;&lt;br /&gt;The syntax for the new argument when using the convert parameter with qemu-img is as follows:&lt;br /&gt;&lt;br /&gt;qemu-img convert -O qcow2 -B master-windows2003-base.qcow2 master-windows2003.qcow2 final.qcow2  &lt;br /&gt;&lt;br /&gt;Note the –B argument which tells qemu-img that the newly created image (final.qcow2) will be a copy on write image of the specified base image (master-windows2003-base.qcow2). What you’re basically saying is convert master-windows2003.qcow2 to final.qcow2 and let this converted image be a copy on write of the image specified by the –B argument. This essentially means that the master-windows2003.qcow2 and master-windows2003-base.qcow2 should have the same content but they may differ in location, format etc.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;If you do a qemu-img info you’re your final.qcow2 image, it looks like the following.&lt;br /&gt;&lt;br /&gt;qemu-img info final.qcow2&lt;br /&gt;&lt;br /&gt;image: final.qcow2&lt;br /&gt;file format: qcow2&lt;br /&gt;virtual size: 10G (10737418240 bytes)&lt;br /&gt;disk size: 1.2G&lt;br /&gt;cluster_size: 4096&lt;br /&gt;backing file: master-windows2003-base.qcow2 (actual path: master-windows2003-base.qcow2)&lt;br /&gt;&lt;br /&gt;Note that unlike copy on write images as described previously, these copy on write images are actually the same size as the backing file and actually take some time to convert.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Summary &lt;br /&gt;&lt;br /&gt;This concludes the short series on base images. In Part 1 and Part 2 of this series you’ve seen how to create images from base templates and rebasing your disk images. In this post, you’ve seen the new optional argument for the qemu-img command and how it might be used. You’ll probably not find yourself using this option very much but I think it’s always good to know your options. Personally, I can’t think of how I might use this option very much as it doesn’t really save much disk space or time and in that case I would probably opt for just a straight conversion. In any case now you know.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:42660</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/42660.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=42660"/>
    <title>nfs4配合fscache/cachefs，用于代码部署</title>
    <published>2009-09-07T15:04:36Z</published>
    <updated>2009-09-08T02:29:39Z</updated>
    <content type="html">由于web代码部署，在服务器端的实现相对仍然是比较复杂的，说复杂是由于下面几个原因&lt;br /&gt;1、web服务器如果较多，代码的分发需要采用异步方式&lt;br /&gt;2、异步的话，如何通知用户代码‘真正’的部署成功了&lt;br /&gt;3、如果有web服务器部署失败，那么用户的代码实际上处于不一致状态，如何回滚&lt;br /&gt;&lt;br /&gt;这些问题如果都亲自实现，实现的复杂度还是比较高的，而且没那么好实现，特别是代码的回滚。在分布式环境中，一致性问题是一直比较艰巨。&lt;br /&gt;&lt;br /&gt;所以有了用nfs服务器保存web代码的想法。&lt;br /&gt;&lt;br /&gt;nfs的优点&lt;br /&gt;1、服务稳定，nfs协议经过了若干年的发展，非常可靠&lt;br /&gt;2、服务端的io如果高，会引发nfs客户端大量阻塞，进而造成大面积宕机&lt;br /&gt;3、有时候nfs客户端到服务器端的网络如果抖动，也都会造成很严重的后果。&lt;br /&gt;&lt;br /&gt;基于上述原因，一般在存储解决方案中，对于大型网站，一般都尽量避免nfs的挂载。&lt;br /&gt;&lt;br /&gt;fs-cache/cachefs&lt;br /&gt;如果在客户端能够大量缓存服务器端的文件，那么读压力就可以消除了。代码的部署实际上写压力并不大，只要很好地控制好，该方案还是可行的。&lt;br /&gt;&lt;br /&gt;实验&lt;br /&gt;服务器端：&lt;br /&gt;/etc/init.d/portmap start&lt;br /&gt;/etc/init.d/nfs start&lt;br /&gt;/etc/init.d/rpcidmapd start&lt;br /&gt;&lt;br /&gt;[root@vm0000154 vol2]# cat /etc/idmapd.conf&lt;br /&gt;[General]&lt;br /&gt;&lt;br /&gt;Verbosity = 0&lt;br /&gt;Pipefs-Directory = /var/lib/nfs/rpc_pipefs&lt;br /&gt;Domain = localdomain&lt;br /&gt;&lt;br /&gt;[Mapping]&lt;br /&gt;&lt;br /&gt;Nobody-User = nobody&lt;br /&gt;Nobody-Group = nobody&lt;br /&gt;&lt;br /&gt;[Translation]&lt;br /&gt;Method = nsswitch&lt;br /&gt;&lt;br /&gt;[root@vm0000154 vol2]# cat /etc/exports&lt;br /&gt;&lt;br /&gt;/data1/nfs4 10.0.0.0/8(rw,fsid=0,insecure,no_subtree_check,sync,anonuid=99,anongid=99)&lt;br /&gt;&lt;br /&gt;客户端：&lt;br /&gt;内核中需要nfs需要支持fscache&lt;br /&gt;CONFIG_FSCACHE=m&lt;br /&gt;CONFIG_FSCACHE_STATS=y&lt;br /&gt;CONFIG_FSCACHE_HISTOGRAM=y&lt;br /&gt;CONFIG_FSCACHE_DEBUG=y&lt;br /&gt;CONFIG_CACHEFILES=m&lt;br /&gt;CONFIG_CACHEFILES_DEBUG=y&lt;br /&gt;CONFIG_CACHEFILES_HISTOGRAM=y&lt;br /&gt;CONFIG_NFS_FSCACHE=y&lt;br /&gt;CONFIG_AFS_FSCACHE=y&lt;br /&gt;&lt;br /&gt;安装cachefilesd程序&lt;br /&gt;&lt;a href="http://people.redhat.com/~dhowells/fscache/cachefilesd-0.9.tar.bz2"&gt;http://people.redhat.com/~dhowells/fscache/cachefilesd-0.9.tar.bz2&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;# cat /etc/cachefilesd.conf&lt;br /&gt;dir /var/cache/fscache&lt;br /&gt;tag mycache&lt;br /&gt;brun 10%&lt;br /&gt;bcull 7%&lt;br /&gt;bstop 3%&lt;br /&gt;frun 10%&lt;br /&gt;fcull 7%&lt;br /&gt;fstop 3%&lt;br /&gt;&lt;br /&gt;启动cachefilesd&lt;br /&gt;#/sbin/cachefilesd&lt;br /&gt;&lt;br /&gt;fscache 需要user_xattr属性支持&lt;br /&gt;#mount -o remount,rw,user_xattr /var&lt;br /&gt;&lt;br /&gt;挂载nfs4服务&lt;br /&gt;#mount -t nfs4 -o fsc,rw,intr 10.210.141.160:/vol2 /mnt/nfs4</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:42436</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/42436.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=42436"/>
    <title>庆祝lj可以访问</title>
    <published>2007-07-10T08:06:28Z</published>
    <updated>2007-07-10T08:06:28Z</updated>
    <content type="html">好久不来这里了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;LJ终于可以访问了，自己发帖庆祝一下。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:42224</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/42224.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=42224"/>
    <title>系统负载奇怪升高</title>
    <published>2007-04-20T08:27:00Z</published>
    <updated>2007-04-20T08:27:00Z</updated>
    <category term="loadavg"/>
    <content type="html">这两天，系统的负载一直在30左右，但是查看了cpu，内存，io，网络，负载都非常的轻。到底什么原因？&lt;br /&gt;&lt;br /&gt;用ps ax查看，发现系统中有许多处于D+状态的sendmail进程，这些进程都处于不可中断的状态。数了一下，大致也在30个左右。&lt;br /&gt;&lt;br /&gt;再分析sendmail进程为什么会处于D+状态？&lt;br /&gt;&lt;br /&gt;到/var/spool/目录下，发现clientmqueue和mqueue下有大量的小文件，这个时候只要有进程作用于这两个目录，都有可能导致不可中断(D+)，包括rm命令。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;系统负载的计算方法：&lt;br /&gt;过去1m/5m/15m时间内，平均等待的进程数。&lt;br /&gt;&lt;br /&gt;所以有多少个D+状态的进程，系统负载就会升到多少。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:41939</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/41939.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=41939"/>
    <title>linux做nat网关</title>
    <published>2007-04-12T08:25:42Z</published>
    <updated>2007-04-12T08:25:42Z</updated>
    <category term="iptables"/>
    <category term="gateway"/>
    <category term="nat"/>
    <content type="html">echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;/sbin/rmmod ipchains&lt;br /&gt;/sbin/modprobe ip_tables&lt;br /&gt;/sbin/modprobe iptable_filter&lt;br /&gt;/sbin/modprobe iptable_nat&lt;br /&gt;/sbin/modprobe ip_conntrack&lt;br /&gt;/sbin/modprobe ip_conntrack_ftp&lt;br /&gt;/sbin/modprboe ip_nat_ftp&lt;br /&gt;/sbin/iptables -F INPUT&lt;br /&gt;/sbin/iptables -F FORWARD&lt;br /&gt;/sbin/iptables -F POSTROUTING -t nat&lt;br /&gt;/sbin/iptables -P FORWARD DROP&lt;br /&gt;/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 192.168.8.0/24 -j MASQUERADE&lt;br /&gt;/sbin/iptables -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;/sbin/iptables -A FORWARD -s 192.168.8.0/24 -j ACCEPT</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:41340</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/41340.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=41340"/>
    <title>Linux下在vmware中添加新的vmnet</title>
    <published>2007-04-11T05:54:31Z</published>
    <updated>2007-04-11T05:54:31Z</updated>
    <content type="html">在Linux 下，有时为了做一些网络方面的测试，就需要启用多个网段进行实验。&lt;br /&gt;默认情况下，vmware提供了vmnet0/vmnet1/vmnet8，但是如果你想使用更多的网段，该怎么办？&lt;br /&gt;&lt;br /&gt;方法其实很简单，就是修改/etc/vmware/locations文件，在文件开头：&lt;br /&gt;answer NETWORKING yes&lt;br /&gt;answer VNET_0_INTERFACE eth0&lt;br /&gt;answer VNET_8_NAT yes&lt;br /&gt;answer VNET_8_HOSTONLY_HOSTADDR 192.168.63.1&lt;br /&gt;answer VNET_8_HOSTONLY_NETMASK 255.255.255.0&lt;br /&gt;answer VNET_1_HOSTONLY_HOSTADDR 192.168.95.1&lt;br /&gt;answer VNET_1_HOSTONLY_NETMASK 255.255.255.0&lt;br /&gt;&lt;br /&gt;添加其他的vmnet。如果需要nat服务，就定义成 answer VMNET_9_nat yes，如果不需要nat，则直接添加：&lt;br /&gt;answer VNET_2_HOSTONLY_HOSTADDR 192.168.64.1&lt;br /&gt;answer VNET_2_HOSTONLY_NETMASK 255.255.255.0&lt;br /&gt;&lt;br /&gt;/etc/init.d/vmware restart&lt;br /&gt;后，就能发现/dev/vmnet2已经存在了，并且&lt;br /&gt;ifconfig后&lt;br /&gt;也能发现新的vmnet2接口了。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:40750</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/40750.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=40750"/>
    <title>openVPN配置</title>
    <published>2007-04-09T10:26:25Z</published>
    <updated>2007-04-09T10:26:25Z</updated>
    <content type="html">一、内核驱动&lt;br /&gt;tun/tap支持。&lt;br /&gt;Device Drivers-&amp;gt;Network device support-&amp;gt;Universal TUN/TAP device driver support&lt;br /&gt;IP forward support/enable routing:&lt;br /&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:40474</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/40474.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=40474"/>
    <title>kvm, xen, vmware</title>
    <published>2007-04-04T08:45:42Z</published>
    <updated>2007-04-04T08:45:42Z</updated>
    <content type="html">这三个虚拟机目前在一个linux内核下没法共存，只能用一个。&lt;br /&gt;&lt;br /&gt;要都支持的话，就需要编译三个不同版本号的内核。&lt;br /&gt;&lt;br /&gt;今天在2.6.20下编译vmware时，可以编译过去，但是插入模块时，报错：&lt;br /&gt;vmmon: Unknown symbol paravirt_ops&lt;br /&gt;&lt;br /&gt;查了一下，发现是CONFIG_PARAVIRT=y引起，但是kvm是需要它的。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:40414</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/40414.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=40414"/>
    <title>世界各国2006GDP排名(zz)</title>
    <published>2007-04-02T07:39:49Z</published>
    <updated>2007-04-02T07:39:49Z</updated>
    <category term="gdp"/>
    <content type="html">2005年世界人均GDP排名/2006年世界各国的GDP&lt;br /&gt;&lt;br /&gt;1 卢森堡 69,056&lt;br /&gt;　　2 挪威 53,465&lt;br /&gt;　　3 瑞士 49,246&lt;br /&gt;　　4 爱尔兰 46,335&lt;br /&gt;　　5 丹麦 45,015&lt;br /&gt;　　6 冰岛 44,133&lt;br /&gt;　　7 美国 42,076&lt;br /&gt;　　8 瑞典 38,451&lt;br /&gt;　　9 英国 36,977&lt;br /&gt;　　10 日本 36,486&lt;br /&gt;　　11 奥地利 35,861&lt;br /&gt;　　12 荷兰 35,393&lt;br /&gt;　　13 芬兰 35,242&lt;br /&gt;　　14 比利时 34,081&lt;br /&gt;　　15 卡塔尔 33,586&lt;br /&gt;　　16 法国 33,126&lt;br /&gt;　　17 德国 33,099&lt;br /&gt;　　18 加拿大 32,073&lt;br /&gt;　　19 澳洲 29,761&lt;br /&gt;　　20 意大利 29,648&lt;br /&gt;　　21 新加坡 25,176&lt;br /&gt;　　22 西班牙 24,627&lt;br /&gt;　　23 香港 24,581&lt;br /&gt;　　24 新西兰 23,276&lt;br /&gt;　　25 阿拉伯联合酋长国 20,960&lt;br /&gt;　　26 科威特 19,288&lt;br /&gt;　　27 塞浦路斯 19,008&lt;br /&gt;　　28 希腊 18,995&lt;br /&gt;　　29 巴哈马 18,190&lt;br /&gt;　　30 斯洛文尼亚 17,660&lt;br /&gt;　　31 荷兰属地 17,435&lt;br /&gt;　　32 以色列 16,987&lt;br /&gt;　　33 葡萄牙 16,658&lt;br /&gt;　　34 韩国 14,649&lt;br /&gt;　　35 汶莱 14,366&lt;br /&gt;　　36 台湾 13,926&lt;br /&gt;　　37 巴林 13,764&lt;br /&gt;　　38 马耳他 13,144&lt;br /&gt;　　39 安提瓜和巴布达 11,790&lt;br /&gt;　　40 匈牙利 10,896&lt;br /&gt;　　41 沙特阿拉伯 10,795&lt;br /&gt;　　42 巴布达 10,747&lt;br /&gt;　　43 捷克 10,708&lt;br /&gt;　　44 阿曼 10,292&lt;br /&gt;　　45 特立尼达和多巴哥 10,117&lt;br /&gt;　　46 塞舌尔群岛 8,892&lt;br /&gt;　　47 爱沙尼亚 8,885&lt;br /&gt;　　48 圣基茨和尼维斯 8,546&lt;br /&gt;　　49 斯洛伐克 7,963&lt;br /&gt;　　50 克罗地亚 7,764&lt;br /&gt;　　51 立陶宛 6,796&lt;br /&gt;　　52 墨西哥 6,566&lt;br /&gt;　　53 波兰 6,373&lt;br /&gt;　　54 赤道几内亚 6,235&lt;br /&gt;　　55 拉脱维亚 6,150&lt;br /&gt;　　56 智利 5,742&lt;br /&gt;　　57 博茨瓦纳 5,713&lt;br /&gt;　　58 黎巴嫩 5,434&lt;br /&gt;　　59 毛里求斯 5,421&lt;br /&gt;　　60 利比亚 5,317&lt;br /&gt;　　61 加蓬 4,911&lt;br /&gt;　　62 巴拿马 4,806&lt;br /&gt;　　63 俄国 4,750&lt;br /&gt;　　64 马来西亚 4,701&lt;br /&gt;　　65 格林那达 4,692&lt;br /&gt;　　66 土耳其 4,637&lt;br /&gt;　　67 格斯达里加 4,484&lt;br /&gt;　　68 阿根廷 4,132&lt;br /&gt;　　69 伯利兹 4,120&lt;br /&gt;　　70 圣卢西亚岛 4,095&lt;br /&gt;　　71 委内瑞拉 4,014&lt;br /&gt;　　72 南非 3,886&lt;br /&gt;　　73 乌拉圭 3,874&lt;br /&gt;　　74 多米尼加 3,772&lt;br /&gt;　　75 圣文森特和格林纳丁斯 3,719&lt;br /&gt;　　76 保加利亚 3,325&lt;br /&gt;　　77 巴西 3,311&lt;br /&gt;　　78 罗马尼亚 3,277&lt;br /&gt;　　79 卡扎克斯坦 3,185&lt;br /&gt;　　80 突尼斯 3,052&lt;br /&gt;　　81 牙买加 3,003&lt;br /&gt;　　82 白俄罗斯 2,992&lt;br /&gt;　　83 塞尔维亚和黑山共和国 2,820&lt;br /&gt;　　84 泰国 2,807&lt;br /&gt;　　85 苏里南 2,785&lt;br /&gt;　　86 土库曼 2,784&lt;br /&gt;　　87 伊朗 2,608&lt;br /&gt;　　88 阿尔及利亚 2,601&lt;br /&gt;　　89 马其顿共和国 2,570&lt;br /&gt;　　90 阿尔巴尼亚 2,434&lt;br /&gt;　　91 秘鲁 2,379&lt;br /&gt;　　92 马尔代夫 2,355&lt;br /&gt;　　93 纳米比亚 2,333&lt;br /&gt;　　94 汤加 2,226&lt;br /&gt;　　95 斐济 2,199&lt;br /&gt;　　96 厄瓜多尔 2,168&lt;br /&gt;　　97 波斯尼亚和黑塞哥维那 2,167&lt;br /&gt;　　98 佛得角 2,161&lt;br /&gt;　　99 哥伦比亚 2,119&lt;br /&gt;　　100 萨尔瓦多 2,063&lt;br /&gt;　　101 斯威士兰 2,043&lt;br /&gt;　　102 多米尼加共和国 2,014&lt;br /&gt;　　103 乔丹 1,988&lt;br /&gt;　　104 危地马拉 1,966&lt;br /&gt;　　105 萨摩亚 1,821&lt;br /&gt;　　106 中华人民共和国 1,703（2005）&lt;br /&gt;　　107 乌克兰 1,589&lt;br /&gt;　　108 安哥拉 1,580&lt;br /&gt;　　109 摩洛哥 1,576&lt;br /&gt;　　110 瓦努阿图 1,440&lt;br /&gt;　　111 刚果共和国 1,401&lt;br /&gt;　　112 叙利亚 1,386&lt;br /&gt;　　113 阿塞拜疆 1,237&lt;br /&gt;　　114 巴拉圭 1,170&lt;br /&gt;　　115 玻利维亚 1,137&lt;br /&gt;　　116 埃及 1,118&lt;br /&gt;　　117 印度尼西亚 1,093&lt;br /&gt;　　118 菲律宾 1,084&lt;br /&gt;　　119 洪都拉斯 1,062&lt;br /&gt;　　120 斯里南卡 1,052&lt;br /&gt;　　121 圭亚那 1,035&lt;br /&gt;　　122 佐治亚 927&lt;br /&gt;　　123 亚美尼亚 868&lt;br /&gt;　　124 卡麦隆 860&lt;br /&gt;　　125 象牙海岸 859&lt;br /&gt;　　126 不丹 859&lt;br /&gt;　　127 吉布提 822&lt;br /&gt;　　128 尼加拉瓜 794&lt;br /&gt;　　129 基里巴斯 768&lt;br /&gt;　　130 塞内加尔 745&lt;br /&gt;　　131 摩尔多瓦 665&lt;br /&gt;　　132 巴布亚新几内亚 660&lt;br /&gt;　　133 印度 652&lt;br /&gt;　　134 海地 650&lt;br /&gt;　　135 苏丹 643&lt;br /&gt;　　136 比宁 583&lt;br /&gt;　　137 巴基斯坦 577&lt;br /&gt;　　138 乍得 567&lt;br /&gt;　　139 科摩罗 554&lt;br /&gt;　　140 也门 553&lt;br /&gt;　　141 蒙古 547&lt;br /&gt;　　142 莱索托 546&lt;br /&gt;　　143 所罗门群岛 534&lt;br /&gt;　　144 越南 528&lt;br /&gt;　　145 尼日利亚 528&lt;br /&gt;　　146 肯尼亚 489&lt;br /&gt;　　147 赞比亚 461&lt;br /&gt;　　148 毛里塔尼亚 452&lt;br /&gt;　　149 加纳 451&lt;br /&gt;　　150 马里 435&lt;br /&gt;　　151 布基纳法索 424&lt;br /&gt;　　152 老挝 421&lt;br /&gt;　　153 孟加拉国 418&lt;br /&gt;　　154 吉尔吉斯斯坦 413&lt;br /&gt;　　155 东帝汶 400&lt;br /&gt;　　156 乌兹别克斯坦 376&lt;br /&gt;　　157 基尼 375&lt;br /&gt;　　158 圣多美及普林西比 372&lt;br /&gt;　　159 多哥 357&lt;br /&gt;　　160 中非共和国 356&lt;br /&gt;　　161 柬埔寨 327&lt;br /&gt;　　162 坦桑尼亚 323&lt;br /&gt;　　163 乌干达 296&lt;br /&gt;　　164 莫桑比克 294&lt;br /&gt;　　165 冈比亚 284&lt;br /&gt;　　166 津巴布韦 277&lt;br /&gt;　　167 塔吉克斯坦 275&lt;br /&gt;　　168 尼日尔 273&lt;br /&gt;　　169 马达加斯加 263&lt;br /&gt;　　170 尼泊尔 246&lt;br /&gt;　　171 塞阿里昂 207&lt;br /&gt;　　172 几内亚比绍 204&lt;br /&gt;　　173 卢旺达 189&lt;br /&gt;　　174 马拉维 174&lt;br /&gt;　　175 厄立特里亚 157&lt;br /&gt;　　176 缅甸 135&lt;br /&gt;　　177 民主党刚果共和国 122&lt;br /&gt;　　178 埃塞俄比亚 121&lt;br /&gt;　　179 布隆迪 103&lt;br /&gt;&lt;br /&gt;2006年世界各国的GDP&lt;br /&gt;&lt;br /&gt;名次--经济体-----------国内生产总值---------面积-----------人口----------人均GDP--  &lt;br /&gt;&lt;br /&gt;01----美国--------132216.85亿美元--面积--982.66万Km2--人口--30053万--人均-43995美元  &lt;br /&gt;02----日本---------49113.62亿美元--面积---37.78万Km2--人口--12746万--人均-38533美元  &lt;br /&gt;03----德国---------28582.34亿美元--面积---35.70万Km2--人口---8242万--人均-34679美元  &lt;br /&gt;04----中国---------26847.05亿美元--面积--959.70万Km2--人口-131457万--人均--2042美元  &lt;br /&gt;05----英国---------23413.71亿美元--面积---24.48万Km2--人口---6060万--人均-38636美元  &lt;br /&gt;06----法国---------21537.46亿美元--面积---54.70万Km2--人口---6088万--人均-35377美元  &lt;br /&gt;07---意大利--------17839.59亿美元--面积---30.12万Km2--人口---5813万--人均-30689美元  &lt;br /&gt;08---加拿大--------10889.37亿美元--面积--998.47万Km2--人口---3310万--人均-32898美元  &lt;br /&gt;09---西班牙--------10812.29亿美元--面积---50.48万Km2--人口---4040万--人均-26763美元  &lt;br /&gt;10----印度----------8000.00亿美元--面积--328.76万Km2--人口-109535万--人均---723美元  &lt;br /&gt;11----韩国----------7684.58亿美元--面积----9.85万Km2--人口---4885万--人均-15731美元  &lt;br /&gt;12---墨西哥---------7415.20亿美元--面积--197.26万Km2--人口--10745万--人均--6901美元  &lt;br /&gt;13---俄罗斯---------7328.92亿美元--面积-1707.52万Km2--人口--14289万--人均--5129美元  &lt;br /&gt;14--澳大利亚--------6453.06亿美元--面积--768.69万Km2--人口---2026万--人均-31851美元  &lt;br /&gt;15----巴西----------6207.41亿美元--面积--851.20万Km2--人口--18808万--人均--3300美元  &lt;br /&gt;16----荷兰----------6127.13亿美元--面积----4.15万Km2--人口---1649万--人均-31757美元  &lt;br /&gt;17----瑞士----------3868.35亿美元--面积---4.129万Km2--人口----752万--人均-51441美元  &lt;br /&gt;18----瑞典----------3715.21亿美元--面积---45.00万Km2--人口----907万--人均-40962美元  &lt;br /&gt;19---比利时---------3678.24亿美元--面积---3.053万Km2--人口---1038万--人均-35436美元  &lt;br /&gt;20--中国台湾--------3539.17亿美元--面积---3.598万Km2--人口---2304万--人均-15361美元  &lt;br /&gt;21---土耳其---------3581.67亿美元--面积---78.06万Km2--人口---7041万--人均--5087美元  &lt;br /&gt;22---奥地利---------3093.46亿美元--面积---8.387万Km2--人口----819万--人均-37771美元  &lt;br /&gt;23-沙特阿拉伯-------2862.05亿美元--面积--196.06万Km2--人口---2702万--人均-10592美元  &lt;br /&gt;24----波兰----------2654.12亿美元--面积---31.27万Km2--人口---3854万--人均--6887美元  &lt;br /&gt;25-印度尼西亚-------2643.57亿美元--面积--191.94万Km2--人口--24545万--人均--1077美元  &lt;br /&gt;26----挪威----------2616.94亿美元--面积---32.38万Km2--人口----461万--人均-56767美元  &lt;br /&gt;27----丹麦----------2563.18亿美元--面积----4.31万Km2--人口----545万--人均-47031美元  &lt;br /&gt;28----希腊----------2224.86亿美元--面积---13.19万Km2--人口---1069万--人均-20813美元  &lt;br /&gt;29---阿根廷---------2103.60亿美元--面积--276.69万Km2--人口---3992万--人均--5270美元  &lt;br /&gt;30---爱尔兰---------2029.35亿美元--面积----7.03万Km2--人口----406万--人均-49984美元  &lt;br /&gt;31----南非----------2004.58亿美元--面积--122.00万Km2--人口---4419万--人均--4536美元  &lt;br /&gt;32----泰国----------1965.78亿美元--面积---51.40万Km2--人口---6463万--人均--3042美元  &lt;br /&gt;33----伊朗----------1948.29亿美元--面积--164.80万Km2--人口---6869万--人均--2836美元  &lt;br /&gt;34--中国香港--------1871.12亿美元--面积----0.11万Km2--人口----694万--人均-26961美元  &lt;br /&gt;35---葡萄牙---------1766.29亿美元--面积----9.24万Km2--人口---1061万--人均-16647美元  &lt;br /&gt;36----芬兰----------1717.33亿美元--面积---33.81万Km2--人口----523万--人均-32836美元&lt;br /&gt;&lt;br /&gt;从初中开始对这些数字感兴趣，即便是专家来看中国的经济也是个巨大的谜团。&lt;br /&gt;对于一般人来说，就只能从这些表面的数据来感受中国了&lt;br /&gt;现在再次对中国经济总量做一次预计&lt;br /&gt;2007年中国经济总量超越德国   升居世界第三&lt;br /&gt;2011或者2012年超越日本 升居世界第二&lt;br /&gt;乐观估计2025年中国经济总量可以超越美国，雄踞世界第一。&lt;br /&gt;&lt;br /&gt;中国人口总量是日本的10倍，即便2012年中国经济总量超越日本，届时人均也只不过是日本的1/10，这正说明中国的经济潜力巨大。&lt;br /&gt;20年后中国人口大约是美国的四倍，中国从总量上超越美国并非遥不可及，但是人均要赶超美国却极其漫长&lt;br /&gt;大国经济格局是个此消彼长的变化格局，老牌 经济强国必然会受到复兴中国全方位的挑战&lt;br /&gt;很有可能中国的崛起直接导致美国日本的衰落&lt;br /&gt;弱者更弱 强者更强&lt;br /&gt;世界将因为中国的复兴而产生巨大变动&lt;br /&gt;没有谁能具体预料&lt;br /&gt;但是中国崛起无可阻挡&lt;br /&gt;&lt;br /&gt;人民币严重被低估&lt;br /&gt;和美元真实比价大约4：1&lt;br /&gt;今后20年人民币会稳定升值到这个合理价位&lt;br /&gt;&lt;br /&gt;中国人口众多，幅员辽阔，地区经济差异巨大。当沿海大都市已经进入发达国家生活水平的时候，内地很多省区可能依然是中低水平&lt;br /&gt;这种巨大的地区经济差异是发展的必然&lt;br /&gt;甚至从某种程度上来说是中国的发展优势&lt;br /&gt;广州深圳的工厂可以轻松招纳到月薪几百元的内地工人，这在国土面积狭小的发达国家或者已经发展均衡的发达国家是不可想象的。&lt;br /&gt;正是这种差异为中国提供了至少30年的低劳动力价值竞争优势&lt;br /&gt;也就是说中国可以和发达国家、甚至低收入的发展中国家在高中低各个经济层面展开积极长久的竞争&lt;br /&gt;当中国目前的经济增长速度降低 就意味着中国已经全部进入了发达水平&lt;br /&gt;那一天中国的经济总量估计会占到全球总额的三分之一甚至二分之一&lt;br /&gt;这一天到来或许仅仅需要20年&lt;br /&gt;也或许50年</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:40034</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/40034.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=40034"/>
    <title>gaim里的qq登录不上了</title>
    <published>2007-03-26T01:05:11Z</published>
    <updated>2007-03-26T01:05:11Z</updated>
    <category term="qq"/>
    <category term="gaim"/>
    <content type="html">(08:59:11) util: Writing file accounts.xml to directory /home/hanwoody/.gaim&lt;br /&gt;(08:59:12) account: Connecting to account 24486915&lt;br /&gt;(08:59:12) connection: Connecting. gc = 0x864f0b0&lt;br /&gt;(08:59:12) dns: DNS query for 'tcpconn3.tencent.com' queued&lt;br /&gt;(08:59:12) dns: Created new DNS child 4913, there are now 1 children.&lt;br /&gt;(08:59:12) dns: Successfully sent DNS request to child 4913&lt;br /&gt;(08:59:12) dns: Got response for 'tcpconn3.tencent.com'&lt;br /&gt;(08:59:12) dnsquery: IP resolved for tcpconn3.tencent.com&lt;br /&gt;(08:59:12) proxy: Attempting connection to 219.133.38.5&lt;br /&gt;(08:59:12) proxy: Connecting to tcpconn3.tencent.com:8000 with no proxy&lt;br /&gt;(08:59:12) proxy: Connection in progress&lt;br /&gt;(08:59:12) proxy: Connected.&lt;br /&gt;(08:59:12) QQ: ==&amp;gt; [13723] QQ_CMD_REQUEST_LOGIN_TOKEN, from (QQ unknown version)&lt;br /&gt;(08:59:12) QQ: ack [13723] QQ_CMD_REQUEST_LOGIN_TOKEN, remove from sendqueue&lt;br /&gt;(08:59:12) QQ: &amp;lt;&amp;lt;&amp;lt; got a token with 24 bytes -&amp;gt; [default] decrypt and dump&lt;br /&gt;0000:  F6 9F 06 00 DB 44 A1 B4 88 FD F2 45 81 94 37 C4  v...[D!4.}rE..7D&lt;br /&gt;0016:  A0 6C C3 F6 E6 83 CD 81                           lCvf.M.&lt;br /&gt;(08:59:12) QQ: ==&amp;gt; [13724] QQ_CMD_LOGIN, from (QQ unknown version)&lt;br /&gt;(08:59:12) QQ: ack [13724] QQ_CMD_LOGIN, remove from sendqueue&lt;br /&gt;(08:59:12) QQ: Decrypt login reply packet with inikey, 11 bytes&lt;br /&gt;(08:59:12) QQ: Redirected to new server: 219.133.49.73:80&lt;br /&gt;(08:59:12) QQ: 0 packets in sendqueue are freed!&lt;br /&gt;(08:59:12) QQ: 0 group packets are freed!&lt;br /&gt;(08:59:12) QQ: 0 groups are freed&lt;br /&gt;(08:59:12) QQ: 0 add buddy requests are freed!&lt;br /&gt;(08:59:12) QQ: 0 info queries are freed!&lt;br /&gt;(08:59:12) QQ: 0 qq_buddy structures are freed!&lt;br /&gt;(08:59:12) dns: DNS query for '219.133.49.73' queued&lt;br /&gt;(08:59:12) dns: Created new DNS child 4914, there are now 1 children.&lt;br /&gt;(08:59:12) dns: Successfully sent DNS request to child 4914&lt;br /&gt;(08:59:12) dns: Got response for '219.133.49.73'&lt;br /&gt;(08:59:12) dnsquery: IP resolved for 219.133.49.73&lt;br /&gt;(08:59:12) proxy: Attempting connection to 219.133.49.73&lt;br /&gt;(08:59:12) proxy: Connecting to 219.133.49.73:80 with no proxy&lt;br /&gt;(08:59:12) proxy: Connection in progress&lt;br /&gt;(08:59:12) proxy: Connected.&lt;br /&gt;(08:59:17) util: Writing file accounts.xml to directory /home/hanwoody/.gaim&lt;br /&gt;(08:59:22) QQ: &amp;lt;&amp;lt;&amp;lt; [13723] send again for 1 times!&lt;br /&gt;(08:59:27) QQ: &amp;lt;&amp;lt;&amp;lt; [13723] send again for 2 times!&lt;br /&gt;(08:59:32) QQ: &amp;lt;&amp;lt;&amp;lt; [13723] send again for 3 times!&lt;br /&gt;(08:59:37) QQ: &amp;lt;&amp;lt;&amp;lt; [13723] send again for 4 times!&lt;br /&gt;(08:59:42) QQ: &amp;lt;&amp;lt;&amp;lt; [13723] send again for 5 times!</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:39559</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/39559.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=39559"/>
    <title>vmware镜像用于xen虚拟机</title>
    <published>2007-03-09T14:10:02Z</published>
    <updated>2007-03-09T14:10:02Z</updated>
    <category term="vmware"/>
    <category term="xen"/>
    <content type="html">一、确保vmware磁盘的使用方式符合preallocated virtual disk,用vmware的话说，disk type是3&lt;br /&gt;fdisk -u ./Gentoo-flat.vmdk&lt;br /&gt;             Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;./Gentoo-flat.vmdk1              63      321299      160618+  83  Linux&lt;br /&gt;./Gentoo-flat.vmdk2          321300     5301449     2490075   83  Linux&lt;br /&gt;./Gentoo-flat.vmdk3         5301450     6281414      489982+  83  Linux&lt;br /&gt;&lt;br /&gt;计算每个分区的offset:&lt;br /&gt;1, 63*512&lt;br /&gt;2, 321300*512&lt;br /&gt;3, 5301450*512&lt;br /&gt;&lt;br /&gt;二、根据offset值将这些分区使用losetup工具attach到loop设备&lt;br /&gt;losetup -o 63*512 /dev/loop0 ./Gentoo-flat.vmdk&lt;br /&gt;losetup -o 321300*512 /dev/loop1 ./Gentoo-flat.vmdk&lt;br /&gt;losetup -o  5301450*512 /dev/loop2 ./Gentoo-flat.vmdk&lt;br /&gt;&lt;br /&gt;三，将这些loop设备作为物理设备填入在xen的配置中&lt;br /&gt;启动过程中可能会有一些问题，不过启动没有关系了。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:39237</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/39237.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=39237"/>
    <title>Squid工作原理(zz)</title>
    <published>2007-03-09T07:39:07Z</published>
    <updated>2007-03-09T07:39:07Z</updated>
    <category term="squid"/>
    <category term="proxy"/>
    <content type="html">Squid工作原理：&lt;br /&gt;    Squid 启动之后，会在 RAM 建立一个 Hash Table，记录硬盘中 object 配置的情形。&lt;br /&gt;    Squid 又会在 RAM 中建立一个 Digest Table(摘要表) ，其功能是和其他有合作关的 Squid (Sibling)互相交换 Digest Table，万一用户端想要的资料自己没有时，可以很快的知道哪一部 Squid Server 有资料(Squid 也可以透过 ICP 向其他 Squid 查询，但速度较慢)。但是 Digest Table 本身不小，既记忆体又频宽，如果 Server 的内存不够，对外带宽不够，反而比 ICP 查询更慢。&lt;br /&gt;   &lt;br /&gt;Squid的种类【可能不太合适叫做种类，不过没有更好的词。语文太差^_^】&lt;br /&gt;    child、sibling、parent。&lt;br /&gt;   &lt;br /&gt;    关系如下：&lt;br /&gt;　　Squid Server 之间的第一种关系是：Child 和 Parent。当 Child Squid Server 没有资料时，会直接向 Parent Squid Server 要资料，然後一直等，直到 Parent 给它资料为止。 &lt;br /&gt;　　Squid Server 之间的第二种关系是：Sibling 和 Sibling。当 Squid Server 没有资料时，会先向 Sibling 的 Squid Server 要资料，如果 Sibling 没资料，就跳过它直接向 Parent 要或上 internet 去拿。     &lt;br /&gt;　　&lt;br /&gt;    一般 Squid Server 运作的模式是：  &lt;br /&gt;    1. 当 Squid Server 没有资料时，会先向 Sibling 的 Squid Server 要资料，如果 Sibling 没资料，就跳过它直接向 Parent 要。 &lt;br /&gt;    2. 向 Parent 要资料，然後一直等，直到 Parent 给它资料为止(Parent 自己有的资料或上 internet 去拿)。 &lt;br /&gt;    3. 没有 Parent 时，就自己上 internet 去拿。 &lt;br /&gt;    4. 如果这三者都拿不到资料，才向用户端回报拿不到资料。 &lt;br /&gt;   &lt;br /&gt;编译安装Squid：&lt;br /&gt;./configure --prefix=/usr/local/squid[-ip] --enable-async-io=160 --enable-icmp  --enable-kill-parent-hack --enable-cache-digests --enable-default-err-language=Simplify_Chinese --enable-poll &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install&lt;br /&gt;--enable-async-io=160：这项主要是设置async模式来运行 squid，我的理解是设置用线程来运行squid，如果服务器很强劲，有1G以上内存，cpu使用SMP的方式的话可以考虑设成160或者更高。如果服务器比较糟糕就根据实际情况设了（不要太贪心哦^_^）。&lt;br /&gt;--enable-icmp：加入icmp。默认不加。&lt;br /&gt;--enbale-kill-parent-hack：当kill掉nobody的squid进程的时候会同时杀死它的父进程。&lt;br /&gt;--enable-cache-digests：【。。。】&lt;br /&gt;--enable-default-err-language=Simplify_Chinese：当有错误的时候在页面中显示简体中文。【不过squid还是会无情的把所有语言都装上，看的不顺的话手工删咯】&lt;br /&gt;--enable-poll：可以提升效能。&lt;br /&gt;&lt;br /&gt;Squid的结构介绍：&lt;br /&gt;安装好的目录在/usr/local/squid-10  (这里假设我的主ip最后一段是10）&lt;br /&gt;结构是：&lt;br /&gt;    bin/：放置squid默认写好的启动脚本。有RunAccel；RunCache；squidclient；前2个启动Squid可以使用，因为当 squid进程死了后，这个脚本可以自动检测到。 RunAccel是用于web 加速用的脚本，而RunCache是用于做squid代理用的，squidclient是用本机做squid测试的。&lt;br /&gt;    etc/：squid.conf在这个目录中&lt;br /&gt;    libexec/：函数库；&lt;br /&gt;    man/：帮助文件。不用说了吧。。。&lt;br /&gt;    sbin/ ：squid命令所在目录。一般如果我用来测试就启动squid命令。或者用这个命令创建swap，或者加-k参数重启之类的操作。&lt;br /&gt;    share/ ：一些错误显示的html都在里面；&lt;br /&gt;    var/ ：log，pid，swap都在这个目录中！&lt;br /&gt;隔了很久才有空可以写这个经验体会，前一段时间一直在搞qmail，头大中，终于可以空下来了：）&lt;br /&gt;&lt;br /&gt;先看squid的一个重要的，对我来说也是唯一需要配置的一个配置文件。选项非常多，当然，默认的squid.conf文件中对于每一个选项都有比较详细的说明，但是我还是想把我理解的以及必须要进行配置的选项罗列出来，以免过段时间自己都忘了^_^&lt;br /&gt;&lt;br /&gt;以下的配置我是要向sina，sohu，163学习的web server的架构，试着自己去搭建一个这样的环境来看看效果到底如何。因此这里的squid不是用来做代理的，而是反向作为网站高速缓存。其实原理差不多，只是方向反一反而已，相信都能理解这点的。&lt;br /&gt;&lt;br /&gt;使用的测试服务器为Dell 2650 双CPU至强2.4G 内存DDR 2G。OS为Freebsd 5.2.1（这里需要说明的是，从实际使用情况来看，squid跑在freebsd上的效果是最快最好的。这是由os的文件系统所决定的，千万不能用， solaris，感觉solaris的文件系统实在太慢，虽然非常稳定，而且跑多线程的效果是最好的。linux嘛~~~没有进行测试，不过感觉在 freebsd之下，solaris之上。）&lt;br /&gt;&lt;br /&gt;Squid.conf的几个重要参数的配置说明：&lt;br /&gt;&lt;br /&gt;http_port 61.155.143.54:80 #Squid Server侦听的端口。假设我的主页的dns server 指到61.155.143.54上的，因此我必须让squid来侦听这个IP的这个端口。&lt;br /&gt;&lt;br /&gt;cache_mem 32 MB #要额外提供多少内存给squid使用，这里的额外是指squid会将最常用的一些缓存放到这块内存中。这个指令也是我看了官方文档后才理解的。因为一开始从实际使用情况来看，我这边设32M的话，用top命令来查看一般会达到100M左右。这点让我让我很想不通，呵呵。然后就去看官方文档，发觉 squid是这样来计算使用多少内存的：squid本身的进程大概10M-20M，然后下面我设的cache目录的大小是500M的话，那他放在内存里的 hash索引大概需要20M左右，然后再加上这里设置的cache_mem的值。官方文档建议你的实际内存大小应该是这个squid所需要总内存的2倍以上。自己量力而为吧。cache_mem当然是越大越好了。&lt;br /&gt;&lt;br /&gt;cache_dir ufs /usr/local/squid-54/var/cache 500 16 256 #设置squid存放cache目录的位置以及大小。第一个数字500是指目录的总大小为500M（默认为100M），第二个数字16是指第一级目录为 16个，第三个数字256是指第二级目录为256个我个人觉得如果网站访问量大，并且内容很多的话，可以考虑将默认的100M改大一点，否则会报错。我就经历过，错误我忘了记录了（该死！）大致就是说超过Max的极限了，当时查了半天才找到罪魁祸首是这条指令，惭愧~~~。&lt;br /&gt;&lt;br /&gt;cache_access_log none&lt;br /&gt;cache_log none&lt;br /&gt;&lt;br /&gt;cache_store_log none #我是将这些log记录都关了， 有需要的可以将它们打开。&lt;br /&gt;&lt;br /&gt;acl managerIP src 10.10.10.10&lt;br /&gt;acl ipcanbrows dst 10.10.10.0/24 #acl应该是squid配置里面最难理解也最需要花时间的地方了。应该说只需要修改很小的一部分就可以了，像这里我只是在原来的基础上加了2条记录，前面一条的意思是我定义了10.10.10.10为源路径，另外一条是指目的端是10.10.10.0/24这个网段。而managerIP, ipcanbrows随便取得名字。具体的规则需要下面的语句来定义。10.10.10.10就是本服务器的内网ip，而apache server的ip就在10.10.10.0/24这个网段里，不需要用外网ip，一定程度上节约了ip地址。&lt;br /&gt;&lt;br /&gt;http_access allow manager managerIP ipcanbrows localhost #加上2个允许就可以了。高深的配置我觉得我也不需要，用户可以访问就达到目的了：）&lt;br /&gt;&lt;br /&gt;httpd_accel_host virtual #由于我后面的apache server是基于ip来做虚拟主机的，因此这里需要设置成virtual。&lt;br /&gt;&lt;br /&gt;httpd_accel_port 80 #http加速的端口，因为习惯等原因，还是将后面的apache server监听80端口。&lt;br /&gt;&lt;br /&gt;httpd_accel_uses_host_header on #如果选了virtual的话，这里必须设置成on。&lt;br /&gt;&lt;br /&gt;这里最多只列出了5%左右的选项，但是我配置的时候就只是用到了这些，因此，如果做网站加速的话，基本设置就是这些。当然需要更强劲的功能的话就需要好好读读squid的配置文件的文档了。&lt;br /&gt;&lt;br /&gt;最后的步骤：&lt;br /&gt;&lt;br /&gt;1. 改变var目录的权限：chown -R nobody var&lt;br /&gt;&lt;br /&gt;2. 创建缓存目录：sbin/squid -z&lt;br /&gt;&lt;br /&gt;3. 启动squid：bin/RunAccel &amp;amp; (这边我使用squid附带的启动脚本来启动squid，有个好处就是，如果squid的进程死了的话，这个脚本会自动启动squid，对于运行在线上的服务器来说，这点太重要了。&lt;br /&gt;&lt;br /&gt;一些使用体会：&lt;br /&gt;&lt;br /&gt;1. squid使用时间长了，速度会变慢，我的建议是每2小时kill掉squid 进程，RunAccel脚本会自动再启动的它。&lt;br /&gt;&lt;br /&gt;2. 写一脚本，放进crontab中，每天凌晨4点左右把cache目录清空。&lt;br /&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;# squid clean swap and restart script by marco lu&lt;br /&gt;SQUID_DIR=/usr/local/squid-54/&lt;br /&gt;PID_FILE=${SQUID_DIR}var/logs/squid.pid&lt;br /&gt;CACHE_DIR=${SQUID_DIR}var/cache&lt;br /&gt;PPID=`ps aux | grep -i squid-54 | grep -v grep|awk '{print $2}'`&lt;br /&gt;kill -9 ${PPID} &amp;gt; /dev/null&lt;br /&gt;kill -9 `cat ${PID_FILE}` &amp;gt; /dev/null&lt;br /&gt;rm -rf $CACHE_DIR/*&lt;br /&gt;${SQUID_DIR}sbin/squid -z &amp;gt; /dev/null&lt;br /&gt;if [ $? -eq 0 ]&lt;br /&gt;then&lt;br /&gt;${SQUID_DIR}bin/RunAccel &amp;amp; &amp;gt; /dev/null&lt;br /&gt;fi</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:39080</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/39080.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=39080"/>
    <title>manpages-zh包</title>
    <published>2007-03-05T05:16:17Z</published>
    <updated>2007-03-05T05:16:17Z</updated>
    <content type="html">manpage的中文包中的文件是gb码的，在utf8环境下无法使用。&lt;br /&gt;今天apt-get install manpages-zh，后， 在查看手册时都是乱码，这是因为我一直用utf8的原因。&lt;br /&gt;于是我将gb码的文件都转成了utf8的：&lt;br /&gt;&lt;br /&gt;cd /usr/share/man&lt;br /&gt;mkdir zh_CN.UTF-8&lt;br /&gt;for f in `find zh_CN -type f`; do echo $f; i=`basename $f`; d=`echo $f|cut -d / -f 2`; mkdir -p zh_CN.UTF-8/$d; zcat $f | iconv -f gb2312 -t utf8 | gzip -f &amp;gt; zh_CN.UTF-8/$d/$i; done&lt;br /&gt;&lt;br /&gt;转换完成后，我用zcat查看这些utf8文件没有问题，但是一旦man ls时，仍然是乱码。&lt;br /&gt;看了一下man命令的手册。man -Tutf8 ls就好了，就是有一个小问题，在konsole上显示时，出现汉字重叠现象； 但 man -Tutf8 ls | less则没有此问题。&lt;br /&gt;写一个脚本,命名为man.utf8&lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;which less &amp;gt; /dev/null || echo "man needs less!"&lt;br /&gt;man -Tutf8 $* | less&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;做一个别名alias，方便使用。&lt;br /&gt;echo alias man='~/script/shell/man.utf8' &amp;gt;&amp;gt; ~/.bashrc&lt;br /&gt;echo alias cman='LC_ALL=C man' &amp;gt;&amp;gt; ~/.bashrc</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:38336</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/38336.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=38336"/>
    <title>常用SNS开源系统比较(zz)</title>
    <published>2007-02-21T06:12:45Z</published>
    <updated>2007-02-21T06:12:45Z</updated>
    <category term="sns"/>
    <content type="html">DotNode：功能和界面完全是Orkut的克隆版。最早的开源SNS系统。目前还处于开发的初期，功能和安全都还比较脆弱。DotNode更像是一个实验版本（因为Orkut本身就不算是一个成功的产品）。&lt;br /&gt;&lt;br /&gt;AroundMe：定制性强。默认提供的功能就比较多，如果要达到自己的使用标准，需要进行一些二次开发。因为AroundMe已经递交到SF.Net，这看起来更像是程序员们使用的一个实验品，所以在功能上比较全，包括Blog、WIKI、论坛、圈子、频道等功能。&lt;br /&gt;&lt;br /&gt;Elgg：更像一个博客程序，每个人拥有自己的blog地址，类似于donews.net的url方式。每个作者之间可以互加好友。与blog.donews不同的是，Elgg每个人都可以建立自己的社区主题板块，并且这个社区的形式跟Google Group类似。值得一提的是，Elgg的汉化是这四个程序中最好的。&lt;br /&gt;&lt;br /&gt;PeopleAggregator：相比之下，PeopleAggregator更像是MySpace的翻版。从官方的示例站点来看，不论是色调布局，还是相关功能，都有MySpace的影子。PeopleAggregator在用户体验上做的比较好，几乎每一步要做什么、怎么操作，都能够一目了然。从对PeopleAggregator相关介绍来看，PeopleAggregator系统不论是从程序结构还是产品结构，都做的比较严谨。在国外的对SNS社区软件的消息中，PeopleAggregator也是备受关注的项目，TechCrunch上就有消息说看好PeopleAggregator倡导的”开放识别标准”。很多人认为”PeopleAggregator将是真正意义上的Web2.0门户。”&lt;br /&gt;&lt;br /&gt;这四个程序我都分别注册登录，做了亲身体验，以上所述大致为体验感受。如果要在这四个系统中选择一个来搭建SNS系统，我推荐AroundMe或PeopleAggregator，但我更倾向于PeopleAggregator。目前二者都没有完全的汉化版本。从演示站点来看，PeopleAggregator提供的界面比较丑陋，AroundMe就要好很多，从可扩展性和发展前景来看，我看好PeopleAggregator。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:38013</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/38013.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=38013"/>
    <title>凸透镜成像的一些基础知识</title>
    <published>2007-02-19T08:44:42Z</published>
    <updated>2007-02-19T08:44:42Z</updated>
    <content type="html">凸透镜是一种常见的透镜，中间厚、边缘薄，至少有一个表面制成球面，或两个表面都制成球面。&lt;br /&gt;&lt;br /&gt;基本概念：&lt;br /&gt;&lt;br /&gt;   1. 主轴：通过凸透镜两个球面球心C1、C2的直线叫凸透镜的主轴。&lt;br /&gt;   2. 光心：凸透镜的中心O点是透镜的光心。&lt;br /&gt;   3. 焦点：平行于主轴的光线经过凸透镜后会聚于主光轴上一点F，这一点是凸透镜的焦点。&lt;br /&gt;   4. 焦距：焦点F到凸透镜光心O的距离叫焦距，用f表示。&lt;br /&gt;   5. 物距：物体到凸透镜光心的距离称物距，用u表示。&lt;br /&gt;   6. 像距：物体经凸透镜所成的像到凸透镜光心的距离称像距，用v表示。&lt;br /&gt;&lt;br /&gt;成像特点：&lt;br /&gt;&lt;br /&gt;    * 物距与像距的关系： &lt;br /&gt;&lt;br /&gt;焦距 	物距 	像距 	像的性质 	应用&lt;br /&gt;f 	u→∞ 	v=f 	不成像 	测焦距&lt;br /&gt;f 	u&amp;gt;2f 	f&lt;div class='ljparseerror'&gt;[&lt;b&gt;Error:&lt;/b&gt; Irreparable invalid markup ('&amp;lt;v&amp;lt;2f&amp;gt;') in entry.  Owner must fix manually.  Raw contents below.]&lt;br /&gt;&lt;br /&gt;&lt;div style="width: 95%; overflow: auto"&gt;凸透镜是一种常见的透镜，中间厚、边缘薄，至少有一个表面制成球面，或两个表面都制成球面。&lt;br /&gt;&lt;br /&gt;基本概念：&lt;br /&gt;&lt;br /&gt;   1. 主轴：通过凸透镜两个球面球心C1、C2的直线叫凸透镜的主轴。&lt;br /&gt;   2. 光心：凸透镜的中心O点是透镜的光心。&lt;br /&gt;   3. 焦点：平行于主轴的光线经过凸透镜后会聚于主光轴上一点F，这一点是凸透镜的焦点。&lt;br /&gt;   4. 焦距：焦点F到凸透镜光心O的距离叫焦距，用f表示。&lt;br /&gt;   5. 物距：物体到凸透镜光心的距离称物距，用u表示。&lt;br /&gt;   6. 像距：物体经凸透镜所成的像到凸透镜光心的距离称像距，用v表示。&lt;br /&gt;&lt;br /&gt;成像特点：&lt;br /&gt;&lt;br /&gt;    * 物距与像距的关系： &lt;br /&gt;&lt;br /&gt;焦距 	物距 	像距 	像的性质 	应用&lt;br /&gt;f 	u→∞ 	v=f 	不成像 	测焦距&lt;br /&gt;f 	u&amp;gt;2f 	f&amp;lt;v&amp;lt;2f 	倒立、缩小的实像 	照相机&lt;br /&gt;f 	u=2f 	v=2f 	倒立、等大的实像 	粗测焦距&lt;br /&gt;f 	f&amp;lt;u&amp;lt;2f 	v&amp;gt;2f 	倒立、放大的实像 	幻灯机&lt;br /&gt;f 	u=f 	v→∞ 	不成像 	手电筒&lt;br /&gt;f 	u&amp;lt;f 		正立、放大的虚像 	放大镜&lt;br /&gt;&lt;br /&gt;    * 物像移动方向总是与物体移动方向相同。&lt;br /&gt;    * 物体移动的速度与物像移动速度的关系：&lt;br /&gt;          o 当u&amp;gt;2f时，物体移动速度大于物像移动速度；&lt;br /&gt;          o 当u=2f时，物体移动速度等于物像移动速度；&lt;br /&gt;          o 当f&amp;lt;u&amp;lt;2f时，物体移动速度小于物像移动速度；&lt;br /&gt;          o 当u&amp;lt;f时，物体移动速度小于物像移动速度。 &lt;br /&gt;    * 物体与物像的距离关系：&lt;br /&gt;          o 当u&amp;gt;f时，物体与物像的距离的最小值为4f，在u=2f时出现。 &lt;br /&gt;    * 成像公式：\frac{1}{u}+\frac{1}{v}=\frac{1}{f}&lt;br /&gt;          o 证明： &lt;br /&gt;&lt;br /&gt;应用&lt;br /&gt;&lt;br /&gt;    * 放大镜&lt;br /&gt;    * 幻灯机&lt;br /&gt;    * 照相机&lt;br /&gt;    * 显微镜&lt;br /&gt;    * 望远镜&lt;br /&gt;    * 眼镜&lt;/div&gt;&lt;/div&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:37770</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/37770.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=37770"/>
    <title>open与文件大小问题</title>
    <published>2007-02-15T10:18:37Z</published>
    <updated>2007-02-15T10:18:37Z</updated>
    <content type="html">当你使用fopen打开文件的时候，如果文件大于2G，你会发现打开失败。&lt;br /&gt;&lt;br /&gt;照理说在现在的OS下没有这个限制了,linux2.2的时候是有这个限制的。&lt;br /&gt;&lt;br /&gt;其实这主要是因为off_t类型的问题，如果是4字节的int型，则最大就是2G了。所以在编译时需要指定_FILE_OFFSET_BITS：&lt;br /&gt;gcc -D_FILE_OFFSET_BITS=64 -o main main.c &lt;br /&gt;&lt;br /&gt;这样就一切OK了。&lt;br /&gt;&lt;br /&gt;在编译php时也需要注意这个问题，因为如果不加上该宏定义，则php无法打开大文件。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:37255</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/37255.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=37255"/>
    <title>永久修改windows中的安装路径</title>
    <published>2007-02-06T08:40:04Z</published>
    <updated>2007-02-06T08:40:04Z</updated>
    <content type="html">windows中默认安装路径是C:\Program Files&lt;br /&gt;&lt;br /&gt;如果需要永久修改，那么修改注册表键：&lt;br /&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesPath</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:35954</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/35954.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=35954"/>
    <title>tsocks/tor/privoxy等作用</title>
    <published>2006-12-29T03:02:24Z</published>
    <updated>2006-12-29T03:02:24Z</updated>
    <content type="html">tsocks是个socks库，可以将其他网络操作转换为socks。如果某个应用程序没有支持代理，那么你可以用tsocks。&lt;br /&gt;tor，是一个加密的socks代理服务器。&lt;br /&gt;privoxy，是一个web代理服务器，带有过滤功能。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:35625</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/35625.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=35625"/>
    <title>utf编码和脚本执行问题</title>
    <published>2006-12-22T03:11:44Z</published>
    <updated>2006-12-22T03:11:44Z</updated>
    <category term="script"/>
    <category term="utf"/>
    <category term="utf8"/>
    <category term="utf-8"/>
    <content type="html">用editplus编写脚本时，如果存储成utf相关的编码，则无法被执行。&lt;br /&gt;这是因为utf编码的文件在文件头写入了一些信息来标志该文件是utf的编码。但是无论是内核还是解释器，并不认识那些字节，所以在linux下会报这样的错误：&lt;br /&gt;cannot execute binary file&lt;br /&gt;&lt;br /&gt;看来utf的标准还是没有能够很好的推行下去。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:35386</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/35386.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=35386"/>
    <title>flying zero logfile</title>
    <published>2006-12-13T08:05:00Z</published>
    <updated>2006-12-13T08:05:00Z</updated>
    <content type="html">当日志增长较快，占满了磁盘空间时，我们应使用：&lt;br /&gt;cp /dev/null  abc-access.log&lt;br /&gt;来对日志文件清零，否则会导致正在运行的服务受到影响。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:34900</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/34900.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=34900"/>
    <title>服务器自动升级的策略</title>
    <published>2006-12-13T03:49:47Z</published>
    <updated>2006-12-13T03:49:47Z</updated>
    <content type="html">本文以debian系统为例，主要讨论了策略和实施。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;服务器自动升级带来的问题有两个方面：&lt;br /&gt;1、稳定性&lt;br /&gt;2、安全性&lt;br /&gt;&lt;br /&gt;下面分别针对这两种情况做一些分析：&lt;br /&gt;&lt;b&gt;稳定性&lt;/b&gt;&lt;br /&gt;	问题来源：虽然OS发行商认为某些包应该升级，但是由于只是发行商自己做了测试，因此是否会带来兼容和稳定方面的问题，谁也不能百分百的保证，特别是提供web服务的服务器。升级的目的一般有：安全问题，性能提升，功能增加等。&lt;br /&gt;	策略：对于所有的升级，我们都应该有一台机器用来测试，并同时提供服务，以检测服务的影响与否。经过一段时间检测（比如一周），发现没有问题后，再在其他机器上升级。另外对于安全升级和其他升级，最好分开，安全升级的优先级设得更高些，测试的时间可以短一些，比如半天到一天。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;安全性&lt;/b&gt;&lt;br /&gt;	问题来源：DNS攻击或者官方的升级服务器被入侵。虽然这两种攻击几率很小，但是一旦发生，则会发生灾难性的后果，特别是发行商的升级服务器被入侵后，木马便能够很容易地安装到用户的服务器中。这在历史上曾经发生过。&lt;br /&gt;	策略：同时从两个平行的顶级镜像建立软件包仓库，通过比较两份镜像的内容，如果相同的软件包得到的md5不一样，说明一个镜像可能存在问题，这样能够及时发现安全问题。&lt;br /&gt;&lt;br /&gt;实施：&lt;br /&gt;准备三台服务器，A,B,C。A用来获取最新的镜像，B是一周前的镜像，C是升级测试服务器。&lt;br /&gt;在A上配置仓库时，配置两份，从不同来源获取。&lt;br /&gt;待续。。。</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:34780</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/34780.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=34780"/>
    <title>加速你的寶貝, vBulletin 的6+1種加速方法(zz)</title>
    <published>2006-12-12T09:09:13Z</published>
    <updated>2006-12-12T09:09:13Z</updated>
    <content type="html">from &lt;a href="http://www.twvbb.com/vbb/thread/30/1096/"&gt;http://www.twvbb.com/vbb/thread/30/1096/&lt;/a&gt;&lt;br /&gt;使用不同的手段為vBB加速的確是有的, 但是通常需要主機環境上的配合&lt;br /&gt;vBB 本身就提供對加速環境的相容功能, 這點看 config.php 就知道了&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vBB加速法1. (適合所有需要快取的程式, 不止php)使用 memcached&lt;br /&gt;&lt;br /&gt;memcached 是新一代的快取加速方式, 能把需要快取的內容放到 RAM裡, 並可以在同一台安裝memcached的機器上提供對不同主機的服務, 這個只要開啟 config.php 的 $config['Datastore']['class'] = 'vB_Datastore_Memcached';&lt;br /&gt;這樣可以開啟vBB首頁 RAM 快取功能, 把每次要從mysql挖出資料並經php運算排版的過程改成只要從RAM 取出即可, 這樣的「得來速」通道, 你說會有多快?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vBB加速法2. (適合所有 php程式加速 opcode cacher)eAccelerator&lt;br /&gt;&lt;br /&gt;這是 跟昂貴的 Zend Platform 加速器使用類似原理的把php預先編譯且的快取方式達到php加速的目的,&lt;br /&gt;&lt;br /&gt;目前使用類似方法常見加速器有以下五個:&lt;br /&gt;&lt;br /&gt;xcache &lt;a href="http://trac.lighttpd.net/xcache/"&gt;http://trac.lighttpd.net/xcache/&lt;/a&gt; (免費, )&lt;br /&gt;&lt;br /&gt;APC &lt;a href="http://pecl.php.net/package/APC"&gt;http://pecl.php.net/package/APC&lt;/a&gt; (免費)&lt;br /&gt;&lt;br /&gt;eAccelerator &lt;a href="http://eaccelerator.net/"&gt;http://eaccelerator.net/&lt;/a&gt; (免費, 相容 Zend Optimiizer) 相容就是可以同時開啟使用的意思&lt;br /&gt;&lt;br /&gt;Zend Platform &lt;a href="http://www.zend.com/products/zend_platform"&gt;http://www.zend.com/products/zend_platform&lt;/a&gt; (商業, 快2000美元)&lt;br /&gt;&lt;br /&gt;ionCube Encoder &lt;a href="http://www.ioncube.com/"&gt;http://www.ioncube.com/&lt;/a&gt; (商業, 也不便宜)&lt;br /&gt;&lt;br /&gt;五樣加速補品的測試報告在 這裡:&lt;br /&gt;&lt;br /&gt;一般來說, 相同硬體環境下, 使用本加速補品可以得到將近兩倍的效能( 23.36/ 44.67 )&lt;br /&gt;&lt;br /&gt;個人選擇使用 eAccelerator 原因是她可以很好的協同 Zend Optimizer一同快樂的運作, 同時間可以服務幾乎多一倍的用戶&lt;br /&gt;&lt;br /&gt;xcache 是新出來的加速補品, 由大名鼎鼎的 lighttpd 開發小組所開發, 加速效能看來比 eAccelerator 甚至 Zend platform 甚至其他加速器都還要好, 有時間想給她試試&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vBB加速法0. 就是針對你的 硬體環境, 軟體版本, 進行量身微調, 修改 my.cnf, php.ini 以及 httpd.conf&lt;br /&gt;&lt;br /&gt;這種方式最保險的辦法是到 vBulletin 英國原廠論壇去求助(當然你要有服務授權先), 會有專人為你的環境提出最佳化的 ini 修改建議,&lt;br /&gt;&lt;br /&gt;此法不要輕易使用, 因為改的不好反而會影響vBulletin 執行效能&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vBB加速法0a. 這是另一種傳說中的方法, 就是換個快一點的 httpd, 例如 lighttpd,&lt;br /&gt;&lt;br /&gt;或者使用 apache 的 worker MPM. 節省系統裡大量衍生的程序, 自然能夠提生效能&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vbb加速法0b. 使用反向代理技術, 將 php的服務與其他靜態內容服務(html/gif/jpg/css/js/...)分開在兩個不同的服務程式, 這樣可以減輕大量的只需要回應客戶端gif圖檔還要掛載 php及其各式模組的負擔&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vbb加速法0c. 用多台web主機, 兩台以上的資料庫主機, 甚至使用 MySQL 叢集, 這已經不像加速, 而是擴充負載能力了 ^_^&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;vbb加速法1a. 最佳化你的 MySQL 運作參數, 適度增加各種表格快取大小等, 甚至使用更快的 thread lib 執行序函示庫(FreeBSD), 甚至hack 並重新編譯你的 glibc (Linux)全面提升 MySQL 的執行效能, 縮短 vBulletin 的資料取得時間&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;使用不同的加速方法都可能遇到不同的狀況需要個別解決, 例如使用 eAccelerator, 你就不能用 php 5.0.x 而是要使用 5.1.x&lt;br /&gt;&lt;br /&gt;使用加速器, 可能你的 vBulletin 的設定要跟 MySQL 的版本甚至編碼方式相配合, 否則可能看到是正常,輸入中文資料卻變成亂碼的情形&lt;br /&gt;&lt;br /&gt;使用 Apache Worker MPM, 最好使用 FreeBSD 而不是 Linux, 因為 Linux下的典型 apache, 其 Worker 模式不支援以模組運行的php, 你說那把 php當成 cgi不就好了? 聰明! 的確有人這樣做, 但是把php 以CGI執行的方式 , 你又要使用 FastCGI 模式, 不然效率還是不好, 但是使用 FastCGI 或者 CGId 模式運行的 PHP, 又可能常常會出現 503 Error 喔! 夠折騰人吧?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:34224</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/34224.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=34224"/>
    <title>open pipeline in firefox</title>
    <published>2006-12-12T05:34:40Z</published>
    <updated>2006-12-12T05:34:40Z</updated>
    <category term="pipeline"/>
    <content type="html">在firefox地址栏里输入about:config，找到下面三项：&lt;br /&gt;    * network.http.pipelining = false&lt;br /&gt;    * network.http.pipelining.maxrequests = 4&lt;br /&gt;    * network.http.proxy.pipelining = false&lt;br /&gt;修改为：&lt;br /&gt;    * network.http.pipelining = true&lt;br /&gt;    * network.http.pipelining.maxrequests = 30 (根据自己的网络决定大小)&lt;br /&gt;    * network.http.proxy.pipelining = true&lt;br /&gt;&lt;br /&gt;Q:什么是pipeline?&lt;br /&gt;A:&lt;a href="http://www.mozilla.org/projects/netlib/http/pipelining-faq.html"&gt;http://www.mozilla.org/projects/netlib/http/pipelining-faq.html&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:33921</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/33921.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=33921"/>
    <title>gearman from danga</title>
    <published>2006-12-12T03:17:37Z</published>
    <updated>2006-12-12T03:20:12Z</updated>
    <category term="distributed job system"/>
    <category term="gearman"/>
    <category term="danga"/>
    <category term="livejournal"/>
    <category term="distributed"/>
    <category term="lj"/>
    <category term="mogilefs"/>
    <content type="html">danga被Six Apart收购了。&lt;br /&gt;&lt;br /&gt;gearman是一个分布式作业系统，用来将计算任务分配到不同的机器。&lt;br /&gt;mogilefs是一个分布式文件系统，用来将文件存储到后端，并且实现网络冗余。&lt;br /&gt;&lt;br /&gt;但是无论是gearman还是mogilefs，都存在一个问题，就是选择的问题。&lt;br /&gt;当gearman分配任务时，应该分配给谁？从最优化角度来看，应该分配给(cpu)最空闲的机器。mogilefs同样也是，当写存储时，我们也希望写到(disk)最空闲的机器，当读存储时，我们也希望从(io)最空闲的机器来读取数据。&lt;br /&gt;&lt;br /&gt;但是要获取一个集群中的“最闲的”机器，本身是有难度的，我想。因为既要考虑到实时，又要考虑到效率和性能。&lt;br /&gt;&lt;br /&gt;livejournal是如何做到的？还是他们就是没有考虑？</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:hanwoody:33581</id>
    <link rel="alternate" type="text/html" href="http://hanwoody.livejournal.com/33581.html"/>
    <link rel="self" type="text/xml" href="http://hanwoody.livejournal.com/data/atom/?itemid=33581"/>
    <title>轻量级的web服务器</title>
    <published>2006-12-06T01:51:11Z</published>
    <updated>2006-12-06T01:51:11Z</updated>
    <content type="html">开源&lt;br /&gt;lighttpd&lt;br /&gt;thttpd&lt;br /&gt;shttpd&lt;br /&gt;boa&lt;br /&gt;tux&lt;br /&gt;wn&lt;br /&gt;nginx&lt;br /&gt;fnord &lt;a href="http://fmorg.sourceforge.net/"&gt;http://fmorg.sourceforge.net/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;商业&lt;br /&gt;zeus&lt;br /&gt;litespeed</content>
  </entry>
</feed>
