Apache in Slax

0

源起

apache 調試需要不同參數,所以建立這個 mo 順便測看看不同編譯的效能差異。

apache.mo

老步驟。

  1. cd /mnt/hda1
  2. wget httpd-2.2.3.tar.bz2
  3. tar jxvf httpd-2.2.3.tar.bz2
  4. cd httpd-2.2.3
  5. ./configure
  6. make
  7. checkinstall
  8. mv httpd-2.2.3-i386.tgz ../
  9. cd ..
  10. mkdir /mnt/hda1/work/apache
  11. installpkg -root /mnt/hda1/work/apache httpd-2.2.3-i386.tgz
  12. cd /mnt/hda1/work
  13. dir2mo apache apache-2.2.3.mo

test apache-2.2.3.mo

  1. reboot first
  2. uselivemod apache-2.2.3.mo
  3. /usr/local/apache2/bin/apachectl -k start
  4. netstat -at

結果要看大一點的檔案會發現開不起來,看 access log 發現都是 HTTP STATUS 206,沒有資料傳出,google 發現這篇有提到這個 sendfile syscall 的問題。同時查到 Unionfs 尚未支援 sendfile 的類似訊息。

根據建議,將 httpd.conf 做點修正,EnableSendfile 改 off 就可以跑起來,進一步參閱 EnableSendfile Directive

但是如果需要測試 sendfile 的話,就需要裝在別的檔案系統,例如之前裝在 tmpfs 的做法。

要先改 httpd.conf 讓它使用 EnableSendfile,同時 DocumentRoot 指到 /mnt/hda1/tmpfs/apache2/htdocs,重新開機後,另外加上可以填滿 htdocs 的東西。

  1. mount tmpfs /mnt/hda1/tmpfs -t tmpfs -o size=64m
  2. mkdir -p /mnt/hda1/tmpfs/apache2/htdocs
  3. cp something to htdocs
  4. /usr/local/apache2/bin/apachectl -k start

雙機作業

這次測希望用兩台機器來測,而不是單機測,所以直接把 slax.vmx 那個檔案夾複製一個,就生出另一台 slax2 機器可以用,還包含一顆一模一樣的硬碟(vmdk)可用。

但是用之前要先改一下網卡的硬體位址,免得衝到,所以打開 slax2 的 slax.vmx,將其中一行 ethernet0.generatedAddress 後面隨便加個一就可以了。

一開機會希望你建立一個新的識別,我是直接建立,不過開機後要立刻按 F2 去改 BIOS,讓 CDROM 先開機。開機完只要互相 ping 一下,確定網路已通就可以開始雙機暴走測試。

benchmark

TODO 未完待續。

httpmark.mo

0

有些事要先知道

部落格的文件發布時間不一致,有時寫的時候並沒有考慮到後來的發展,所以文件往往缺乏一貫與完整性,為避免看的人一頭霧水,於是在文件前稍微介紹一下這個練習的來龍去脈。

  1. 如何使用 vmplayer 玩 ISO 檔請參考 dsl in vmplayer
  2. slax 在 vmplayer 上玩請參考 Slax popcorn in vmplayer
  3. gcin 中文輸入請參考 gcin in slax popcorn
  4. jre/apr-tcnative/tomcat 請參考 Native Tomcat in Slax
  5. 網頁測試 autobench.mo 請參考 httperf and autobench

源起

之前包 autobench.mo 為求方便,只有加個輸出單張的 PNG 的 script 而已,這次想要修改一下輸出樣式,可以輸出一個簡易 HTML 報告, 這樣到底是要繼續改 bench2png 還是另外作 ? 這裡選擇另外作 shell script 來跑,因為 perl 不熟 :-)

要輸出 HTML 當然需要 HTTP 服務,內建要選小一點的,所以選 lighttpd 供測試與展示 HTML 使用。

lighttpd inside

注意編譯 lighttpd 期間需要 pcre 支援,安裝完並不需要這個 pcre。

  1. wget pcre; configure; make; checkinstall
  2. wget lighttpd; configure; make; checkinstall

