Archive for October, 2007

Some autumn pictures, 2007

S’more, at Father and Son camping (sleeping in a cabin with bunk beds) night in Morten Arboretum. It was an unusually hot day.

Guys camping night

Camp fire, where we roasted the marshmallow and made s’mores

Guys camping night

Lake Marmo, inside the arboretum, the next morning

Guys camping night

Halloween-themed Jack and the Beanstalk story at a farm

Jack and the Beanstalk

Feeding a goat at a farm. The only thing that was more annoying than the ubiquitous flies were the Bears football announcer and color commentator, blasting through the loud speakers pretty much the whole time we were there. I am sure a lot of people, especially other guys, disagreed with me on that.

Annual farm visit

Trick or Trees at Morten Arboretum. Check out the muscles!

Trick or Trees

Watching the magician perform

Trick or Trees

Our deer friend, within 10 meters of our reach, just finished drinking some water, in a forest preserver in River Forest

Deer inside the forest preserve

Comments (1)

Bring back the mirror when the principal blows up and there is no witness

Here is the script you can use to bring the mirroring database out of its “Restoring…” coma:

alter database MyDb set partner off
restore database MyDb with recovery

This is useful when you have high performance mirroring setup, your principal blows up, and there is no witness present. At this point, you will have to use the script, because you will not be able to access the mirroring database. Notice that the automatic failover does not work in this case. Applications and users need to point to the new database to resume their work.

Thanks to the folks who asked me those questions.

While I am on the topic of mirroring, the mirrored database must have the same name as the that of the principal, at least from my experience so far.

Comments (2)

2007年夏北京之行流水帐之二

到京后第三天我们去了长城。

我们到德胜门坐公共汽车去八达岭。德胜门那儿有很多小巴、中巴,有不少司机和售票员会冒称他们的车是公共汽车,我们差点上当。花了几分钟才找到正牌的大客车,物美价廉,唯一的遗憾是没有从八达岭到十三陵的直达公共汽车。我们原打算一天内通吃八达岭和十三陵,所以该计划泡汤。如雇个小车肯定可以。不过感觉背包族用公交在一天之内是可以拿下这两个地方的。

我们偷懒,是坐着这个到好汗坡的。即便如此,还是一头大汗:

Climbing up

长城上人奇多,每个烽火楼都有大量的人流堵塞。但其景观、气势还是令人叹为观止

Badaling 八达岭

因为人多拥挤,我们没走多远就下来了。我们再次偷懒,坐了缆车。

Great Wall gondola

可能是这一天(因有一段时间了,记不清细节),我们去了一个叫皇城老妈的火锅店。之所以去那儿是因为小孩娘从一本英文的北京指南上读到这儿可以选料涮锅。小孩娘吃素,牛奶、鸡蛋、奶酪除外,所以我们以为她可以在此放心地尝一尝我们火锅的味道。到了之后,才知道根本不是那回事儿,所以很扫兴。我当然尊重她的选择,但素食者在我国旅游在外吃饭是很困难的事情。这种情况在以后的旅行中多次重现,特别是和父母及哥嫂一家到南京、杭州、上海之时,以至于几次都得分头吃饭,弄得我很伤心。这也是这次故国行很有意义,但总体并不愉快的一个不可忽视的因素。文化、思维、和行为的不同是另外一个很重要的原因。这我以后可能还会提到。(儿子的口味和妈妈很类似,郁闷。)

有意思的是,我上月在丹佛开会时遇到一对瑞典夫妇。瑞典的食品口味很淡,他们的腌鱼除外。我们闲聊时,我谈到了玛丽亚吃饭时的困境,那位女士很能理解。她告诉我她的一个朋友交了一个孟加拉国的男友。孟加拉的食品据说很辛辣。该友在孟加拉也遇到了同样的窘境,尽管孟方的父母下了不小的功夫去做他们以为她会喜欢的东西。顺便说一句,到目前为止我遇到的所有瑞典人都很讲礼貌,很通情达理。虽然我肯定瑞典,和中国、美国一样,不会缺少瘪三、下三烂、讨厌鬼之流,只是表现方式可能不同,各有各的特色而已。

到离京的那一天,我们才发现王府井下面的大食代。我太后悔没能及早发现这里了。

