入手 Timex Men’s Ironman Triathlon 100-Lap FLIX System Watch 功能超強
- 100圈記憶
- 5組鬧鈴, 鬧鈴可分 weekdays/weekend/daily….
- 兩個時區
- INDIGLO® night-light , 可以不用按 button 就把背光打開
= NTD$1813
= NTD$1813
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
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
據說用 3台 varnish 可以抵 12台 squid 來用 , 有時間要來玩一下.
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
Varnish is free software and is licenced under a modified BSD licence. Please read the introduction to get started with Varnish.
這是簡單版的架構, http flow:

其實, 裝起來並沒有想像中複雜, 只是準備一個測試環境比較麻煩些罷了–> 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 實驗的都會貼這一張:
雖然我已經會了 , 但是看到這個Vi-vim Cheat Sheet 還是蠻好奇的把它收錄下來
完整的請看原網站 , from : http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
[youtube]http://www.youtube.com/watch?v=udivD0kzWUI[/youtube] (more…)
FILE* fp = fopen(path, "r");
if (fp) {
// file exists
fclose(fp);
} else {
// file doesn't exist
}
起因是不想要動到舊的程式碼 , 若用 mysql-proxy 把讀寫分離出來 , 那舊的程式連接資料庫的 connect 段就不用改了 , 而且 mysql-proxy 官網還寫了不少好處:
- load balancing
- failover
- query analysis
- query filtering and modification
and many more.
好早就想要試看看了! 首先要先建制一個 master/slave 的 mysql 架構 – 設定 mysql 成 master / slave 架構
在 gentoo 中 , 用 emerge –av mysql-proxy 把 目前版本 0.61 裝進來 , 然後 /etc/conf.d/mysql-proxy 的設定如下
# /etc/conf.d/mysql-proxy: config file for /etc/init.d/mysql-proxy # location auf pidfile PIDFILE="/var/run/mysql-proxy.pid" # general options for mysql-proxy OPTS="--proxy-lua-script=/root/tutorial-keepalive.lua --proxy-backend-addresses=172.30.0.182:3306 --proxy-read-only-backend-addresses=172.30.0.183:3306 " #OPTS="/root/mysql-proxy.lua" # if you want mysql-proxy to depend on mysql, enable this: #RC_NEED="mysql"
這邊的 tutorial-keepalive.lua 可以到 http://svn.mysql.com/svnpublic/mysql-proxy/trunk/examples/tutorial-keepalive.lua下載
參考 http://jan.kneschke.de/2007/8/1/mysql-proxy-learns-r-w-splitting
O’Reilly 有一些 lua 的 sample : http://www.oreillynet.com/pub/a/databases/2007/07/12/getting-started-with-mysql-proxy.html?page=4
MySQL 官網的 FAQ : http://dev.mysql.com/doc/refman/5.0/en/mysql-proxy-faq.html
http://dev.mysql.com/doc/refman/5.0/en/mysql-proxy.html
在 January 30th, 2009 , MySQL Proxy 有新版了 from 0.6.1 to 0.7.0
http://jan.kneschke.de/2009/1/30/mysql-proxy-from-0-6-1-to-0-7-0
另外 Lua 是一種簡單/快速的 script language , mysql proxy snippets
最後看到有個問題 : “SPoF” , Sigle Point of Failure , 我看如果要用 mysql proxy 還是有得搞了 … 暫時打住吧!
www.monster.com.tw , © Copyright 2008