試運轉後發現 lighttpd 需要使用 sendfile 支援,而這個部份似乎有點問題,必須考量將 www 等目錄掛在 tmpfs 上。

  1. cd /mnt/hda1/work
  2. mkdir httpmark
  3. installpkg -root httpmark ../httperf-0.8-i386-1.tgz
  4. installpkg -root httpmark ../autobench-2.1.2-i386-1.tgz
  5. installpkg -root httpmark ../lighttpd-1.4.11-i386-1.tgz
  6. cd httpmark
  7. mkdir -p usr/local/lighttpd/www/test
  8. mkdir -p usr/local/lighttpd/logs
  9. echo “httpmark work” > usr/local/lighttpd/www/index.html
  10. echo “httpmark test” > usr/local/lighttpd/www/test/index.html

這裡預設會輸出 4 個圖檔,與 4 個 tsv 檔。

<img src="hmark_1.png"/>
<a href="hmark_1.tsv.txt">hmark_1.tsv</a>
.....

同時放幾個 jpg 檔進去。test10k/test20k/test50k/test100k,同時把設定檔調一下。

  1. cp /mnt/hda1/lighttpd-1.4.11/doc/lighttpd.conf usr/local/lighttpd/
  2. cp /mnt/hda1/lighttpd-1.4.11/doc/rc.lighttpd usr/local/lighttpd/
  3. cd usr/local/lighttpd/

接下來改 lighttpd 啟動檔, vi my.lighttpd 如下,主要是一開始劃出 tmpfs 來掛的要求必須滿足。

#! /bin/sh
# Check lighttpd
LIGHTTPD_BIN=/usr/local/sbin/lighttpd
if [ ! -e $LIGHTTPD_BIN ]; then
        echo "ERROR : $LIGHTTPD_BIN DO NOT exist." 
        exit 0
fi
#
# check tmpfs for lighttpd
#
LIGHTTPD_HOME=/usr/local/lighttpd
LIGHTTPD_FS=/usr/local/tmpfs/lighttpd
target=`df -h | grep "$LIGHTTPD_FS"`
if [ "$target" == "" ]; then
        echo "Mount tmpfs in $LIGHTTPD_FS" 
        [ -e $LIGHTTPD_FS ] || mkdir -p $LIGHTTPD_FS
        mount tmpfs $LIGHTTPD_FS -t tmpfs -o size=24m
        mkdir -p $LIGHTTPD_FS/logs
        cp -r $LIGHTTPD_HOME/www/ $LIGHTTPD_FS
fi

LIGHTTPD_HOME=/usr/local/lighttpd
LIGHTTPD_CONF_PATH=$LIGHTTPD_HOME/lighttpd.conf

case "$1" in
    start)
        echo "Starting lighttpd..." 
        # check if lighttpd.pid file exists [mylighttpd.sh creates it.]
        if [ -e $LIGHTTPD_HOME/lighttpd.pid ] ; then
                pid=`cat $LIGHTTPD_HOME/lighttpd.pid`
                # check if process is still running
                if [ -d "/proc/$pid" ]; then
                        echo "lighttpd already running as process $pid.Stop it first.." 
                        exit 0
                fi
        fi
        $LIGHTTPD_BIN -f $LIGHTTPD_CONF_PATH &
        echo $! > $LIGHTTPD_HOME/lighttpd.pid
        ;;
    stop)
        echo "Shutting down lighttpd..." 
        if [ -e $LIGHTTPD_HOME/lighttpd.pid ] ; then
                pid=`pgrep lighttpd`
                kill $pid
                rm $LIGHTTPD_HOME/lighttpd.pid
        fi
        ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" 
        exit 1
        ;;
esac

然後修改設定檔,將路徑指到 tmpfs 去。

vi usr/local/lighttpd/lighttpd.conf

server.document-root        = "/usr/local/tmpfs/lighttpd/www/" 
server.errorlog             = "/usr/local/tmpfs/lighttpd/logs/lighttpd.error.log" 
accesslog.filename          = "/usr/local/tmpfs/lighttpd/logs/access.log" 

接下來重開機測試 lighttpd。

#dir2mo httpbench httpmark-0.1.mo #reboot
  1. uselivemod httpmark-0.1.mo
  2. /usr/local/lighttpd/my.lighttpd start
  3. netstat -at
  4. check http://127.0.0.1/

gnuplot 的樣本檔

建立一個 gnuplot 的樣本檔,可以先跑看看,然後到時候用 sed 換字就好。

  1. cd /mnt/hda1/work/httpmark
  2. mkdir usr/local/httpmark
  3. cd usr/local/httpmark
  4. vi httpmark.plt