在北京的报摊上也看到了不少以姜文做封面的杂志,到上海时更看到了姜拿枪走在山野的照片。看来姜文一定要把“汉子姜文”的形象塑造到底,或许给电影造势是更重要的原因。感觉姜文和王朔之流一样,都是很讨厌的乌合之众。整天牛逼哄哄,人五人六,自以为深沉,一点礼貌、一点涵养都没有,牛什么臭逼!倒没听说过像葛优、王蒙、崔健等很有底蕴的北京文化人用狂言、花边来存留于公众的视线之内。不过姜的《阳光灿烂的日子》我倒是很想看,但找不着。

Comments (3)

Character set and collation for simplified Chinese — MySQL

I am curious about character sets and collations, especially how they are used in databases. I got some time to play with them recently. I did some testing today on MySQL. I will do the same test on Sql Server, Oracle, and PostgreSql, time permitting. I am only dealing with simplified Chinese at this point. I may take up traditional Chinese too.

Here is my setup:

1. I created a table that stores simplified Chinese characters in different character set, along with collation used, pinyin, number of strokes, and tone value. There are 126 collations in MySQL, only 10 of which are suited for simplified Chinese.

2. I used the Chinese version of the golden rule, 己所不欲, 勿施于人, from Confucius, as my sample characters. Of those 8 characters, 欲 and 于 have the same pinyin. To make the test more interesting, I added one more character, 旗, since it has the same radical as 施.

Here are the findings:

1. I don’t see any difference between the _bin and _chinese_ci collations. In all cases, they produced identical results;

2. Big5 sorts on number of strokes. gb2312 and gbk sort on pinyin. Yes, all of this is stated in the documentation, but I want to see it for myself;

3. ucs2 and utf8 collations generate the same sort results. Interestingly, it is only through those two that characters share the same radicals are sorted next to each other, at least based on my sample. I tend to believe that should be true in general. Another interesting thing is that with ucs2 and utf8, all 独体字 are sorted together, and all 合体字 are sorted together, at least based on my sample.

4. (This is an updated item, thanks to the comment from reader Jedy) However, if you have any English letter as a beginning of the string, regardless of the string is all English letters or English mixed with Chinese characters, the _bin and _CI collation do make a difference. For _bin collations, capital English letters always come first. For _CI collations, non-capitalized English letters come first.

Below is the script I used and the results, if you are interested.

SQL query: SELECT big5_bin , PinYin , StrokeNo , Tone FROM t1 ORDER BY big5_bin

big5_bin PinYin StrokeNo

Tone
ren 2 2
yu 3 2
ji 3 3
bu 4 2
wu 4 4
suo 8 3
shi 9 1
yu 11 4
qi 14 2

SQL query: SELECT big5_chinese_ci , PinYin , StrokeNo , Tone FROM t1 ORDER BY big5_chinese_ci

big5_chinese_ci PinYin StrokeNo

Tone
ren 2 2
ji 3 3
yu 3 2
bu 4 2
wu 4 4
suo 8 3
shi 9 1
yu 11 4
qi 14 2

SQL query: SELECT gb2312_bin , PinYin , StrokeNo , Tone FROM t1 ORDER BY gb2312_bin

gb2312_bin PinYin StrokeNo

Tone
bu 4 2
ji 3 3
qi 14 2
ren 2 2
shi 9 1
suo 8 3
wu 4 4
yu 3 2
yu 11 4

SQL query: SELECT gb2312_chinese_ci , PinYin , StrokeNo , Tone FROM t1 ORDER BY gb2312_chinese_ci

gb2312_chinese_ci PinYin StrokeNo

Tone
bu 4 2
ji 3 3
qi 14 2
ren 2 2
shi 9 1
suo 8 3
wu 4 4
yu 3 2
yu 11 4

SQL query: SELECT gbk_bin , PinYin , StrokeNo , Tone FROM t1 ORDER BY gbk_bin

gbk_bin PinYin StrokeNo

Tone
bu 4 2
ji 3 3
qi 14 2
ren 2 2
shi 9 1
suo 8 3
wu 4 4
yu 3 2
yu 11 4

SQL query: SELECT gbk_chinese_ci , PinYin , StrokeNo , Tone FROM t1 ORDER BY gbk_chinese_ci

gbk_chinese_ci PinYin StrokeNo

Tone
bu 4 2
ji 3 3
qi 14 2
ren 2 2
shi 9 1
suo 8 3
wu 4 4
yu 3 2
yu 11 4

