| Subcribe via RSS

彩云之南

December 16th, 2008 | No Comments | Posted in Travel

上个月利用年假去了趟云南丽江,前前后后总共呆了8天。现在的丽江古城已经非常商业化了,到处都是商铺,而且卖的东西几乎千篇一律,虽然如此,丽江还是给我了很深刻的印象,丽江是个很适合发呆的地方,当你身处此地时,你便会不由自主的放慢脚步,沉思……

此次总共走了两个路线,一个是梅里雪山4日游,还有一个是泸沽湖2日游,另外花了半天时间去了趟束河古镇。

梅里雪山这条路线还是非常不错的,其实主要还是奔着去看梅里雪山的,很多人只知道玉龙雪山,其实几乎在丽江任何地方你抬头都能看到玉龙雪山,而且玉龙雪山就一座主峰,而且山上也没什么积雪,所以我也就远观而已。而梅里雪山则不同,梅里雪山由13座主峰组成,而且一年当中能看到梅里雪山的时间也不长,雨季是肯定看不到了,下雪的时候会封山,而且道路极其难走,所以导游告诉我们一年当中最佳时间是11月底和12月初,这次正好碰到了这个最佳时机,后来证明我还是挺幸运的,后来我回到丽江后没几天,梅里那边就下雪了,肯定就去不了了。

泸沽湖这条路线由于路况不好,虽然路程不远,单程大概也就不到300公里,却要花7、8个小时,所以大部分时间都花在路上了,个人感觉泸沽湖跟纳木错比还是差多了。

废话不多说了,还是多上些照片吧。大家可以单击图片看大图。

丽江清晨柔柔的云儿 Canon EOS 300D

日照金山:早上大概7:40左右日出时拍摄的梅里雪山,Canon EOS 30V/28-135 IS/柯达E100VS反转片


拉市海 Canon EOS 30V/28-135 IS/柯达E100VS反转片

松赞林寺里的小喇嘛们




日落前拍的拉市海 Canon EOS 30V/28-135 IS/柯达E100VS反转片


泸沽湖 Canon EOS 300D

里格半岛 EOS 300D

篝火舞会中的帅哥

更多图片可以访问我的Flickr,里面还有很多去年去西藏时候拍的照片:)

Tags: , , , , ,

Varnish –为你的网站加速

October 23rd, 2008 | No Comments | Posted in Cache System

Web cache对于一个高流量的网站来说是非常重要的,通过cache常见的静态文件,如图片, flash, css和js等不常改动的文件,可以大量减轻后台server的压力。

说到这可能很多人都会想到开源软件Squid,Squid如今广泛的被各大网站所使用,如sina、sohu等,但与此同时,我们还有另外一个选择,那就是Varnish,下面是一些官方网站的介绍:

“Varnish is a state-of-the-art, high-performance HTTP accelerator. Varnish is targeted primarily at the FreeBSD 6/7 and Linux 2.6 platforms, and takes full advantage of the virtual memory system and advanced I/O features offered by these operating systems.”

我一些朋友已经在他们的production环境下采用Varnish来替换Squid,据说性能很不错。

所以这里我打算临时给自己的网站也搭建一个web cache,当然我这只是做测试而已,以我网站目前的流量还远远不到需要cache的地步:)

首先先大概介绍一下web cache的工作原理:

 

现在让我们来开始安装Varnish,Varnish最新稳定版是1.1.2,可以从这里下载

当前我的web server运行的是FreeBSD,Apache,PHP和MySQL,Varnish讲会被安装在另外单独一台RedHat server上。

安装
1. 为Varnish创建用户和组’www’

# groupadd www
# useradd www -g www

2. 编译安装Varnish

# cd varnish-1.1.2
# ./configure –prefix=/home/varnish
# make && make install

3. 创建cache文件和日志文件目录

# mkdir -p /data02/cachefile
# chown -R www.www /data02/cachefile
# mkdir -p /data02/cachelog
# chown -R www.www /data02/cachelog

4. Varnish的配置文件
例子:

backend mywebserver {
set backend.host = “YOUR_WEB_SERVER_IP”;
set backend.port = “80″;
}

acl purge {
“localhost”;
“127.0.0.1″;
“192.168.1.0″/24;
}

sub vcl_recv {
if (req.request == “PURGE”) {
if (!client.ip ~ purge) {
error 405 “Not allowed.”;
}
lookup;
}

if (req.http.host ~ “^www.isoracle.com”) {
set req.backend = mywebserver;
if (req.request != “GET” && req.request != “HEAD”) {
pipe;
}
elseif(req.url ~ “\.(php|cgi|pl)($|\?)”) {
pass;
}
else {
lookup;
}
}
else {
error 404 “isoracle.com Cache Server”;
lookup;
}
}

