Category: 小小草

IT 技术领域学海无涯。其实任何领域都学海无涯,无非 IT 发展太快了,让我有更多嘘唏。希望我掌握的技术有如小小草,虽然渺小,却有旺盛的生命力。

  • vnc vs vino

    我刚刚弄明白,Fedora 有两种远程桌面:VNC 和 Vino,软件包的名称分别是:

    • 服务器端:vnc-server & vino
    • 客户端:vnc & vinagre

    有关 VNC 的介绍很多,以致把 Vino 都湮没了。Vino 随着 GNOME 而来,菜单项的名称就叫 Remote Desktop。我找了一会,没找到 Vino 的配置文件是哪个。如果只有图形界面,我反而会觉得不方便。而且 Vino 使用 5901 端口,我也没找到什么方法修改。

    启用 Vino 后,/etc/sysconfig/vncservers 里就无法使用 Display 1 了,5901 端口被用掉了嘛。这么启动 vncserver 会报错,“A VNC server is already running as :1”。

    VNC 和 Vino 有两大不同。

    1. VNC 进入的虚拟桌面,Vino 进入的是桌面 Session(不知道这样表达妥不妥当?)
    2. VNC 必须设置 password (by running vncpasswd),Vino 则可以不设密码。
  • Easiest way to install Flash Player in Fedora

    Fedora 发行时不带 Flash Player,因为 Fedora 说 Flash is not free。我没去仔细研究这句话的意思,大概是指生成 Flash 的软件不免费吧。我也不喜欢 Flash,但是有那么多的资源得用 Flash Player。虽然 Fedora 推荐了两款 Open Source Flash Player,但播放时还是有七七八八的问题。除非大家都不用 Adobe Flash 制作 Flash,否则我还是离不开 Adobe Flash Player。

    因此,面对现实,怎么在 Fedora Firefox 下安装 Fedora 最简单?今天发现一法,一分钟内搞掂,笔记如下:

    1. 从 http://labs.adobe.com/downloads/flashplayer10.html 下载一个压缩包。
    2. 解压其中的 so 文件 放到 /usr/lib64/mozilla/plugins
    3. 在终端中运行 mozilla-plugin-config -i -g -v
  • Fedora LiveCD installation is not perfect

    Fedora 各版本都制作了 LiveCD, installation DVD, installation CD 等形式方便用户下载。刚接触 Fedora 时,我很难决定该选哪个来下载。既然 Fedora 把 LiveCD 放在下载首页,我就下载来刻成 CD。我用这张 CD 装了好几台机器,主要是用作文件服务器或 local dns 服务器或后备 http 服务器,都没有发现大的问题。在 intel 845 芯片安装过程中遇到困难,但也被我克服了。

    直到最近我用这张 CD 安装了我的 desktop,用了几天,日常使用没有什么问题,但虚拟机总是启动不了。VMWare 的虚拟客户端都是启动到 95% 时报错,Fedora 自带的 xen 或 qemu 也总是连接不上。我查来查去查不出毛病,最后一个指令 remove kernel-xen 就让 Fedora 彻底瘫痪(启动出现 Error 5)。

    我在尝试修复 Fedora 时查阅了很多论坛,我的最后结论是:LiveCD 不适合用来安装,虽然它可以 install to harddisk。我曾认为 LiveCD 和 installation DVD 或 CD 装出来的系统是一样的,但以我的实际情况结合其他人反映的情况(特别相似的一例是有人说用 ubuntu desktop cd 安装后 VMWare 虚拟机启动到95%时出错,改用 ubuntu server cd 安装后问题消除),我再不会用 LiveCD 来装机。

    顺便提一下,LiveCD 对初次接触 Fedora、想先评估后安装的用户确实是个不错的选择。我的系统瘫痪以后,我一时没有找到拯救硬盘文件的最佳途径,就只好用 LiveCD 在无硬盘的条件下工作了两天半,它也出色地帮我完成了两天半的任务。当然还得感谢网络化的办公环境——邮件全在服务器上,文件也在服务器上,真的很少用到本地硬盘了。只是 dns lookup 比较慢,几乎每次访问都要重新 lookup,估计 LiveCD 考虑到内存有限,不缓存 dns lookup result?我用本地另一台已启用 dnsmasq 的机器为我作 dns 代理,这样 LiveCD 访问 internet 速度就正常了。

    回过头来看 Fedora,为什么 Fedora 把 LiveCD 高高推荐在下载的首页?我觉得没有必要,除非 Fedora 对自己没有信心,才拼命拉拢用户来试用(Fedora 应该早就过了这个苦命的阶段了吧)。我没有试过用 Fedora installation DVD 去安装 intel 845 芯片的机子, 我猜 Fedora installation DVD 不会有显卡驱动的问题。现在我也理解了为什么没有 rescue mode、为什么 grub linux 命令无效,因为这些都是 LiveCD 没有的。Fedora 对 LiveCD 的下载用户警告不足,为此走了一圈弯路的用户应该不止我一个吧。

  • How slow is MyBookWorld

    以前只是觉得 MyBookWorld 慢,但也没关心究竟有多慢,今天实测了一下,单个大文件读速率 4.9 MB/s,写速率 3.8 MB/s。这么糟糕的成绩,大概得归咎于 CPU 能力太差。我测的是 MyBookWorld I 版,不知带 Raid 双硬盘配置的 MyBookWorld II 是否使用了更好的芯片,如果同种芯片,II 版不会有比 I 版更好的成绩。

  • Difference of try_files to rewrite in Nginx

    try_files 是 Nginx 自0.6.36 新增的 directive。通常对 try_files 的理解是——它是
    if (!-e $request_filename) {
    rewrite .* /index.php;
    }

    的更简洁的表达。但我发现它们之间还是略有区别,主要表现在两点:

    1. 如使用 rewrite,Nginx 要求 document_root 下必须有一个 index 文件,即使我把另一个目录别名整个 document_root,但因为 Nginx 先校验 document_root 下是否有一个 index 文件,所以得放置一个空 index 文件。try_files 则没有 index 文件校验,直接去第二、第三… document_root 找对应的文件。
    2. 如使用 try_files $uri $uri/ /index.php,index.php 不能取得 get 变量,例如在 Magento 下,对 http://mydomain/catalogname?mode=list 的访问不能起效,Nginx 交付的页面是 http://mydomain/catalogname。这时必须使用 rewrite。这或许是 try_files 的一个 bug。
  • Linux talks to Linux using Windows languages

    MyBook World Edition 基于 Linux,却是面向 Windows 用户的产品。Linux 用户怎么访问它?我一时犯傻了。

    因为我早就破解了我的 MyBook World 的根密码,所以我首先想着用 root 身份、sftp 方式去访问 MyBook World。但是 Windows 用户上载到 MyBook World 的文件所有者是 www-data, root 上载上去的文件 www-data 不可写。我无从得知 www-data 的初始密码,否则我就用 www-data 身份、sftp 方式去访问 MyBook World。如果我强行修改 www-data 初始密码,万一把 MyBook World 搞瘫痪了,一个 network drive 只能当 external drive 用就不值了。

    好长时间以后才想到,Fedora 自带 Connect to server -> Windows share 就可以 samba client 去访问 MyBook World。Samba 本来就是为 Windows 和 Linux 之间的通讯开发的,但现在两台 Linux 的机器,因为要照顾到其他 Windows 用户,所以只能用 Samba 来对话。

    不管怎么说,问题解决了。只留下一个小小的问题—— Windows 下,\\ip address or netbios name 就可以看到所有的共享文件夹,在 Fedora 的 Connect to server -> Windows share 则必须把共享文件夹作为 share 的名字输入后才能连接,如果只输入 ip address or netbios name 则出现 Cannot display location “smb://ip address or netbios name/” ,no application is registered as handling this file. 那怎么查看所有共享文件夹?

  • Finetune 1and1 dedicated server with CentOS

    Although the start with 1&1 was not pleasant, I decided to stay with 1&1 and upgraded from a VPS to a dedicated server. (sadly, this VPS performance is much better than the dedicated server I got.) Now it is time to finetune it. The server came with CentOS, which is not my favourite, but it the best OS I can choose from the list.

    The first thing to do is

    yum update

    I am using Ngnix instead of Apache, so turn off pre-installed Apache. Better to do it as the first thing, as I did not aware that httpd is running which prevented nginx from starting and wasted a lot of time to find the reason.
    service httpd stop
    chkconfig --level 235 httpd off

    CentOS depository is missing lots of packages. I add two 3rd party repositories, epel (to get Nignx) and remi (to get the newest php 5.2.9).
    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/5/remi/x86_64/remi-release-5-7.el5.remi.noarch.rpm

    Because I use try_files directive quite often in nginx conf files, but try_files starts from nginx 0.6.36, I can not use nginx 0.6.35 in epel repository. Luckly, epel-testing repository has nginx 0.6.36.
    yum install nginx --enablerepo=epel-testing

    The following commands are straight-forward.
    yum install memcached
    chkconfig --level 235 memcached on

    yum install php-pecl-apc
    yum install phpMyAdmin
    yum install spawn-fcgi

    I encounted difficulty install vim. First try is using yum install vim. It works on other CentOS I installed, aslo works with CentOS on 1&1 VPS, but just does not work on this 1&1 dedicated server. I do not know why. Nevertheless, the below listed command works.
    yum install vim-enhanced

    Because magento requires php 5.2.0 or above, but CentOS current php version is 5.1.6, it must be updated.
    yum update php --enablerepo=remi

    I saw some file conflicts from some mysql packages. To solve this problem,
    cd /var/cache/yum/remi/packages
    rpm -Uvh --force mysql<tab>

    <tab> will automatically fill in the package file name.

    mysql was up and running, but 1&1 did not tell me how to log into it. It took me a couple of hours to try different combinations of possible usernames and passwords before I gave up. Then I stopped mysqld, restarted it with
    mysqld_safe --skip-grant-tables

    Then I could go to user table in mysql database to reset root password. However, I found root as a username was not there. Instead, it is admin with all privileges.

    So, I quitted mysql, restarted it in a normal way, tried to put in admin as username and the same password as server root user, it worked!

    I changed the owner of php session directory (/var/lib/php/session) from apache to nginx, otherwise php could not start session without errors.

    I expected the server would work by now, but it did not. It took me another hour to find out it was because php.ini of 1&1 dedicated server had
    safe_mode default on

    Just turn safe_mode off, because I do not need it. Now my lovely server is fully up.

  • 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
    
  • 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