set terminal png small color
set key outside below
set key box
set grid
set output "results.png" 
set data style linespoints
set title "results.title" 
set xlabel "X Axis : dem_req_rate" 
set y2tics
set ytics nomirror
set y2label "Y2 Axis : Mbps" 
plot "results.tsv" using 1:2 every ::1 ti "req rate" , \
"results.tsv" using 1:3 every ::1 ti "conn rate" , \
"results.tsv" using 1:7 every ::1 ti "std_req_rate", \
"results.tsv" using 1:8 every ::1 ti "resp_time(ms)", \
"results.tsv" using 1:10 every ::1 ti "error", \
"results.tsv" using 1:($9*8/1024) every ::1 ti "net_io(Y2)" axis x1y2

關於 gnuplot 可以參考。

http://t16web.lanl.gov/Kawano/gnuplot/plot1-e.html#5.2 http://www.gnuplot.info/faq/faq.html http://www.gentoo.org/doc/en/articles/l-awk1.xml?style=printable

httpmark.sh

  1. vi httpmark.sh
  2. chmod +x httpmark.sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
echo "httpbench runing...." 
echo "test : $1" 
echo "low rate : $2" 
echo "high rate : $3" 
echo "num call : $4" 
echo "num conn  : $5" 
echo "rate step : $6" 

#
# check autobench
#
abcmd=/usr/local/bin/autobench
if [ ! -e $abcmd ]; then
        echo "autobench is not install." 
        exit 0
fi
#
# autobench need conf file
#
exaconf=/usr/local/etc/autobench.conf
aconf=$HOME/.autobench.conf
[ ! -e "$aconf" ] && cp $exaconf $aconf

#
# gnuplot template
#
HTTPMARK_HOME=/usr/local/httpmark
plt=$HTTPMARK_HOME/httpmark.plt
HTDOC=/usr/local/tmpfs/lighttpd/www
#
# run autobench
#
uri="/test" 
testfile="test10k.jpg" 
echo "Run autobench with num_call $4" 
tsvfile=hmark_$1.tsv
echo "tsv file : $tsvfile" 
pngfile=hmark_$1.png
echo "png file : $pngfile" 
title="hmark($testfile) n_call=$4,n_conn=$5" 
echo "title : $title" 
autobench --single_host --host1 127.0.0.1 \
 --port1 80 --uri1 $uri/$testfile --quiet \
 --low_rate $2 --high_rate $3 --rate_step $6 \
 --num_call $4 --num_conn $5 --timeout 5 \
 --file $tsvfile
# sed file
sed -e "s/results.tsv/$tsvfile/g" \
-e "s/results.png/$pngfile/g" \
-e "s/results.title/$title/g" $plt | gnuplot
mv $pngfile $HTDOC/
mv $tsvfile $HTDOC/$tsvfile.txt
echo "httpbench done." 
exit 0

  1. /usr/local/httpmark/httpmark.sh
  2. dir2mo httpmark httpmark-0.1.mo
  3. reboot

final run

  1. uselivemod gnuplot.mo
  2. uselivemod httpmark-0.1.mo
  3. /usr/local/lighttpd/my.lighttpd start
  4. /usr/local/httpmark/httpmark.sh 1 50 150 1 600 10

跑完可以到 http://127.0.0.1 去看結果,測試需要不斷調整觀察,這個部份是最難的,一直到找出轉折點,換成 httpmark.sh 2 xx xx xx xx xx 繼續跑,可以放 4 個結果。

download

httpmark-0.1.mo

Linux links

0

SLAX

gcin 同好會

KNOPPIX中文交流網

自由軟體技術交流網

開放原始碼新聞網

自由軟體鑄造場

Mozilla Taiwan

鳥哥的 Linux 私房菜

酷!學園討論區

kaise

httperf and autobench in Slax

0

源起

下面內容可能出現之前做過而省略或是疏漏現象,如有問題請告訴我或是參考之前本站的 Native Tomcat in Slax 一文,也許可以找到相關提示。

my_7_crash.svg

網站要掛了嗎 ?

網站的效能往往需要測試才知道可以跑到哪種程度,平常就應該要測看看,在掛掉之前趕快解決。