SQL query: SELECT ucs2_bin , PinYin , StrokeNo , Tone FROM t1 ORDER BY ucs2_bin

ucs2_bin PinYin StrokeNo

Tone
bu 4 2
yu 3 2
ren 2 2
wu 4 4
ji 3 3
suo 8 3
shi 9 1
qi 14 2
yu 11 4

SQL query: SELECT ucs2_unicode_ci , PinYin , StrokeNo , Tone FROM t1 ORDER BY ucs2_unicode_ci

ucs2_unicode_ci PinYin StrokeNo

Tone
bu 4 2
yu 3 2
ren 2 2
wu 4 4
ji 3 3
suo 8 3
shi 9 1
qi 14 2
yu 11 4

SQL query: SELECT utf8_bin , PinYin , StrokeNo , Tone FROM t1 ORDER BY utf8_bin

utf8_bin PinYin StrokeNo

Tone
bu 4 2
yu 3 2
ren 2 2
wu 4 4
ji 3 3
suo 8 3
shi 9 1
qi 14 2
yu 11 4

SQL query: SELECT utf8_unicode_ci , PinYin , StrokeNo , Tone FROM t1 ORDER BY utf8_unicode_ci

utf8_unicode_ci PinYin StrokeNo

Tone
bu 4 2
yu 3 2
ren 2 2
wu 4 4
ji 3 3
suo 8 3
shi 9 1
qi 14 2
yu 11 4

Comments (3)

VMWare Converter and VMWare Server fun

I am playing with VMWare Converter and VMWare Server. Both are available for free. You do need to register to get the download link and serial numbers. Fake name, address, and email will do.

VMWare Converter is pretty neat. It can suck the gut out of a physical machine, while it is running, and create a virtual machine based on it. I’ve done that and was reasonably pleased with the result. You can also supply it with a virtual machine generated using Microsoft Virtual PC (7 and higher) or Microsoft Virtual Server, and it will convert that into a VMWare virtual machine, although I didn’t try that myself. I may do that in the future.

Note, Converter can only convert Windows boxes, no Linux, no BSD, and such, as far as I can tell.

Here is a note for myself and whoever finds it useful.

1. Downloaded Converter;
2. Upon install, Converter told me that I could use VMWare Converter boot CD, if I want to convert the machine I was installing Converter on, to a virtual machine. Some reading gave me the impression that the image converted using the Converter boot CD only works under VMWare Server Enterprise, so I didn’t take that route. I could be wrong on it though. Plus, VMWare didn’t make it very easy to get the Converter CD;
3. Installation was easy enough. When it was done, I fired it up, and clicked Import Machine button. I then picked the local machine as the source machine. The program then asked for destination, I picked a folder on the local machine. I said yes to the question below.

—————————
VMware Converter Import Wizard
—————————
The selected destination is the same as the source machine. Are you sure you want to clone the machine onto itself?
—————————
Yes No
—————————
4. Somewhere along the way, I was asked if I want to give the virtual machine a name and supply sysprep files. I intended to run this virtual machine on the host on which it was based, so I gave it a different name. I think it also asked for organization name and such. Anything will do here;
5. Locating the deploy.cab files for sysprep created a little hassle. The converter wizard provided some hint via a message box, telling me to search for “sysprep Windows XP SP2″ and the like in Microsoft’s site. In my case, I searched for “sysprep Windows 2003 Enterprise R2 SP2″, which led me to this site. I downloaded and installed it, but it didn’t seem to do anything, and didn’t provide deploy.cab that I needed;
6. After checking around for a while, I decided to download the SP2 ISO image from Microsoft, and used 7zip to get deploy.cab out of the image. I then expanded deploy.cab into a folder;
7. Clicking through the wizard, it proposed 3 NIC cards for the machine. I took that, and they were all bridged Ethernet cards. Finally it started importing. On my machine of Windows 2003 Server Enterprise R2 SP2 with Sql Server 2005 and Visual Studio 2005 installed, the process took 29 minutes;
8. Afterwards, I clicked the Configure Machine button. It seemed that this process gave the virtual machine its name, and somehow hooked up with sysprep files, or not. It took less than 30 seconds to finish;
9. Downloaded and installed VMWare Server. Part of it was the web management interface, or something like that. It needs IIS, the host didn’t have it and I didn’t intend to install it, at least for now. So I skipped that component;
10. Double clicked the vmx file to open it. Click the Run button to run the machine. The virtual machine booted up, but then rebooted, at this stage I saw the sysprep thing running. A few reboots later, it became stable and was functional. It was a bit sluggish, especially inside the virtual machine, but it worked;
11. I then downloaded a LAMP virtual appliance from here. It is light, and it runs pretty well. To use the words of International Man of Mystery: Groovy, baby!

