• 【台湾单车环岛计划】Day 1 – 台北取车

    刚好碰上了首都机场跑道大修,起飞延误了一个小时,大概下午5点多到达桃园机场。桃园捷运在我来的一个月前刚开通,40分钟到达台北车站,160新台币。在台北车站提着行李走了差不多一公里的换乘通道,才坐上了台北捷运。移动WIFI好像不太好使,基本没信号,Google地图差不多路线,心急。回过神来,坐过站了…

    在松山站下了捷运,打开腾讯地图和GPS,不禁问自己:我在哪?我从哪里来?我要去哪里? 目测定位信息中加入了我国特色的“偏移”,地图上的定位与实际有不少出入。只好用最原始的方法按着门牌号找。

    弄到7点多,在饶河街夜市附近找到了“佳游单车”。耗费了2个多小时,老板教会了我修车技能(主要是应对爆胎),出来10点多了。

    我预定了板桥(新北市)附近的胶囊旅馆,有个15km的距离,感觉这么晚骑行不太稳妥。后来在老板的指导下,带着自行车坐上了捷运。(老板友情提示,台湾人民口中的“直走右转”跟北京人民的“直走右转”是有区别的:北京是走1公里,台湾是走30米……我是同意的。)

    带自行车上捷运要在人工窗口买票,划一价80新台币,基本上除了中转站都能带自行车上下。只能在最前或者最后的一节车厢乘车,并且全程都需要扶着车。
    台北捷运-自行车

    来到府中站,差不多10点了。地图的问题还没解决,只好凭着仅有的方向感,看着门牌号找到旅馆。在一个看着熟悉的地方,大概是2年前跟Becky买芭乐的地方,看到了这个旅馆。

    重启了一下手机,Google地图突然好使了。

    早点休息,明天正式出发!

  • 【台湾单车环岛计划】行前准备

    大概在高中或是大学的时候,被人种下了“台湾骑行环岛”的草。一直想去,又因为各种原因没去成。前两年,去了趟台北,发现台湾太棒了。找个时间环个岛吧!

    决定时间

    台湾环岛快的话大概需要9天,如果算上中途停留和恶劣天气,最好能有12天时间。台湾的气候跟广东差不多,12~2月算是冬季,会有点冷,而5月到9月是夏季,非常热还经常有台风。综合降水量来看,2/3/4月是降水较小(4月平均降水6天左右),温度不算太高的时候。

    台湾气候-温度

    台湾温度-降水

    (资料来源: http://www.cwb.gov.tw/V7/climate/climate_info/statistics/statistics_1_2.html)

    4月2/3/4日是大陆的清明假期,在假期后请8天年假连上周末能拼出15天假期。嗯,所以环岛计划的时间就定在 4.2 ~ 4.15 了。
    (更多…)

  • 感受南半球的蓝天 – 悉尼吃喝睡逛7日游

    特价机票

    在9月份的某个晚上,看到了亚航长途(AirAsiaX)出现了特价机票,北京往返悉尼含税1485元,周六去周日回,果断出手。

    亚航是廉价航空,托运行李要另外收费(全程约800元),餐食要付费购买(26元一份),且座位相对拥挤。同期海南航空含税往返2300元左右,如果需要托运行李,选择海航性价比会更高。

    Day 0 – 吉隆坡 (黑风洞/国家博物馆/双子塔)

    周五晚上下班看完电影直奔T2,亚航的值机柜台永远是排满了人。航班凌晨2点30分起飞,早上8点30分抵达吉隆坡KLIA2. KLIA2 连接着一个商场,餐饮的价格与市区差不多。

    马来西亚的M记性价比仅次于香港,有一些马来特有的产品(通常是一些鸡肉汉堡)。
    KLIA2-麦当劳
    (更多…)

  • 简单的 xinetd 示例程序

    通过 xinetd 的管理,可以按需启动某些“用完即走”的网络服务。实际上,xinetd 相当于网络层面的 wrapper, 应用程序只需要处理标准输入输出,网络层面的事情由 xinetd 代为处理即可。

    以下是在 RHEL7 中实现的一个简单示例程序。
    (更多…)

  • Python attributes 笔记

    上个月在 Python Meetup 上有人分享了 Python attributes 的一些玩法,记录一下。
    (更多…)

  • 为什么不同的 LC_ALL 设定会导致 sort 命令输出顺序不一样?

    在使用 sort 命令对文本进行排序时,如果语言环境不同,得到的排序结果也会不同。

    [root@rhel674 tmp]# export LC_ALL=C; sort test.txt 
    1234
    AAA
    BBB
    aaa
    aab
    
    [root@rhel674 tmp]# export LC_ALL=en_US; sort test.txt 
    1234
    aaa
    AAA
    aab
    BBB
    

    如果用 C (POSIX) 作为语言环境,得到的排序结果是按照字符对应的 ascii 码大小来排序的。而如果用 en_US 等语言环境,得到的排序结果会不同(从上可以看到,先按字母顺序排序,字母都一样的时候才区分大小写)。
    (更多…)

  • 锁定 C-state 能提高 CPU 性能吗?

    tl;dr

    不能。

    背景

    用户发现,尽管设置了 ‘performance’ 作为 cpuspeed 的 governor (/etc/sysconfig/cpuspeed), 但是 CPU 并不是一直处于最高频率运行。用户希望保持最高频率运行,不考虑节能,要发挥出 CPU 的最高性能。
    (更多…)

  • 比较 kdump makedumpfile 中的压缩方法

    背景

    在出现 Kernel Panic 的时候,kdump 可以帮助我们收集 vmcore, 以便后续对故障原因进行分析。然而,近些年的服务器动辄上百G的内存,转储一个 vmcore 所耗费的时间显得相对较长,增加了 down time.

    在 RHEL7/CentOS7 中, kdump 提供了三种压缩方法(zlib, lzo, snappy),我们可以选择一种较快速的压缩方法来节省收集 vmcore 的时间。

    压缩方法可以在 kdump.conf 中的 makedumpfile 一行里设置。
    [cc lang=”text”]
    # man makedumpfile

    -c,-l,-p
    Compress dump data by each page using zlib for -c option, lzo for -l option or snappy for -p option. (-l option needs USELZO=on and -p option needs USESNAPPY=on when building)
    A user cannot specify this option with -E option, because the ELF format does not support compressed data.
    Example:
    # makedumpfile -c -d 31 -x vmlinux /proc/vmcore dumpfile
    [/cc]

    zlib 是 gzip 所使用的压缩方法,通常而言它比 lzo 和 snappy 慢,而压缩比稍微高于 lzo 和 snappy.
    (更多…)

  • How to request continuous physical memory in Linux?

    Background

    A customer noticed an issue. His system has 100+GB free memory (which is pure free memory, not buffer/cache), but system starts reclaiming pages from buffer/cache and swapping out pages at some point.

    From system log, we can see things like below at the reclaiming moment.
    [cc lang=”text”]
    May 2 10:03:56 rhel68-kmalloc kernel: insmod: page allocation failure. order:10, mode:0xd0
    May 2 10:03:56 rhel68-kmalloc kernel: Pid: 22319, comm: insmod Not tainted 2.6.32-642.el6.x86_64 #1
    May 2 10:03:56 rhel68-kmalloc kernel: Call Trace:
    May 2 10:03:56 rhel68-kmalloc kernel: [] ? __alloc_pages_nodemask+0x7dc/0x950
    May 2 10:03:56 rhel68-kmalloc kernel: [] ? kmem_getpages+0x62/0x170
    May 2 10:03:56 rhel68-kmalloc kernel: [] ? fallback_alloc+0x1ba/0x270
    May 2 10:03:56 rhel68-kmalloc kernel: [] ? cache_grow+0x2cf/0x320
    May 2 10:03:56 rhel68-kmalloc kernel: [] ? ____cache_alloc_node+0x99/0x160
    [/cc]
    (更多…)

  • Why do services like sendmail/httpd still query outdated DNS servers after resolv.conf is changed?

    Question

    One of my colleague raised a question: After changing resolv.conf, sendmail still query the old resolver, why?

    Steps:

    1. Set 192.168.122.65 as nameserver in resolv.conf, start sendmail service, send a mail to root@hat.com, and take a tcpdump. We can see there’s a query asking 192.168.122.65 for MX record of hat.com .

    2. Change nameserver from 192.168.122.65 to 192.168.122.72 in resolv.conf, send a mail to root@hat.com and take a tcpdump again. This time we expect a query to 192.168.122.72 (new), but the actual query is to 192.168.122.65 (old).

    3. Restart sendmail service, send a mail to root@hat.com, this time we can see a query to 192.168.122.72 (new) as expected.

    When we were thinking about what’s going wrong with sendmail, another colleague joined in discussion, and she mentioned that httpd and some other long-running services also have this behavior.

    Since sendmail is not the only case, I think we should have a check on glibc.

    (更多…)