Author: 芳草苑主

  • Varnish vs Nginx

    Fedora 10 release note 提及 Varnish,据说“Varnish 是一个高性能 HTTP 加速器”,又看了一些其他网站的介绍,据说比 squid 快了好几倍。squid 是什么?没听说过。但既然同是反向代理服务器,Varnish 和 Nginx 相比如何?

    我没实测,但引用别人的测试结论:

    • 根据 Connection Times 获知 Varnish 连接速度快于 Nginx,但 Nginx 处理速度快于 Varnish,等待时间几乎一致,总时间 Nginx 要快于 Varnish 15%左右。
    • 根据 HTML transferred 项获知大负载下 Varnish存在较多的丢包问题。

    我想我还是坚持走 Nginx,并走好它。

  • recordset.clone is not working

    我修改了一段以前写的 vba,用到了 recordset.clone,没想到由于 vba 本身的 bug,克隆并没有进行,recordset.clone 返回值仍然是原记录集的引用。我在返回值记录集进行了 recordset.delete,结果把我原本想保持不动的原记录集里的记录给删了。

    那个恨啊!实在没想到 recordset.clone 只引用不克隆,害我为恢复原记录折腾了很久。我没兴趣深究原因,就当是 vba bug,就算是我调用参数配置不当,recordset.clone 克隆不成功也不能随随便便返回一个值而不抛出错误。

    既然 recordset.clone 不能用,找了一个前辈 Robert Gelb 写的函数来做真正的克隆。

    Public Function Clone(ByVal oRs As ADODB.Recordset, _
        Optional ByVal LockType As ADODB.LockTypeEnum = adLockUnspecified) As ADODB.Recordset
    
        Dim oStream As ADODB.Stream
        Dim oRsClone As ADODB.Recordset
    
        'save the recordset to the stream object
        Set oStream = New ADODB.Stream
        oRs.Save oStream
    
        'and now open the stream object into a new recordset
        Set oRsClone = New ADODB.Recordset
        oRsClone.Open oStream, , , LockType
    
        'return the cloned recordset
        Set Clone = oRsClone
    
        'release the reference
        Set oRsClone = Nothing
    End Function
    
  • Goodbye, Windows

    在个人桌面应用领域,我也早就想跟 Windows 说 byebye,但一直懒于重装系统。

    最近换了台 64位的服务器,虽然硬件指标跟原来的比较,除了 32位升级到64位,其他方面并未有太多提升,但性能却强劲不少。既然服务器的性能能有这么大的提升,为什么不把我的桌面也提升一下?一直埋没了64位的 CPU 两年多,突然很想见识一下它在 64位操作系统下的表现。

    于是下载了 Fedora x86_64,擦除了厂商的出厂分区,一键恢复 Windows 也没了,彻底投入 Linux 怀抱。

  • Yum update php to 5.2.x on CentOS

    The current php version with CentOS is 5.1.6. Even epel repository’s php is 5.1.6. I am disappointed with epel slow up-to-date, but I found three 3rd party repositories to update php. Installation of these repositories are slightly diffferent.

    • remi repo has php 5.2.9. To install, just run

      rpm -Uvh http://rpms.famillecollet.com/enterprise/5/remi/x86_64/remi-release-5-7.el5.remi.noarch.rpm

    • atomic repo has php 5.2.9. To install, download this script and run it

      wget http://www.atomicorp.com/installers/atomic.sh

    • james’ utterramblings repo has php 5.2.6. To install, import GPG key first

      rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

      create a repo file manually with the following content

      [utterramblings]
      name=Jason's Utter Ramblings Repo
      baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
      enabled=1
      gpgcheck=1
      gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

  • Install Fedora 10 on a machine with Intel 845 chipset

    前面讲过,Fedora 是不太注重兼容性的,碰上杂七杂八问题的概率就高。我在 Dell Dimension 2400 上安装 Fedora 10 总是进行不下去,换一台机子也是如此,具体的症状是在 Live User login 界面时花屏、黑屏、或干脆死机。我猜是显卡驱动的原因,Google 了几下基本证实我的判断,问题集中在使用 Intel 845 chipset 的机型上。当年 Intel 845 的畅销如今使得面临这个问题的用户还不少。(但是 Fedora 为什么不解决一下这个问题?)

    原因定位得很快,对策就是让 Fedora Live CD 启动时不加载显卡驱动,或按特殊的参数加载显卡驱动。可是,具体怎么做?我又 Google 了好久,一开始找到的方法最后发现在 Fedora 10 上已经不适用了,这些过时的方法浪费我好多时间。我把我走过的弯路也写出来,希望后来者少走弯路。

    弯路一:输入启动参数 vmlinux initrd=initrd.img text,试图以文本方式安装,可 kernel 已经不叫 vmlinux,改称 vmlinux0,initrd.img 也不存在,改名 initrd0.img,但就算你把名称弄对了,也别想进入文本模式。

    弯路二:追加启动参数 linux xdriver=vesa resolution=1024×768 (我还试过 linux xdriver=vesa resolution=1024*768),试图加载 vesa 通用显卡驱动,强制分辨率。Fedora 10 根本不理这一套。

    真正能在 Intel 845 chipset 机型上成功安装 Fedora 10 的办法在 Fedora forum 上有提及,我这里总结一下:

  • 1and1 support is not professional

    I am quite happy with Godaddy’s product and service. However, virutalisation time is coming and my current dedicated server is not fast enough. Instead of going back to Godaddy for a VPS, I choose 1&1 as my new supplier.

    1&1 offer a slightly better price than Godaddy, but the cost saving is not the incentive of my switching supplier. I trust Godaddy better than 1&1. I think many people feel the same, which makes Godaddy has too many customers. It in turn overloads Godaddy’s servers. (Not efficient and responsive Godaddy’s servers forced me to learn a lot about CLI, which is good for me.)

    My reason of being a 1&1 sounds odd. Anyway, I am now a 1&1 customer. But they disappointed me on the first day after purchase.

    Before my purchase, I called 1&1 support asking how to order additional IPs because their standard checkout does not have this option. I was told I could order additional IPs after logging into my 1&1 account management (of course I have to purchase and get account open first).

    When I got account open, I could not find a link to order additional IPs. So the first support ticket to 1&1 support is “how can I order additional IPs”. Then the reply is “no, 1 VPS can only have 1 IP”!

    I have to write to them again to get IPs.

    The good thing is the IP coming with 1&1 VPS is UK based. I prefer UK IP to US IP for GEO SEO reasons. Before my purchase, I asked 1&1 support “will I get a UK IP” and was told “no, because all VPS are located in America”. So, why I get a UK IP eventually?

  • Config CentOS to use the latest software

    1and1 VPS OS 可选清单里没有 Fedora,不得不说是个遗憾。当然 CentOS 也不错,可是以前都没接触,使用 CentOS 会有很长的学习过程,但没办法,只能装个 CentOS 用用看。

    以前我调查过,CentOS 讲究兼容性,Fedora 追求技术领先。CentOS 安装真得比当初装 Fedora 要容易(Fedora 从6开始到10,我没有一次是一次启动就安装成功的),今天装CentOS 5很顺利(CentOS 兼容性真的那么好?还是我从 Fedora 学来的经验丰富了?)

    装完 CentOS,我就面临一个问题:不能 yum install nginx;yum install php 得来的版本也只是 5.1.6。这个简单的比较才觉得 Fedora 的好。我无法想象我还要下载编译 nginx(那一套我还不熟,怕搞砸了)。不过,Extra Packages for Enterprise Linux (EPEL) 已经做好了一个 repository,只要添加这个 repository,

    sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

    然后就可以用 yum install nginx。

    但是,yum install php 得来的版本只能是 5.1.6,目前还没找到好办法。

  • 一语惊醒梦中人

    由于某种原因,我删掉了 /usr/bin/php, /etc/php.ini 等文件,我指望 yum reinstall php 能把这些文件重新装回去。但是 yum install / remove / reinstall 交替使用了 n 次,还是没见这些文件。

    于是我又在想,可能 Fedora 把我以前的安装信息保存在某个地方,毕竟直接去删 /usr/bin/php, /etc/php.ini 等文件不是卸载 package 的正当做法,所以再次用 yum 安装时,它不会把这些文件送回来。怎么让 Fedora 认为我是要象第一次安装 php 那样把这些文件都给装上去呢?我想了好久不得要领,只好去 Fedora forum 提问,由于我的提问也没切中要害,一开始得到的回答也不得要领。

    直到突然一个好心人告诉我,/usr/bin/php 是在 php-cli package 里,/etc/php.ini 是在 php-common package 里。一语惊醒梦中人——怎么我总以为这些文件是由一个 php 全包了呢?

  • Session save path should be writable

    由于我系统里的 php session save path 是由当初 apache 创建的,改用 nginx 后就变成不可写了。但是,症状并不直观,php 照样能运行,phpMyAdmin 也能 login,还能查看各库各表的数据,但就是不能更新、删除,也无法 logout。无法 logout phpMyAdmin 的具体症状也不是其他人描述的那样(logout 时提示输入用户名和密码),就是点了没效果,仍在管理界面(还有人说启用 http basic auth login 的话就是无法 logout 的,只能关闭浏览器才 logout,这纯属无稽之谈)。

    我一直认为是 phpMyAdmin 或 mysql 设置出问题的,根本没往 php session save path 是否可写这方面想,我想当然地以为如果 php session save path 不可写,在 php 里启用 session 就会出错,别想进入 phpMyAdmin。

  • Reboot is still the best remedy in Linux

    Long time ago, I read an article about moving from Windows to Linux, the top differences a system administrator should keep in mind. I still remember one of the difference is reboot in Linux does not cure the problem as it does for Windows in 99% occasions.

    However, today I tried to fix a problem after I manually compiled php 5.2.9 (phpMyAdmin stop working, server response 500 error). I lack of knowledge of configure, make install, so I decided to remove php 5.2.9 and reverse to php 5.2.6 came with Fedora. I like yum install. Yum make my life so easy and it can also install packages perfect for me.

    php 5.2.9 executables was installed to /usr/local/bin (as php’s default), but php 5.2.6 was installed to /usr/bin (as fedora yum default). After I yum reinstalled php 5.2.6, I found

    If I typed “php-cgi -v”, Fedora could find php-cgi in /usr/bin
    If I typed “php -v”, Fedora still looked for php in /usr/local/bin

    I did not know why Fedora behave so strangely. After hours trying to correct Fedora mis-behavior without success, I reboot Fedora hopelessly. Then what? Fedora now is willing to load php executable in /usr/bin.