Comments (3)

Database mirroring on a clustered Sql Server instance

Mirroring is a high availability feature introduced in Sql Server 2005. Combining it with Sql Server cluster, it can buy an insurance policy for your high availability needs, if you will, in that cluster provides one layer of protection, and mirroring provides another layer.

You can create a clustered Sql Server instance, which provides protection against a server failure (motherboard, CPU, memory, etc.). Sql Server cluster in and of itself will not protect you against storage media failure. A lot of companies use SAN for their storage needs. Therefore it is possible for them to use replication technology at the hardware level (EMC’s SRDF seemed to be the most talked about) to protect the database files.

With mirroring, you can use a mirrored database on a different box to protect against storage media failure. Suppose you have a mission critical database, you can put it on a cluster. Furthermore, you can mirror that database to a different server, which can provide automatic failover.

Now suppose the principal is running on the cluster, and the mirror is running on a separate box. What happens when there is a failover from Node A to Node B on the cluster? Will the mirror take over right away, assuming automatic failover is setup? If it does, what happens when the cluster comes on line on Node B. To find that out, I conducted my experiment. Here is what I got:

1. 3 virtual machines were created on one physical box. Let’s call them Dc for Domain Controller, Node A, and Node B;
2. I set up one Sql Server cluster instance with Node A and Node B. In addition, I created one Sql Server instance on the Dc, one named instance on Node A. All instances were RTM instances, no service packs or hot fixes, because installing service packs broke things on my virtual machines. I turned on mirroring using trace flag 1400;
3. On Sql Server cluster, one database, let us call it LoveMeDo, was created. LoveMeDo was then restored on Dc. High safety automatic fail over mirroring was set up, with LoveMeDo on the cluster as the principal, the one on Dc as the mirror, and the named instance on Node A as witness. I verified that the mirroring worked properly by inserting some data into the principal, then created a database snapshot on the mirror, and saw the data inserted into the principal was in the snapshot;

Here is what I found:

1. I initiated database failover, and verified that LoveMeDo can fail over back and forth between the Sql Server cluster instance and Dc instance;

2. I initiated a failover using Cluster Administrator, now Sql Server cluster instance is running on Node B now. Dc LoveMeDo took over and became the principal. Initially it had the status of “Principal, Disconnected”. The database on the cluster, which is running on Node B at this point, became the Mirror. Shortly after, things are in sync;

3. I was able to fail the database back to the virtual instance on Node B.

I repeated the above steps a few more times, overall, I thought it worked pretty well.

Comments

Remote desktop into Windows 2003 Enterprise R2 SP2 in a home network

I have a home network, which consists of a Linksys Wireless-G broadband router. This router gives out dynamic IP addresses to laptops and workstations. I remember that when I had Windows 2003 standard installed on one workstation, I could remote into it using Terminal Service.

I’ve since installed Windows 2003 Enterprise R2 SP2, and my remote desktop stopped working. I could not even ping this workstation’s IP address from my laptop, which was really frustrating. After some research, here is what I did to make it work, feel free to make suggestions, as my way may not follow security best practices. Someday I need to take a computer networking class.

Go to services on the machine, find Windows Firewall/Internet Connection Sharing (ICS), disable it.

Now onto some fun with virtuization, MySQL, Oracle, Sql Server 2008, and full text search stuff.

Comments

2007年夏北京之行流水帐之一

这次中国行是家人的第一次,所以我们主要去了天安门、故宫、长城、和颐和园等地。94年大学毕业后我去北京工作,到95年三、四月份回山东老家办护照以便赴美留学,因此我在北京呆的时间也不长。所以我对北京并不熟悉,没去过长城,不少地方我也觉得新鲜。

到北京感觉挺亲切的,因为我毕竟是北方人,懂得这儿的说话、思考、行为方式。甚至很多俚语都是相通的。实际上对我来说,我们国家任何一个地方我都会感到亲切,因为毕竟出去太久,并且不常回来。

我到京的第一顿饭:干锅豆腐

