Tuesday, March 31, 2009

谷歌音乐,百度MP3

谷歌推出了免费音乐搜索,是与top100.cn合作的,在这样的形式下,百度的股价大跌5%,看来在伟大的中国,只有依靠国人的力量来击垮对手,在历史上这样的案例比比皆是,看来要进入中国市场的老外们要阅读的不是经济学人,而是中国历史,再简单不过了。

Friday, March 27, 2009

Perl never die

Hard working...

Tuesday, March 17, 2009

Linux VLM how to

创建和管理LVM

  要创建一个LVM系统,一般需要经过以下步骤:

  1、 创建分区

  使用分区工具(如:fdisk等)创建LVM分区,方法和创建其他一般分区的方式是一样的,区别仅仅是LVM的分区类型为8e。

  2、 创建物理卷

  创建物理卷的命令为pvcreate,利用该命令将希望添加到卷组的所有分区或者磁盘创建为物理卷。将整个磁盘创建为物理卷的命令为:

  # pvcreate /dev/hdb

  将单个分区创建为物理卷的命令为:

  # pvcreate /dev/hda5

  3、 创建卷组

  创建卷组的命令为vgcreate,将使用pvcreate建立的物理卷创建为一个完整的卷组:

  # vgcreate web_document /dev/hda5 /dev/hdb

  vgcreate命令第一个参数是指定该卷组的逻辑名:web_document。后面参数是指定希望添加到该卷组的所有分区和磁盘。vgcreate在创建卷组 web_document 以外,还设置使用大小为4 MB的PE(默认为4MB),这表示卷组上创建的所有逻辑卷都以 4 MB 为增量单位来进行扩充或缩减。由于内核原因,PE大小决定了逻辑卷的最大大小,4 MB 的PE决定了单个逻辑卷最大容量为 256 GB,若希望使用大于256G的逻辑卷则创建卷组时指定更大的PE。PE大小范围为8 KB 到 512 MB,并且必须总是 2 的倍数(使用-s指定,具体请参考man vgcreate)。

  4、 激活卷组

  为了立即使用卷组而不是重新启动系统,可以使用vgchange来激活卷组:

  # vgchange -a y web_document

  5、 添加新的物理卷到卷组中

  当系统安装了新的磁盘并创建了新的物理卷,而要将其添加到已有卷组时,就需要使用vgextend命令:

  # vgextend web_document /dev/hdc1

  这里/dev/hdc1是新的物理卷。

  6、 从卷组中删除一个物理卷

  要从一个卷组中删除一个物理卷,首先要确认要删除的物理卷没有被任何逻辑卷正在使用,就要使用pvdisplay命令察看一个该物理卷信息

  如果某个物理卷正在被逻辑卷所使用,就需要将该物理卷的数据备份到其他地方,然后再删除。删除物理卷的命令为

