FreeNAS , Openfiler 免費的 file server

今天知道 Jack大大入手了 Synology USB Station 三合一SOHO伺服器
http://shopping.pchome.com.tw/?mod=item&func=exhibit&IT_NO=DGAK0J-A16377028&SR_NO=DGAK0J&ROWNO=5

AMD00039l

我記得有幾個免費的 file server 可以抓來用, 今天玩的心得: FreeNAS VS. Openfiler

我測試的結果 –> FreeNAS 勝!

FreeNAS 各類 server 都有了 , 甚至 BT / iTunes server  … 舊電腦可以裝這個來用了 , 他說記憶體有 128MB 就夠了.

FreeNAS
http://www.freenas.org/

ID : admin
PW : freenas

bcc96c9600258cbee2d3a4c47553b879

Openfiler
http://www.openfiler.com/

ID : openfiler
PW : password

abf5d86d9252b760a0983e897d890638

unix shell programming / sh / csh syntax

Shell script syntax

Bourne shell (sh) syntax samples

test:
[ number -lt|-le|-eq|-ne|-ge|-gt number ]
[ string = != string ]

if [ test ]
then
   commands
elif [ test ]
   commands
else
   commands
fi

for var in item1 item2 item3
do
  commands
done

while test
do
  commands
done

case expression in
  case1)         commands ;;
  case2|case3)   commands ;;
  *)             default-commands ;;
esac


# How to read an input file into shell variables:
while read variable1 variable2
do
  ...
done < $input_file

# How to redirect stdout/stderr
echo something 1>&2
echo something 2>&1

# How to throw out stdout and stderr
some_command > /dev/null 2>&1

# Shell functions:
func () {
	echo $1 $2 $3
}
func a b c


C shell (csh) syntax samples

test:
( expression ==|!=|>>|<< expression )

if ( test ) command

if ( test ) then
   commands
else if ( test ) then
   commands
else
   commands
end if

foreach var ( list list list )
  commands
end

while condition
   commands
end

# How to throw out stdout and stderr
some_command >& /dev/null

另一個

#!/bin/sh
count=0
while [ $count -lt 5 ]
do
  count=`expr $count + 1`
  echo $count
done

sysctl / Linux tunning /etc/sysctl.conf

net.ipv4.ip_local_port_range = 1024 65536
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_tw_recycle = 1
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_no_metrics_save=1
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2



取代 squid 的 HTTP 加速器 varnish

據說用 3台 varnish 可以抵 12台 squid 來用 , 有時間要來玩一下.

Varnish

http://varnish.projects.linpro.no/

 

Varnish is a state-of-the-art, high-performance HTTP accelerator. It uses the advanced features in Linux 2.6, FreeBSD 6/7 and Solaris 10 to achieve its high performance.

Some of the features include

  • A modern design
  • VCL – a very flexible configuration language
  • Load balancing with health checking of backends
  • Partial support for ESI
  • URL rewriting
  • Graceful handling of "dead" backends
  • more features

Varnish is free software and is licenced under a modified BSD licence. Please read the introduction to get started with Varnish.

用 HAProxy 作 load balancer – 窮人的 SLB ( server load balance)

這是簡單版的架構, http flow:
cacae1dfce25d17bd8225bdcd8b7b772

其實, 裝起來並沒有想像中複雜, 只是準備一個測試環境比較麻煩些罷了–> vmware 又幫了我不少忙 😛

參考他的 online document:
http://haproxy.1wt.eu/download/1.3/doc/haproxy-en.txt

及架構圖
http://haproxy.1wt.eu/download/1.3/doc/architecture.txt

略翻完這兩個文件就可以來測試了 , 首先準備三台 web server : webA 到 webC , 然後還要一台 server 當 haproxy server 這台不用跑 apache , 安裝 haproxy 很簡單, 在 gentoo 就是 emerge –av haproxy , 設定檔要自己建 (放到 /etc/ )

我的 /etc/haproxy.cnf

listen webfarm 172.30.0.235:80
monitor-uri /haproxy_status
stats uri /stats
stats auth admin:admin
mode http
balance roundrobin
cookie SERVERID insert indirect
option httpchk HEAD /index.php HTTP/1.0
server webA 172.30.0.206:80 cookie A check
server webB 172.30.0.227:80 cookie B check
server webC 172.30.0.228:80 cookie C check

第一次連上後, haproxy 如他的 menual 寫的 , 會丟一個 cookie 給 client , 作為下次要連的實體 server 的依據 , 我把那台 apache 停掉, 果然就連到別去了 , 然後 phpinfo 中值得紀錄的是:

SERVER_NAME 就是 haproxy.cfg 中寫的 listen 的 IP , 然後 , SERVER_ADDR 就是實體連到的 apache 的 IP , haproxy 會不停的丟 HTTP/1.0 的 HEAD 取得 apache 是否還活著.

在 webA-C 的 aapache access log 中若 沒特別改的話, 就是紀錄 haproxy server 的 IP address

….

好了! 實驗完成了!

結論, HAProxy 在他的官網寫說他:

“ 提供一個免費/快速的 HA / LOAD BALANCE 方案 , 可是我覺得他僅能夠說 HA / BALANCE (並沒有很徹底的偵測 server loading) , 並且在 SPF 方面也並沒有很好的解決辦法.

不過呢, 至少 HAProxy 比 DNS roundrobin 還好.

各種 LOAD BALANCE 方案 評估表

SLB

CPU用量

轉送效率

偵測連線

roundrobin DNS

最佳,直接傳給client

NO

ipvsadm

最低

YES

mod_proxy

YES

haproxy

YES

 

過了一個晚上想了想 , 即使 Citrix / Alteon / Foundry 這些 SLB hardware device 也沒有做到真正的 loading detective , 所以就一個免費又高容量的 HAProxy 來說, 算是很好的 SLB 解決方案了.

ㄎㄎ 有做過 HAProxy 實驗的都會貼這一張:

ec6601bde1fdb02e373efc74ea97e0f1