干锅豆腐
Toufu with pork bits in spicy source. It was good, would have been better if there were more veggies. The character 干 can cause amusing translations in English. Here it literally means “dry”, pronounced with the first tone. However, the same character, when pronounced with the fourth tone, can mean “to work” or “to do it” or “to f***”. I’ve seen pictures of menus translating this character into the F word.

我们是8月10号下午到达北京。部分是时差,部分是激动,我醒得很早。在床上熬了一会,看了看电视天气预报,就起来跑步。我从东四西大道和王府井交界处,即隆福寺附近,小跑到故宫北门。大清早的,天都没亮,倒有几个人在紫禁城的护城河边钓鱼。问了一下,说是能钓到。河边也有人不知是清嗓子,还是锻炼肺部和喉管的肌肉,不时发出嗷嗷的声音。

我从景山公园南门返回,途经新文化运动纪念馆和中央美术馆。我对我国近现代史很感兴趣,所以很想去新文化运动纪念馆参观。但因时间关系没去成,有点遗憾,以后再说吧。想一想也挺有意思:十几年前在北京的我,对像新文化运动纪念馆一类的东西是不屑一顾的。那时忙着羡慕美国(虽然嘴上可能不说甚至说反话),对自己的东西、自己的历史怎能看得上眼?现已居美十数载,也到过一些地方,窃以为对美国有了一些较深的认识。回头想来,那种盲从,狂热,坐井观天的自以为是,和对近现代史和这个世界缺乏全面、真实、和客观的了解,是可笑、可悲和可怕的。

回到旅馆,洗漱早饭之后,就开始了繁忙的一天。

先到天安门。出租车把我们放到了应当是南河沿大街和长安街的地方。我们走过菖蒲河公园到天安门广场。

A nice little park on the way to Tiananmen Square
Nice little park, Changpuhe Park, leads to Tiananmen Square.

我们商量了一下要不要去毛主席纪念堂看看。因时间紧,决定不去。我和老婆闲聊,说到毛泽东的遗体也是处于日出而起(从水晶棺升起)、日落而息(落入水晶棺内)的状态,感觉有些滑稽,遂相视一笑。这里一点也没有顶礼膜拜或嘲弄毛泽东的意思。毛解放前的军事、政治、和领导才能是毋庸置疑的;但其解放后的暴戾和疯狂及对国家和人民的伤害也是有目共睹的。个人以为邓小平才是更全面、理性、坚强、人性化、有魄力、有胆识并值得敬佩的领导人,虽然他也不是十全十美。有谁是呢?这里顺便说一句,我出国十几年间,我们的纸币好像换了几套。新的纸币好像都有毛泽东的头像,我不以为然。原先的各民族人民的头像都很好,读报道建议的孔子等人的头像也不错,干嘛再放老毛?他老人家的符号已经够多的了,个人感觉弱化一下没什么坏处。

这是我和我儿子在天安门附近照的像:

天安门广场
Jet-lagged Benjamin needs a sugar high to show us a smiling face

天安门广场完了后去故宫。故宫我也想多看一看。可是人太多,天太热,又有小孩,所以便是走马观花。

The Forbidden City
Forbidden no more. Inside the emperor’s court.

The Forbidden City
Inside the Forbidden City

紫禁城后面的金鱼挺可爱的:

The Forbidden City
Gold fish towards the north end of the Forbidden City

出了故宫,我们到了景山公园。爬到不高的景山上,看故宫白塔,看北京城,很有味道。

Jingshan park
Looking at Beihai Park from the top of Jingshan Park

Jingshan park
Looking north from Jingshan Park

之后我们去了红桥市场。那儿的玩具城真不错,应有尽有,儿子顿时来了精神。我慷慨解囊,买了几个神奇宝贝(Pokemon)的任天堂电子游戏卡和几幅牌。儿子现在对神奇宝贝很入迷。

红桥市场就在天坛边上,那就是我们的下一站。天坛的祈年殿是我眼中的我国最美的古建筑之一:

Temple of Heaven
A stunningly beautiful building, 祈年殿, or Hall of Prayer for Good Harvests, inside 天坛, Temple of Heaven. So far, this is one of my most favorite, if not the favorite, old buildings of my beloved homeland.

Temple of Heaven
A building inside Temple of Heaven. I couldn’t remember its name now.

我们这一天走了不少路,总之很有收获。

Comments