關於測試工具 httperf 與 autobench 的部份,請閱讀 HTTP performance testing 一文,有非常詳細的內容可以參考,這裡是要轉化為 slax 可以用的 mo,方便在 vmplayer 之中運行。

一開始要做的是取得檔案後開始安裝 httperf 與 autobench 。

checkinstall httperf

  1. cd /mnt/hda1
  2. wget httperf-0.8.tar.gz
  3. uselivemod Official_Development_module_5_1_4.mo
  4. tar zxvf httperf-0.8.tar.gz
  5. cd httperf-0.8
  6. ./configure
  7. make
  8. checkinstall
  9. mv httperf-0.8-i386-1.tgz /mnt/hda1

checkinstall autobench

  1. cd /mnt/hda1
  2. wget autobench-2.1.2.tar.gz
  3. tar zxvf autobench-2.1.2.tar.gz
  4. cd autobench-2.1.2
  5. ./configure
  6. make
  7. checkinstall
  8. mv autobench-2.1.2-i386-1.tgz /mnt/hda1/

開始測試之前需要網站,這裡用本機的 Tomcat 來測。

start tomcat

  1. uselivemod jre-1_5_0_08-linux.mo
  2. uselivemod apache-tomcat-5.5.15.mo
  3. /usr/local/tomcat/bin/startup.sh
  4. netstat -at

httperf first run

第一次跑用比較少的人數,只用 10 個。

httperf—server=192.168.213.131—port=8080—rate=10—num-conns=500

httperf --client=0/1 --server=192.168.213.131 --port=8080 
--uri=/ --rate=10 --send-buffer=4096 --recv-buffer=16384 
--num-conns=500 --num-calls=1

Maximum connect burst length: 1

Total: connections 500 requests 500 replies 500 test-duration 49.909 s

Connection rate: 10.0 conn/s (99.8 ms/conn, <=2 concurrent connections)
Connection time [ms]: min 1.0 avg 2.0 max 184.5 median 1.5 stddev 8.3
Connection time [ms]: connect 0.0
Connection length [replies/conn]: 1.000

Request rate: 10.0 req/s (99.8 ms/req)
Request size [B]: 66.0

Reply rate [replies/s]: min 10.0 avg 10.0 max 10.0 stddev 0.0 (9 samples)
Reply time [ms]: response 2.0 transfer 0.0
Reply size [B]: header 149.0 content 8132.0 footer 0.0 (total 8281.0)
Reply status: 1xx=0 2xx=500 3xx=0 4xx=0 5xx=0

CPU time [s]: user 0.55 system 48.17 (user 1.1% system 96.5% total 97.6%)
Net I/O: 81.7 KB/s (0.7*10^6 bps)

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

換個動態 JSP 試看看,加上—uri=/jsp-examples/jsp2/el/basic-arithmetic.jsp 跑起來,沒太大差異,都還沒到瓶頸。

問題在於要找到極限需要不斷加大設定值來測試,手動當然可以,不過這工具已經有人寫好了。

autobench first test

轉用 autobench 來跑多次的結果方便找出掛掉的地方。

autobench --single_host --host1 192.168.213.131 --port1 8080 --uri1 / --quiet \
--low_rate 10 --high_rate 50 --rate_step 10 --num_call 1 \
--num_conn 1000 --timeout 5 --file results.tsv 

結果如下,大致還是可以看出 req_rate 都可以跟上。

dem_req_rate    req_rate_192.168.213.131        con_rate_192.168.213.131       
min_rep_rate_192.168.213.131     avg_rep_rate_192.168.213.131    
max_rep_rate_192.168.213.131    stddev_rep_rate_192.168.213.131 
resp_time_192.168.213.131      net_io_192.168.213.131   errors_192.168.213.131
10      10.0    10.0    10.0    10.0    10.0    0.0     1.1     81.6    0
20      20.0    20.0    20.0    20.0    20.0    0.0     1.1     163.2   0
30      30.0    30.0    30.0    30.0    30.0    0.0     1.0     244.8   0
40      40.0    40.0    40.0    40.0    40.0    0.0     1.1     326.4   0
50      50.0    50.0    50.0    50.0    50.0    0.0     1.0     408.0   0

文字檔很難看出正確的趨勢,還是轉圖出來看比較方便找出關鍵。

download gnuplot