vgreduce:

  # vgreduce web_document /dev/hda1


  7、 创建逻辑卷

  创建逻辑卷的命令为lvcreate:

  # lvcreate -L1500 –nwww1 web_document

  该命令就在卷组web_document上创建名字为www1,大小为1500M的逻辑卷,并且设备入口为/dev/web_document/www1 (web_document为卷组名,www1为逻辑卷名)。如果希望创建一个使用全部卷组的逻辑卷,则需要首先察看该卷组的PE数,然后在创建逻辑卷时指定:

  # vgdisplay web_document| grep "Total PE"

  Total PE 45230

  # lvcreate -l 45230 web_document -n www1


  8、 创建文件系统

  笔者推荐使用reiserfs文件系统,来替代ext2和ext3

  创建了文件系统以后,就可以加载并使用它:

  # mkdir /data/wwwroot

  # mount /dev/web_document/www1 /data/wwwroot


  如果希望系统启动时自动加载文件系统,则还需要在/etc/fstab中添加内容:

  /dev/web_document/www1 /data/wwwroot reiserfs defaults 1 2

  9、 删除一个逻辑卷

  删除逻辑卷以前首先需要将其卸载,然后删除:

  # umount /dev/web_document/www1
  # lvremove /dev/web_document/www1
  lvremove -- do you really want to remove "/dev/web_document/www1"? [y/n]: y
  lvremove -- doing automatic backup of volume group "web_document"
  lvremove -- logical volume "/dev/web_document/www1" successfully removed


  10、 扩展逻辑卷大小

  LVM提供了方便调整逻辑卷大小的能力,扩展逻辑卷大小的命令是lvcreate:

  # lvextend -L12G /dev/web_document/www1
  lvextend -- extending logical volume "/dev/web_document/www1" to 12 GB
  lvextend -- doing automatic backup of volume group "web_document "
  lvextend -- logical volume "/dev/web_document/www1" successfully extended


  上面的命令就实现将逻辑卷www1的大小扩招为12G。

  # lvextend -L+1G /dev/web_document/www1
  lvextend -- extending logical volume "/dev/web_document/www1" to 13 GB
  lvextend -- doing automatic backup of volume group "web_document "
  lvextend -- logical volume "/dev/web_document/www1" successfully extended


  上面的命令就实现将逻辑卷www1的大小增加1G。

  增加了逻辑卷的容量以后,就需要修改文件系统大小以实现利用扩充的空间。笔者推荐使用reiserfs文件系统来替代ext2或者ext3。因此这里仅仅讨论reiserfs的情况。Reiserfs文件工具提供了文件系统大小调整工具:resize_reiserfs。对于希望调整被加载的文件系统大小:

  # resize_reiserfs -f /dev/web_document/www1

  一般建议最好将文件系统卸载,调整大小,然后再加载:

  # umount /dev/web_document/www1
  # resize_reiserfs /dev/web_document/www1
  # mount -treiserfs /dev/web_document/www1 /data/wwwroot


  对于使用ext2或ext3文件系统的用户可以考虑使用工具

  ext2resize(resize2fs)。http://sourceforge.net/projects/ext2resize

  11、 减少逻辑卷大小

  使用lvreduce即可实现对逻辑卷的容量,同样需要首先将文件系统卸载:

  # umount /data/wwwroot
  # resize_reiserfs -s-2G /dev/web_document/www1
  # lvreduce -L-2G /dev/web_document/www1
  # mount -treiserfs /dev/web_document/www1 /data/wwwroot

Monday, March 16, 2009

RPM Print Package Version

rpm -qa --qf "%{n}-%{arch}\n"
output:

filesystem-x86_64
libXau-i386
wireless-tools-x86_64
libvorbis-x86_64


rpm -qi {package-name}
rpm -qa --qf "%{n}-%{v}-%{r}.%{arch}\n" | less
rpm --querytags | less

Just a good django-appengine tut

http://www.42topics.com/dumps/django/docs.html

Friday, March 13, 2009

MySQL的性能调优工具:比mysqlreport更方便的tuning-primer.sh

LINK: http://www.chedong.com/blog/archives/001451.html
http://www.day32.com/MySQL/

Mirror With Wget

wget --mirror --limit-rate=100k --wait=1 -erobots=off --no-parent --page-requisites --convert-links --no-host-directories --cut-dirs=2 http://www.yahoo.com/mirror

Wednesday, March 11, 2009

Remove KDE and Gnome Desktop

Yeah, just remove both of them. Only Fluxbox here! Slackware (12.2). Best Linux.

VIM中的正则使用

http://blog.csdn.net/menghun_99520/archive/2008/06/06/2517970.aspx

Sunday, March 8, 2009

Python and Eventlet

http://wiki.secondlife.com/wiki/Eventlet/Documentation

Eventlet is an easy to use networking library written in Python. Eventlet is capable of supporting a large number of sockets per process by using nonblocking I/O, cooperatively multiplexing them through a single main loop. This approach allows for the implementation of massively concurrent servers which would require prohibitive amounts of memory under a traditional preemptive multi-threading or multi-process model. However, nonblocking I/O libraries such as asyncore or twisted can be difficult for programmers to use because they require the use of continuation passing style. This means code must be broken up into functions which initiate operations, and functions which will be called when the operation is complete, known as "callbacks."


Just use eventlet with a threads scanner to insert data to MySQL database.

Wednesday, March 4, 2009

PortAudio MME DirectSound

PortAudio是一个跨平台的声音驱动
MME与DirectSound是Windows平台上的,像PJSIP这样的项目默认的是使用PortAudio驱动,如果在Windows上编译,就要使用MME或者DirectSound,因为使用PortAudio可能会出现问题。

Tuesday, March 3, 2009

Work SVN on Samba


[global]
create mask = 0644
force create mode = 0600
security mask = 0555
force security mode = 0600