2010年7月11日

Ubuntu Enterprise Cloud, UEC

Eucalyptus Beginner’s Guide – UEC Edition

Chapter 1 – Introduction to UEC and its components


雲端運算安裝 Ubuntu Enterprise Cloud install

 

HAProxy 當 server load balancer 

硬體 Citrix / Alteon / Foundry 這些 SLB hardware device 

BalanceNG

Crossroads 

LVS 好像比較是 系統備援 (see http://www.ibm.com/developerworks/linux/library/l-linux-ha/index.html)

Virtualbox 網路的模式

source: http://www.dotblogs.com.tw/cyl1688/archive/2009/08/14/10055.aspx

VirtualBox 網路的模式,如下共5種(手冊上面寫的,但是用途為何?)

1.not attached (不使用網路卡)   
會出現網卡,但是沒有連接 

2.network address Translation(NAT)  預設值  
這是最簡單的方法連到外面的網路,這是單向,外部網路無法存取GUEST電腦(如果使用ultravnc 是否可以?), 一些限制:
  1. icmp ,ping 應該可以使用,但其它工具可能無法穩定工作
  2. UDP ,接收UDP傳播可能會不穩定
  3. 不支援GRE(pptp vpn)
  4. 無法將主機的連接埠轉向< 1024(這是保留給系統使用)
    整合在virtualbox 內的dhcp server會提供IP ,第一個卡 10.0.2.0,第二個卡10.0.3.0以此類推

3.bridged networking 橋接介面卡 
(可參見 VirtualBox 網路橋接(Bridge)模式 under Ubuntu 一文)
Guest會透過dhcp取得新內部的IP,因此會有兩個對外實體IP (使用一個設備驅動程式,過濾由實體的網卡來的資料,這個驅動程式已經完整被重寫,HOST 不再需要複雜的設定),  設定網路時要選擇bridge,並選取實體網卡  

4.internal networking    可以讓不同虛擬主機互通,好像接到同一個hub上,但是無法存取外部網路
  1. 安全:
  2. 速度:比bridged networking有效,因為它是直接傳送,不需要透過HOST作業系統的網路堆疊
    IP 要手動指定
5.僅限主機介面卡 (host-only networking) 
    這是2.2版新增的模式,不同的GUEST可以互通,也可以跟HOST互通
    可以想像混合 bridged 和 internal 網路模式,在 HOST 會建立一個軟體的網路卡, 如同虛擬機器連線到虛擬的網路, 只可以讓HOST和GUEST互通

  1. virtualbox host-only networking 要使用dhcp 不可以指定
  2. virtualbox ->檔案->偏好設定->網路->點選host-only networking 可以設定dhcp如上兩個host-only和GUEST會有相同網段的IP,就可以互通
  3. 這裏的dhcp伺服器不同於其它模式,它是獨立的,也只有在這裏才會可以關閉,並指定ip的範圍

2010年7月4日

xorg.conf

Section "Device"
Identifier "Configured Video Device"
Driver "vesa"
EndSection

Section "Monitor"
Identifier "Configured Monitor"
Vendorname "Generic LCD Display"
Modelname "LCD Panel 1024x768"
Horizsync 31.5-48.0
Vertrefresh 50-60
modeline "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -vsync -hsync
EndSection

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
Defaultdepth 24
SubSection "Display"
Depth 24
Virtual 1024 768
Modes "1024x768@60" "800x600@60"
EndSubSection
EndSection

2010年7月3日

試用 ubuntu 10.04

今天用 virtualbox 3.1.2 在 ubuntu 9.10 下試用 ubuntu 10.4 版, 結果 ubuntu 10.04 系統開啟地很慢很慢...
後來將 virtualbox 換成 3.2.6 版, 問題才解決

ubuntu 10.04 視窗風格有很大的改變, 最不適應的是放大縮小鈕改成放在左上角 ...
要更改為放在右上角的話:
  1. 在終端機啟動 gconf-editor
  2. 點選 Apps > Metacity > General > Button Layout
  3. 把字串值改成:menu:minimize,maximize,close
    (原來的值是: close,minimize,maximize:)
ubuntu 10.04 這一版的預設中文輸入法仍是 iBus + 注音輸入法, 新增倉頡 3 代後, 發現輸入法會記住你上一次所挑選的字, 總算有些進步...

ubuntu 10.04 這一版預載可安裝的 gretl 是 1.8.7
gnuplot 是 4.2.6-1
要在圖形中正常顯示中文, 請參見
http://gretl.sourceforge.net/gnuplot_for_gretl.html
測試的 gretl script
open djclose
smpl 1988/01/04 1989/12/29
gf1 <- gnuplot djclose --time-series --output=display --with-lines
gf1.show

先裝上 gretl 1.8.7 之後, 再
https://sites.google.com/site/gretlforubuntu/home/gretl-deb
下載自行編譯的 gretl 1.9.1, 但無法執行:
 /usr/local/bin/gretl_x11/: error while loading shared libraries: liblapack.so.

用 
sudo aptitude install libfftw3-dev
sudo aptitude install liblapack-dev
之後再重裝 gretl 1.9.1 即可 (比上一版 9.10 的簡單一些)


最後, 固定寛度字形預設是 monospace, 但要改成 freemono, 或 Courier 10 pitch 顯示才會對齊... 


若執行 ARIMA 模型估計時, 出現 /usr/lib/gretl-gtk2/arma.so 找不到, 則建立連結:
sudo ln -s /usr/local/lib/gretl-gtk2/ /usr/lib/gretl-gtk2/

2010年6月10日

Drupal 架站筆記-雙語言網站

用 Views 來做一個顯示「最新消息」的區塊
http://riemann.math.nccu.edu.tw/forum/viewtopic.php?f=8&t=637
Views 的選項:
  • Basic Information:  View 的名稱
  • 頁面: 要做一個 page 時要用這一個。
  • 區塊: 區塊的設定。因為我們要做的是「最新消息」的區塊, 所以選用這一項。
  • Fields: 選擇要把 Node 的什麼部份顯示出來, 例如標題 (Title)。
  • Arguments: ...。
  • 過濾器: 沒有要把所有的 Nodes 顯示出來時, 要設一些條件。
  • Exposed Filters
  • Sort Criteria
相簿 show:  Dynamic display block模組
http://chenyuyi.mis.nchu.edu.tw/drupal-6.16/node/59

待確認:
區塊 (block) 的雙語模型 要用哪一個模組?

待試用的 modules


Better Formats
不同 role 指定不同輸入格式 (是否允許 HTML)
http://drupal.org/project/better_formats



Nice Menus
下拉 css 選單
http://drupal.org/project/nice_menus

2010年5月10日

ASP 中的 codepage

放在 *.asp 的第1行:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
936代表是簡體中文,而950代表繁體中文,65001就是 UTF-8 編碼了


若你的 *.asp 是 UTF-8 編碼, 則加入以下的程式碼在第1行, 就不會有亂碼了

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

2010年4月23日

Regular Expression 語法

在很多程式中見到看起來很怪的語法, 中文稱為「正規表達式 」,例如
 
([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})
代表 yyyy-mm-dd 的日期格式, 或
 
a[0-9]*\.c
代表 a12.c,a932.c 等以 a 開頭, 以 .c 結尾, 中間只能是數字, 的所有字串
還滿聰明的一個做法
 
參見
特別要抓 unicode 中文的話, 看這裡

 
  它使用「/xxx/u」,在最後加上「u」,以這方式支援 UTF-8,
 
#!/usr/bin/php -q
$a = "def:123:這是:AB=你好!";
$pattern = 
'/123:([\x{4e00}-\x{9fff}]+):[A-B]*/u';
preg_match($pattern, 
$a,$match);
echo $match[0];
?> 
 
ASP 中使用:
例 1
Function RegExpTest(patrn, strng) 
   Dim regEx, retVal ' 建立變量。 
   Set regEx = New RegExp ' 建立正則表達式。 
   regEx.Pattern = patrn ' 設置模式。 
   regEx.IgnoreCase = False ' 設置是否區分大小寫。 
   retVal = regEx.Test(strng) ' 執行搜索測試。 
   If retVal Then 
      RegExpTest = "找到一個或多個匹配。" 
   Else 
      RegExpTest = "未找到匹配。" 
   End If 
End Function  
 
例 2
 
s1="This equation {x} + {y} = {x+y}
"
x=100
y=200
response.write "====>" & Var2Value(s1) & "
" 
function Var2Value(var_name)
   Var2Value = Txt2Value(var_name, 1)
end Function
function Txt2Value(str, level)
   dim regEx, Matches, Result
   Set regEx = new RegExp
   select case level
          case 0 regEx.Pattern = "\{([\w\(\)]+)\}" '變數名有效判斷
          case 1 regEx.Pattern = "\{([\w+\-\*/\\<>=\(\)]+)\}" '變數名及運算符號有效
          'case 2 regEx.Pattern = "\{([\w\s\(\)]+)\}" '除換行符外的所有字符有效
          case else exit function
   end select
   regEx.IgnoreCase = true
   regEx.Global = true
   Set Matches = regEx.Execute(str)
   Result = str
   'response.write Matches.Count
   For Each Match In Matches
      Result = Replace(Result, Match.Value, GetVar(Match.SubMatches(0)))
   Next
   set Matches = nothing
   set regEx = nothing
   Txt2Value = Result
end function