輸出圖案來判讀簡單了解,不過需要先下載 gnuplot mo 來裝。

  1. cd /mnt/hda1
  2. wget gnuplot_4_0.mo
  3. uselivemod gnuplot_4_0.mo

裝好就可以用 bench2graph 跑看看。

bench2png

autobench 附的 bench2graph 會輸出 postscript 格式,這裡換成 PNG 格式。改成 echo set terminal png small color 的命令。

  1. cd /usr/local/bin
  2. cp bench2graph bench2png
  3. vi bench2png
  4. cd to autobench results dir
  5. bench2png results.tsv result.png

上圖可以看到整個線性上升,尚未到底,再加點負荷,跑一次看看,同時為了避免流量飆高,整個 Y 軸都是流量,會導致其他數值看起來躺在 X 軸上,所以採用指定欄位的做法,避掉 net_io 這一欄。

# autobench --single_host --host1 192.168.213.131 --port1 8080 --uri1 / --quiet \
--low_rate 10 --high_rate 100 --rate_step 10 --num_call 10 \
--num_conn 1000 --timeout 5 --file results2.tsv
bench2png results2.tsv results2.png 4 5 6 7 8

圖中可以看到卡在800-900 請求/秒 (80-90 連線/秒) 的時候,急速墜落。

道這裡完成基本安裝與測試,接下來可以包個 mo 出來用了,免得關機完要再來一次。

dir2mo autobench mo

為求以後測試方便,將 httperf 與 autobench 包成一個 mo,同時加上改的 bench2png。

  1. cd /mnt/hda1/work
  2. mkdir autobench
  3. installpkg -root autobench ../autobench-2.1.2-i386-1.tgz
  4. installpkg -root autobench ../httperf-0.8-i386-1.tgz
  5. cp /usr/local/bin/bench2png autobench/usr/local/bin/
  6. dir2mo autobench autobench-2.1.2.mo
  7. reboot for test.

包完後開機一次做完整測試。

uselivemod autobench-2.1.2.mo

  1. cd /mnt/hda1/work
  2. uselivemod jre-1_5_0_08-linux.mo
  3. uselivemod apache-tomcat-5.5.15.mo
  4. uselivemod gnuplot_4_0.mo
  5. uselivemod autobench-2.1.2.mo
  6. /usr/local/tomcat/bin/startup.sh
  7. cd /tmp
  8. autobench again
  9. bench2png results.tsv results.png 4 5 6 7 8

這裡可以用更細的方式試看看,改取每次加五個方式。

autobench --single_host --host1 192.168.213.131 --port1 8080 --uri1 / --quiet \
--low_rate 50 --high_rate 100 --rate_step 5 --num_call 10 \
--num_conn 1000 --timeout 5 --file results.tsv 

看起來 750需求 (75連線) 左右就開始不穩。奇怪的是後來又線性上揚,不清楚是不是 JVM 的 GC 運作導致 Tomcat 一口氣喘不過來,有機會再多做些測試。

download autobench-2.1.2.mo

autobench-2.1.2.mo

links

The Linux HTTP Benchmarking HOWTO

httperf—-A Tool for Measuring Web Server Performance

Native Tomcat in SLAX

0

緣起

年初做了個簡易測試 Tomcat 的 APR 連接器簡易測試 發布在 javaworld@TW 網站,現在想在 SLAX popcorn 上面跑看看,這裡將先作編譯與環境準備工作,也就是產出相對的 mo 檔。

下圖為本文產出的 mo 安裝之後,用 firefox 跑出來的部份畫面。

更新紀錄 Changelog

  1. 2006-09-26 APR 本身編譯時可能以為系統有 sendfile 支援,但是執行時候卻發現沒有這樣支援,可能是檔案系統的支援問題 ? 待查,這個現象在 Apache in Slax 一文 中有遇到,可以在設定檔關掉這個行為,Tomcat 也可以設定 useSendfile 參數來關掉,預設是有開啟的。所以說下面做法如果沒有做到修正檔案系統或是關掉設定的輔助,很可能會導致更慘的效率,白忙一場。但是這在一般 ext2/ext3 應該都沒問題,不過這裡畢竟是談 SLAX 環境,特此加上說明。

準備

有些步驟可能之前做過而出現省略或是疏漏現象,請告訴我或是請參考之前本站的 gcin in slax popcorn 一文,也許可以找到相關提示。