sub vcl_hit {
if (req.request == “PURGE”) {
set obj.ttl = 0s;
error 200 “Purged.”;
}
}

sub vcl_miss {
if (req.request == “PURGE”) {
error 404 “Not in cache.”;
}
}

sub vcl_fetch {
if (req.request == “GET” && req.url ~ “\.(txt|js)$”) {
set obj.ttl = 3600s;
}
else {
set obj.ttl = 10d;
}
}

更多关于配置文件的说明请参考官方文档的说明。

5. 启动varnishd

# /home/varnish/sbin/varnishd -n /data02/cachefile -f /home/varnish/vcl.conf -a 0.0.0.0:80 -s file,/data02/cachefile/cache.dat,500M -g www -u www -w 50,200,10 -T 127.0.0.1:1800 -p client_http11=on

更多Varnish启动选项,可以参考命令”varnishd –help”

6. 启动varnishncsa

# /home/varnish/bin/varnishncsa -n /data02/cachefile -w /data02/cachelog/varnish.log &

7. 检查Varnish状态

# /home/varnish/bin/varnishstat

此命令将会显示当前Varnish工作状态的很多参数,比如cache hints, cache misses等。

检验Varnish所搭建的web cache是否生效
这里我们用curl来获取http header来检查。

# curl –head http://www.isoracle.com/
HTTP/1.1 200 OK
Server: isoracle/Stable 1 (Unix) PHP/5.2.0
Last-Modified: Sat, 12 Jul 2008 21:54:39 GMT
ETag: “96347-cc05-4879281f”
Content-Type: text/html
Content-Length: 52229
Date: Sun, 13 Jul 2008 01:36:12 GMT
X-Varnish: 1652882410 1652882077
Age: 8877
Via: 1.1 varnish
Connection: keep-alive

从http header的信息来看,Varnish已经在工作了。

最后你只要修改一下你的DNS的A记录,将原先指向web server的IP指向Varnish所在server的IP就可以了。

Tags: ,

FreeBSD 7.0 Release doesn’t support Broadcom 5722 in Dell R300

July 21st, 2008 | 1 Comment | Posted in FreeBSD

I planed to install FreeBSD 7.0 Release on Dell R300, but unfortunately, 7.0 Release doesn’t support the network adapter Broadcom 5722 which is combined in Dell R300.

