Archive for April, 2007

Thoughts on server

Tuesday, April 3rd, 2007

真是個大問題,這兩天有在用心的思考該不該更換目前的 Hosting Plan

  • Colocation: 好一點的主機實在太貴了,所以短期內大概不大可能去買台 1U 主機然後丟 Datacenter 吧
  • Dedicated: 實在找不到比現在這個 1&1 的 Dedicated Root Server 更好的 Plan 了,雖然硬體實在真的很爛
  • VPS: 所有看到(付得起) VPS 的 disk space 實在小的無法接受阿 Orz
  • Shared Hosting: 頻寬大、空間大、設備好,看起來實在是聰明的選擇,但是不能惡搞主機

所以我覺得我大概是需要把需求分開來才對:

  1. 空間
  2. 流量
  3. 效能
  4. 控制

想一想,其實 1, 2, 3 只要找個好的 Shared Hosting Plan (像是胸毛男現在在用的 HostMonster?) 就可以輕鬆 cover,可能得仔細的讀 review 不要小心找到一間容易被丟到操的很兇的 server 上就好了。

要達到 4 隨心所欲的控制的話,還是得至少有 VPS 才可以。但是想一想,需要隨心所欲控制的部分,需要用到那麼多的功間、流量、和效能嗎?好像不用耶,就頂多拿來編些程式、跑些不該跑的東西、抓些不該抓的東西、丟給一小圈的人下載 (以上純為假設) 之類的事情。

總和以上,看起來取得兩個 Plan 會比較划得來。反正如果 shared hosting 上有 shell access 的話,也可以直接丟個 cron 之類的把 VPS 上的東西抓到 shared hosting 上然後再丟出來,頻寬嘛 XD

Server down past 3 days

Monday, April 2nd, 2007

I was working on something that’s probably not important because I don’t remember what I was working on. But anyway, 3/31/2007 morning, the server is suddenly offline, and it leads to my letter to 1&1:

===========================

Hi,
My customer id is [EDIT] and the question is regarding to the Root Server
with contract ID [EDIT].

My server became unreachable this morning (3/31). Since this happens once in
a while so I just go ahead and restart the server via the 1&1 Admin Panel.
The server did not come back online, so I tried logging in via Serial
Console. Server looks normal, nothing changed. However, it looks like the
DHCP server on your side is down for unknown reason. I've attach some
relevant command output below:

[root@u15185402 ~]# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:129 errors:0 dropped:0 overruns:0 frame:0
          TX packets:129 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:22508 (21.9 KiB)  TX bytes:22508 (21.9 KiB)

[root@u15185402 ~]# dmesg | grep eth0
eth0: VIA Rhine II at 0x1e000, [EDIT], IRQ 15.
eth0: MII PHY found at address 1, status 0x7849 advertising 05e1 Link 0000.
eth0: link down

[root@u15185402 ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use
Iface
169.254.0.0     *               255.255.0.0     U     0      0        0 lo

[root@u15185402 ~]# dhclient eth0
Internet Systems Consortium DHCP Client V3.0.2-RedHat
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP

Listening on LPF/eth0/[EDIT]
Sending on   LPF/eth0/[EDIT]
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 16
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 16
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 10
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

[root@u15185402 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr [EDIT]
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:15 Base address:0xe000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:136 errors:0 dropped:0 overruns:0 frame:0
          TX packets:136 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:22909 (22.3 KiB)  TX bytes:22909 (22.3 KiB)

[root@u15185402 ~]# dmesg | grep eth0
eth0: VIA Rhine II at 0x1e000, [EDIT], IRQ 15.
eth0: MII PHY found at address 1, status 0x7849 advertising 05e1 Link 0000.
eth0: link down
eth0: link down

I tried calling the support number 1-877-206-4255 but was disconnected for
unknown reason before I reach a customer representative. Please help.

Thanks,

Peter

After two days no response, I called them again. Being put on hold for about 30 minutes, I was finally able to talk to a customer service. The rep told me my server is sending packets with fake MAC address and therefore my account is suspended. WOW. He was not able to do anything but elevate this case and put a high priority tag so the server department will be able to look into it later. Next morning, I suddenly saw the server back online again. Immediately after that I receive this letter:

===========================

Dear Peter Chang, (Customer ID: [EDIT])

Thank you for contacting us. Your server has been disabled at the switch
because it was generating traffic with false MAC address header
information.  This is most often due to a virtual machine running with
an independent interface. To use virtual machines on your server, you
must use NAT so that the virtual machine uses the host interface. I have
reenable the server back onto the switch and you r server is now
pinging.

If you have any further questions please do not hesitate to contact us.

--
Sincerely,
Chad Hodgdon
Technical Support
1&1 Internet

WOW. Virtual Machines? It can’t even run smoothly as 1 machine. How can my computer generate traffic with false MAC header? I really wonder how this happens. Also I don’t get any letter or any call telling me the account is suspended, is that normal? Anyway, it’s back, and I’m happy for now. Colopronto is looking very attractive though.

Ajax 筆記

Monday, April 2nd, 2007

過去幾天一直在摸 AJAX 的相關東西,而跟以前不同的是,這次有下去實作。實作的內容是寶貝哈泥的作業,我想應該是不會拿去交啦,有點類似國小在教小畫家但是拿 Photoshop 的作品去交件。趁還記得把一些心得記下來:

Prototype.js:

  • $( ) 是超級好朋友,省了好多字
  • $( ) 不能用在 radiobutton 上
  • 超省時 XMLHttpRequest Syntax:
    ob = new Ajax.Request(
        URL,
        {
            method: 'get/post',
            parameters:'a=1&b=2',
            onComplete:funcOb
        });
  • onComplete 或者其他 onXxxxx 的 funcOb 要用 var funcOb = function(param) { … } 下去定義
  • 除了丟 funcOb 以外,也可以直接丟 anonymous function 像是 onComplete: function(param) { … } 這樣
  • $( ).visible() 和 $( ).hide() + $( ).show() 真是省了好多 browser hack 的工作

Scriptaculous.js:

  • Effect.toggle(’ID’) 是美觀大方又實用到爆的開關
  • Effect.Fade(’ID1′, {queue:’end’}) 然後 Effect.Fade(’ID2′, {queue:’end’}) 會先 Fade 完 ID1 後才會 Fade ID2

XML:

  • <?xml version="1.0" encoding="big5" standalone="yes" ?>

    順序很重要,嗯哼,亂掉就不給 parse \囧/

  • IE 真的很討厭,只要 XML 有一咪咪問題 responseXML 就變成空的,所以最好用 Microsoft XML Notepad 2007 之類的先 validate
  • PHP 在丟 XML 時候記得要丟 header,像是
    header('Content-Type:text/xml;charset=Big5')

DOM:

  • Mozilla DOM 是個好地方,多看多嘗試就會了
  • element.value 才是取得 input 物件裡面的值,element.innerHTML 是拿來塞東西到 <div id=”mydiv”></div> 之間的

這些是實作的不同版本:

  • ajaxbmi1: 超級基本的版本,直接用 responseText 來丟進 innerHTML
  • ajaxbmi2: 開始會丟 XML 來生成 responseXML 了
  • ajaxbmi3: 開始使用 prototype/scriptaculous 來簡化許多東西
    這個版本有個用 behavior 生的 syntax highlighter (star-light),而原因是因為林餅幹家的 lighty 沒設好 phps 的輸出所以一時起興掛上去的
All Rights Reserved Copyright © 2008 Design by StyleShout and Clazh