編譯需要準備一些工具,當然要跑 tomcat 之前須先有 JRE。一開始先到 Apache Tomcat 5.5.17 下載,然後主要參考 Apache Portable Runtime and Tomcat 的說明來進行。

Create jre mo

先裝安裝檔,再加連結到 /usr/local/bin/java 執行檔與 /usr/local/java 目錄,接著用 dir2mo 包成 mo 檔,並裝上去測看看。

  1. cd /mnt/hda1
  2. wget jre-1_5_0_08-linux-i586.bin
  3. chmod +x jre-1_5_0_08-linux-i586.bin
  4. cd /mnt/hda1/work
  5. mkdir -p java/usr/local
  6. cd java/usr/local/
  7. /mnt/hda1/jre-1_5_0_08-linux-i586.bin
  8. yes
  9. ls
  10. jre1.5.0_08/bin/java -version
  11. mkdir bin
  12. cd bin
  13. ln -s ../jre1.5.0_08/bin/java java
  14. ./java -version
  15. cd /mnt/hda1/work/java/usr/local
  16. ln -s jre1.5.0_08 java
  17. java/bin/java -version
  18. cd /mnt/hda1/work
  19. dir2mo java jre-1_5_0_08-linux.mo
  20. uselivemod jre-1_5_0_08-linux.mo
  21. java -version

Tomcat test run

tomcat 後來預設用 eclipse 的編譯器,所以目前只要裝 JRE 1.5 版,並不需要裝到 JDK 版本,但是編譯 tcnative 需要 JDK,等一下會談到。

  1. cd /mnt/hda1
  2. wget apache-tomcat-5.5.17.tar.gz
  3. tar zxvf apache-tomcat-5.5.17.tar.gz
  4. export JAVA_HOME=/usr/local/java
  5. apache-tomcat-5.5.17/bin/startup.sh
  6. netstat -at | grep 8080
  7. more apache-tomcat-5.5.17/logs/catalina.out

一開頭部份可以看到 APR 沒有載入。

INFO: The Apache Tomcat Native library which allows optimal performance 
in production environments was not found on the java.library.path:....

Create the jdk mo

編譯 tomcat-native-1.1.3 需要 JDK 的一些檔案,所以建立需要的 jdk mo 檔,這個檔約需要 130M 的空間來解開,所以要注意一下空間。

  1. cd /mnt/hda1
  2. wget jdk-1_5_0_08-linux-i586.bin
  3. chmod +x jdk-1_5_0_08-linux-i586.bin
  4. cd /mnt/hda1/work
  5. mkdir -p jdk/usr/local
  6. cd jdk/usr/local/
  7. /mnt/hda1/jdk-1_5_0_08-linux-i586.bin
  8. jdk1.5.0_08/bin/java -version
  9. cd /mnt/hda1/work
  10. dir2mo jdk jdk-1_5_0_08-linux.mo
  11. uselivemod jdk-1_5_0_08-linux.mo
  12. /usr/local/jdk1.5.0_08/bin/java -version

Create the openssl mo

另外也需要 openssl,爆米花只有裝精簡版,換上完整版。

  1. search openssl in http://slackware.it/en/pb/
  2. wget openssl-0.9.8b-i486-1.tgz
  3. cd /mnt/hda1/work
  4. mkdir openssl
  5. installpkg -root openssl /mnt/hda1/openssl-0.9.8b-i486-1.tgz
  6. dir2mo openssl openssl-0.9.8b.mo
  7. uselivemod openssl-0.9.8b.mo

install Apache Portable Runtime

編譯之前需要 Apache Portable Runtime

  1. apache-tomcat-5.5.17/bin/shutdown.sh
  2. uselivemod /mnt/hda1/Official_Development_module_5_1_4.mo
  3. cd /mnt/hda1
  4. wget apr-1.2.7.tar.bz2
  5. tar jxvf apr-1.2.7.tar.bz2
  6. cd apr-1.2.7
  7. ./configure
  8. make
  9. make install

預設會裝到 /usr/local/apr/

install tomcat native

  1. cd apache-tomcat-5.5.17/bin/
  2. tar zxvf tomcat-native.tar.gz
  3. cd tomcat-native-1.1.3/jni/native
  4. ./configure—with-apr=/usr/local/apr—with-java-home=/usr/local/jdk1.5.0_08
  5. make
  6. make install
  7. ls /usr/local/apr/lib