Some of my friends said that 7.0 stable in snapshot can work with 5722, but I’m not sure if it’s stable enough to support the production environment, so finally, I’ll have to replace it with Dell 1950 which combines Broadcom 5708C :(

Tags: , ,

MySQL中如何定义含有空格的表名或列名

June 30th, 2008 | No Comments | Posted in MySQL

作为一个Oracle DBA,MySQL很多SQL语法与Oracle的还是有很多差异的。

这里我将要在MySQL里建一个表,表名为”Test Table”, 其中一个列名为”First Name”,当我用下列SQL语句来创建此表时,MySQL返回下列错误:

mysql> create table “Test Table2″ (id int, “First Name” varchar(200));

ERROR
1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near ‘”Test Table2″ (id int, “First Name” varchar(200))’ at line 1

这个MySQL数据库是按照默认配置安装的。

那么改如何解决这个问题呢?

方法1:
使用 ` (即数字键1左边那个键)符来代替上面的双引号,就像下面

create table `Test Table2` (id int, `First Name` varchar(200));

方法2:
修改MySQL的配置文件my.cnf文件,在[mysqld]此项中添加下面参数,然后重启MySQL使之生效

sql_mode = ANSI_QUOTES

方法3:
在启动MySQL时添加一个启动选项

mysqld_safe –user=mysql –sql-mode=ANSI_QUOTES &

个人推荐使用方法2

Tags:

LPCD带来的震撼

June 9th, 2008 | No Comments | Posted in Hi-Fi

 

 

记得好像是去年就曾经在CD架上看到雨果唱片公司的LPCD了,当时只知道HDCD、XRCD、SACD这些,所以对LPCD也没怎么在意。直到前两天,在网上下了一张LPCD转成ape格式的《十二钗》雨果女声示范碟,虽然当时只是在笔记本上通过PX200来听,但还是能很明显的感觉到LPCD的威力,初步听感就是声场比普通CD更准确、特别是人声,临场感特别强烈,喜出望外,于是决定一定要买张LPCD来好好听听。

于是今天下午又去了一趟位于上海音乐学院旁边的九龙,那是我常逛的一家专业音像店,这里以古典居多,也可以找到很多国内的作品,最重要的是这里雨果CD很全,本人对雨果唱片一直情有独钟,买的第一张CD就是《雨果发烧碟一》,那时还在念初中,囊中羞涩,买的是D版的,如今当然要支持正版了,好了,废话不多说。

挑了半天,决定还是先买《发烧@港》这张LPCD 45,因为对其中很多作品还算比较熟悉。我买的这张LPCD价格是223/张,价格还是蛮高的,普通的一张雨果CD一般也就90左右,不过我还是相信那句老话:一分钱一分货。

到家后,迫不及待地打开CD、耳放和耳机,这里顺便介绍一下我的设备,CD机是去年买的马兰士CD5001,耳放是云钟的纯甲类,耳机是森海塞尔的HD650,感觉CD机在这套组合中还是显得比较鸡肋,因为买回来不久我就拆开了看过,用料实在令人失望,以后有机会一定要先把他替换掉。

CD盒内共有两张CD,一张是LPCD,另一张就是普通的CD,具体LPCD和普通CD的差异在哪?从附带的说明书来看,传统的CD需要经过:母带—母盘CDR—玻璃模—金属模—压碟—CD这些工序,这个过程中数码格式需要转换5-6次,而LPCD从母带到最终的成品LPCD应该只经过了2次数码转换,而且LPCD直接从母带处理完后直接刻盘,免去了传统玻璃模、金属模、压碟这几道失真损耗非常严重的工序,对音质的提升是肯定的。更多关于LPCD的介绍大家可以到雨果唱片公司的官方网站上查阅这张LPCD刻录面是紫色的,颇显几分神秘,估计应该也属于CD-R,因为CD盒封面上有提示,要求你的CD播放机能兼容CD-R。另外说一下LPCD 33和LPCD 45的区别,说明书上介绍道:LPCD产品规格分为LPCD 33和LPCD 45,LPCD 33是特殊加工处理的CD产品;LPCD 45是录音水准顶峰代表的产品,也是CDR母盘规格最高的。所以,要想完全领略LPCD的魅力,当然要选择LPCD 45了!

 

下面来谈谈个人对《发烧@港》这张专辑的听后感,仅供参考。
1 《阳春白雪》–琵琶
这是整张专辑的第一首,刚入耳,第一感觉就是声音更清晰、定位更准确,所演奏的琵琶声清脆有力、毫不含糊,其他配乐的方位感很强烈,可以很清楚地判断出乐器所在的方位,让我们初步领略LPCD的不凡功底。

2 《望春风》–人声:张杏月
这首是现场版,由老易现场录音,开头是短暂的观众鼓掌声,然后便是萨克斯的演奏,可以感觉是从偏右方传来,这时从中央传来了歌手的声音,定位很清晰。接下来便是歌手的深情演绎,其深厚的唱功展露无疑,加上LPCD的助威,使得女声极富感染力,临场感非常强烈,此时此刻,歌手就仿佛就站立在你的面前,而你已经完全融入到了现场。。。一曲演罢,全场发出了热烈的掌声,可以听出掌声是从前台最先发出,继而引致整个全场.

3 《二泉映月》–二胡
个人觉得,我们通过各种方式不断地追求高音质,并不是为了单纯的让某个乐器听得更清楚,或者说能够听出他的前后左右等等,而是为了通过更高的回放效果来更有力的表现作品所要表达的内容和思想,这就有点类似”形”与”神”,声音是形,作品的思想是神,没有声音这个载体,作品的神是无法展现出来的,如果”形”能够更生动有效的表达出来,那么更有利于让我们充分体会和了解”神”所要反映的实质。

借助于LPCD的精彩传神的表现,当我听完《二泉音乐》之后,不由得心沉了许多,压抑了许久,那时而阵阵颤抖,时而绵绵无尽的二胡,都极生动地描绘了作者内心的悲苦,难怪CD说明书中提道:此曲在心情低落之际切忌聆听!

一言以蔽之,LPCD给了我很多惊喜。

晚上,又在网上订了两张LPCD 45,分别是《十二金钗》雨果女声示范碟和《新历其声》新加坡发烧盛会,期待着更多。。。

Tags: ,

Sun own story of moving to T2000

May 27th, 2008 | No Comments | Posted in IT News

FYI:

http://www.sun.com/blueprints/1205/819-5148.pdf

Tags: ,

安装Memcached

April 27th, 2008 | No Comments | Posted in Cache System

Memcached 是一个非常流行且高性能的cache应用程序,目前被广泛应用在很多web2.0网站,比如:LiveJournal, Facebook, Sourceforge 等。下面简单介绍一下memcached的安装和使用,更详细的资料可以从memcached的官方网站获得:http://danga.com/memcached/

下面的测试都是在RedHat Advanced Server Update 6上实现的。

必须的软件

libevent, http://www.monkey.org/~provos/libevent/
Linux kernel 2.6, 带有epoll的2.6 Linux内核

安装:

libevent

./configure –prefix=/usr
make && make install

memcached
configure的时候有很多参数可供选择,可根据具体需求来选择

./configure –help

./configure –prefix=/home/memcached –with-libevent=/usr
make && make install

运行memcached

/home/memcached/bin/memcached -d -m 100 -l 192.168.1.136 -p 11211 -u nobody

-d: 让memcached以daemon形式运行
-m: 分配给memcached的内存大小,单位是MB
-l: memcached所监听的IP地址
-p: memcached监听的端口
-u: 运行memcached的用户

memcached运行后,我们可以用 ‘netstat’ 来确认端口11211已经打开。

#netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.1.136:11211 0.0.0.0:* LISTEN

几个简单的用来测试memcached的Perl脚本

现在我们已经在192.168.1.136上运行memcached了,下面我们将在另外一台客户端192.168.1.137上来向memcached存储和抓取数据。

由于这两个Perl脚本需要用到 ‘Cache::Memcached’ 模块, 所以在运行之前必须确保其已经在客户端安装好,可以从www.capn.org 上获得,安装完毕后我们就可以开始来做测试了。

1. 将值 ‘123′ 存储到memcached

脚本名称: push_mem.pl

  1. #!/usr/bin/perl
  2. use Cache::Memcached;
  3. my $memd = new Cache::Memcached {
  4.       'servers' => [ "192.168.1.136:11211"],
  5.     };
  6.  
  7. # Set a value
  8. $memd->set("my_key", "123");
  9.  
  10. $memd->disconnect_all();
  11. exit;

2. 从memcached抓取数据

脚本名称: print_mem.pl

  1. #!/usr/bin/perl
  2. use Cache::Memcached;
  3. my $memd = new Cache::Memcached {
  4.       'servers' => [ "192.168.1.136:11211"],
  5.     };
  6. my $val = $memd->get( "my_key" );
  7. if ( $val )
  8. {
  9.      print "Value is '$val'\n";
  10. }
  11.  
  12.  
  13. $memd->disconnect_all();
  14. exit;

输出结果: Value is ‘123′

我们可以看到,当我第一次运行push_mem.pl脚本后,值123就被存储到memcached了,然后当我运行第二个测试脚本print_mem.pl的时候,我们就可以从memcached抓取到我们刚刚存储的值123了。

这里,我只是举了个简单的例子来演示memcached,实际情况中要比这个复杂多了。

提示:
我们可以telnet到memcached的端口11211来检查当前memcached的运行情况,这对检查系统运行状况和排查问题会有些帮助。

[root@web1 scripts]# telnet 192.168.1.136 11211
Trying 192.168.1.136…
Connected to web1.isoracle.com (192.168.1.136).
Escape character is ‘^]’.
input command: stats
STAT pid 23810
STAT uptime 622
STAT time 1209240944
STAT version 1.2.5
STAT pointer_size 32
STAT rusage_user 0.000999
STAT rusage_system 0.061990
STAT curr_items 1
STAT total_items 1
STAT bytes 58
STAT curr_connections 2
STAT total_connections 5
STAT connection_structures 3
STAT cmd_get 1
STAT cmd_set 1
STAT get_hits 1
STAT get_misses 0
STAT evictions 0
STAT bytes_read 43
STAT bytes_written 36
STAT limit_maxbytes 104857600
STAT threads 1
END

而且我们可以计算出cache的命中率, 也就是 get_hits/ cmd_get

Tags:

ORA-27054 error

March 19th, 2008 | No Comments | Posted in Oracle

I have a DB which stores the archived logs in NFS file system, it’s running Oracle 9i and mainly used for Logminer auditing.

Due to the business requirement, I upgraded it to 10g, after that, when I run the Logminer to process the archived log, I got the following errors:

ERROR at line 1:
ORA-01284: file /path/to/arc/100.arc cannot be opened
ORA-00308: cannot open archived log ‘/path/to/arc/100.arc’
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
Additional information: 2
ORA-06512: at “SYS.DBMS_LOGMNR”, line 68
ORA-06512: at line 1

Explanation about ORA-27054:

27054, 00000, “NFS file system where the file is created or resides is not mounted with correct options”
// *Cause:The file was on an NFS partition and either reading the mount tab
// file failed or the partition wass not mounted with the correct
// mount option.
// *Action: Make sure mount tab file has read access for Oracle user and
// the NFS partition where the file resides is mounted correctly.
// For the list of mount options to use refer to your platform
// specific documentation

Solutions from Metalink:

1. Umount the NFS file system and remount it with the following options:
rw,hard,bg,proto=tcp,suid,rsize=32768,wsize=32768,noac

2. Apply patch 5146667.

In my this case, I tried the option 1 to fix the problem.

Tags: ,

Installing RedHat Advanced Server 4 Update5 on Dell 2950

January 14th, 2008 | No Comments | Posted in Linux

Dell 2950 server combines PERC5 Raid controller which needs the last Linux kernel to identify the raid controller driver. At the first time, I try to install RedHat Advanced Server 4 Update2 x86_64 on this server, but this version cannot identify the raid driver of PERC5.

Finally, from Dell tech support, I get to know that only RHEL 4 Update 5 or RHEL 5 can be installed on Dell 2950. So, if you also need install RedHat RHEL on Dell 2950, please try RHEL 4 Update 5 or RHEL 5 version.

Tags: ,

Veritas -How to add a new dg(disk group) and Volume

January 8th, 2008 | 1 Comment | Posted in Storage

* Assuming you have Veritas software installed on your platform correctly.*

I performed the following operations on Sun Fire V480 (Solaris10 Sparc) with Sun T3 storage.

Checking the current vxfs information
#df -k
#format </dev/null — show detailed all disks info
#vxprint -ht
#vxdg list
#vxdisk list

Using ‘vxdiskadm’ to create a new dg
#vxdiskadm
Enter the disk name:cxxdxxtxx
Enter the disk group name: namedg
Next…

Verifying if the dg has been created
#vxdg list
#vxprint -ht
#vxdisk list

Creating a new volume
#vxassist -g YOUR_DG make VOLUME_NAME SIZE
Example: #vxassist -g SITE2dg make archive 10g

Verifying the new volume
#vxprint -ht

Creating the vxfs file system
#mkfs -F vxfs -o bsize=2048 /dev/vx/rdsk/YOUR_DG/VOLUME_NAME
Example: #mkfs -F vxfs -o bsize=2048 /dev/vx/rdsk/SITE2/archive

Creating the destination folders
#mkdir /oracle/archive
#mkdir /oracle/data01
#mkdir /oracle/data02
#mkdir /oracle/data03
#mkdir /oracle/home
#mkdir /oracle/redo

Editing the /etc/vfstab if you want to mount vxfs file system automatically when OS startup
An example of /etc/vfstab on Solaris 10 Sparc

#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c1t0d0s1 - - swap - no -
/dev/dsk/c1t0d0s0 /dev/rdsk/c1t0d0s0 / ufs 1 no -
/dev/dsk/c1t0d0s3 /dev/rdsk/c1t0d0s3 /var ufs 1 no -
/dev/dsk/c1t0d0s2 /dev/rdsk/c1t0d0s2 /export/home ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -

##################SITE_2#####################
#/dev/vx/dsk/SITE2dg/archive /dev/vx/rdsk/SITE2dg/archive /oracle/archive vxfs - yes rw,suid,largefiles,log
#/dev/vx/dsk/SITE2dg/home /dev/vx/rdsk/SITE2dg/home /oracle/home vxfs - yes rw,suid,largefiles,log
#/dev/vx/dsk/SITE2dg/redo /dev/vx/rdsk/SITE2dg/redo /oracle/redo vxfs - yes rw,suid,largefiles,log
#/dev/vx/dsk/SITE2dg/data01 /dev/vx/rdsk/SITE2dg/data01 /oracle/data01 vxfs - yes rw,suid,largefiles,log
#/dev/vx/dsk/SITE2dg/data02 /dev/vx/rdsk/SITE2dg/data02 /oracle/data02 vxfs - yes rw,suid,largefiles,log
#/dev/vx/dsk/SITE2dg/data03 /dev/vx/rdsk/SITE2dg/data03 /oracle/data03 vxfs - yes rw,suid,largefiles,log

A Shell script to mount the vxfs file system manually
#!/usr/bin/bash
mount -F vxfs /dev/vx/dsk/SITE2dg/archive /oracle/archive
mount -F vxfs /dev/vx/dsk/SITE2dg/data01 /oracle/data01
mount -F vxfs /dev/vx/dsk/SITE2dg/data02 /oracle/data02
mount -F vxfs /dev/vx/dsk/SITE2dg/data03 /oracle/data03
mount -F vxfs /dev/vx/dsk/SITE2dg/home /oracle/home
mount -F vxfs /dev/vx/dsk/SITE2dg/redo /oracle/redo

Tags: ,