關鍵在於環境變數 LD_LIBRARY_PATH,只要設對,tomcat 就會啟動 APR

  1. export LD_LIBRARY_PATH=/usr/local/apr/lib
  2. cd /mnt/hda1/apache-tomcat-5.5.17
  3. bin/startup.sh
  4. tail -100 logs/catalina.out
  5. bin/shutdown.sh

catalina.out 可以看出差異,非 APR 的版本可以找到 Http11BaseProtocol start 字眼,有 APR 的版本可以找出 Http11AprProtocol start。

make apr-tcnative.mo

既然直接編譯可以裝,必須轉成 mo 測看看,這裡將 apr-1.2.7 與 tomcat-native-1.1.3 兩個安裝一起後包成 apr-tcnative-1.1.3.mo 來用。

  1. cd /mnt/hda1/apr-1.2.7
  2. checkinstall
  3. mv apr-1.2.7-i386-1.tgz /mnt/hda1
  4. cd /mnt/hda1/apache-tomcat-5.5.17/
  5. cd bin/tomcat-native-1.1.3/jni/native/
  6. checkinstall
  7. mv native-native-i386-1.tgz /mnt/hda1/tomcat-native-i386-1.tgz
  8. cd /mnt/hda1/work
  9. mkdir apr-tcnative
  10. installpkg -root apr-tcnative ../apr-1.2.7-i386-1.tgz
  11. installpkg -root apr-tcnative ../tomcat-native-i386-1.tgz
  12. dir2mo apr-tcnative apr-tcnative-1.1.3.mo
  13. reboot for test

make tomcat.mo

重開後測試 apr-tcnative-1.1.3.mo 可以的話,就準備改一下 tomcat 來包 apache-tomcat-5.5.15.mo,讓啟動 APR 模式比較簡單。

  1. cd /mnt/hda1/work
  2. mkdir -p tomcat/usr/local
  3. cd tomcat/usr/local
  4. tar zxvf ../apache-tomcat-5.5.17.tar.gz
  5. cd apache-tomcat-5.5.17
  6. vi bin/catalina.sh

這裡有個考量,必須指名 JAVA_HOME 的位置,而這個位置卻是每次裝新的 JRE 都會更換的,所以設到 /usr/local/java,加上下面一行。

export JAVA_HOME=/usr/local/java

  1. uselivemod jre-1_5_0_08-linux.mo
  2. uselivemod apr-tcnative-1.1.3.mo
  3. cd bin
  4. cp startup.sh startapr.sh
  5. vi startapr.sh

主要是把環境變數寫入,不用每次輸入,加上下面一行。

export LD_LIBRARY_PATH=/usr/local/apr/lib

開始測看看。

  1. ./startapr.sh
  2. tail -100 logs/catalina.out
  3. ./shutdown.sh

可以跑就準備包起來,同時做個捷徑 /usr/local/tomcat。

  1. cd /mnt/hda1/work
  2. cd tomcat/usr/local
  3. ln -s apache-tomcat-5.5.17 tomcat
  4. cd /mnt/hda1/work
  5. dir2mo tomcat apache-tomcat-5.5.17.mo
  6. reboot

final tomcat-native mo test run

重開後就可以把需要的 mo 載入跑看看。

  1. cd /mnt/hda1/work
  2. uselivemod jre-1_5_0_08-linux.mo
  3. uselivemod apr-tcnative-1.1.3.mo
  4. uselivemod apache-tomcat-5.5.17.mo
  5. /usr/local/tomcat/bin/startapr.sh
  6. netstat -at
  7. tail -100 /usr/local/tomcat/logs/catalina.out
  8. uselivemod ttf-arphic-uming-0.1.mo
  9. uselivemod firefox-1.5.0.6-zh_TW.mo
  10. uselivemod gcin-1.2.5.mo
  11. ldconfig
  12. startx
  13. firefox to http://127.0.0.1:8080/

Download

下面軟體都是 Apache 改作,所以採 Apache License 釋出,非本站慣用 授權

apr-tcnative-1.1.3.mo [860K]

apache-tomcat-5.5.17.mo [5964K]

Older posts: 1 2 3 4