[Logo]
Messages posted by: andowson
Forum Index » Profile for andowson » Messages posted by andowson
Message
中華電信數據分公司98年度研發替代役人員第二次徵才公告

主旨:公告本公司所轄數據分公司遴選98年研發替代役人員第二次徵才公告事宜。
依據:內政部頒佈之「替代役實施條例」、「研發替代役甄選訓練服役實施辦法」及「中
   華電信股份有限公司新進從業人員遴選作業要點」規定辦理。

一、遴選日程:
  (一)報名日期:自 98.06.03 (星期三)至 98.06.12 (星期五)中午 12 點止
  (二)第一試(資歷論文審查)日期:98.06.15 (星期一)至 98.06.22 (星期一)由數據分公司資歷
    審查遴選。
  (三)第二試通知日期:98.06.25 (星期四),以 Email 通知詳細口試時程及順序表,並請於
    收到 mail 後回覆是否參加。
  (四)第二試(口試)日期:98.07.02 (星期四) ~ 98.07.03 (星期五)(若有異動,以通知變更日期
    為準)。
  (五)放榜日期:98.07.08 (星期三)(若有異動,以通知變更日期為準)。

二、口試地點:台北市信義路一段 21 號數據通信大樓。

三、資格:具有中華民國國籍,且符合內政部研發替代役資格者。

四、報名方式:網路報名外,並請郵寄相關應繳資料,始完成報名手續。
  (一)網路線上登錄報名(時間:98 年 6 月 3 日至 98 年 6 月 12 日中午 12 時正)。
  (二)應徵人員應檢附下列資料:(每人以應徵一項職缺為限)
    1.報名履歷表乙份(請先於網路報名後,再列印「報名履歷表」使用)
    2.自傳(請先登載至報名系統,再列印使用,如有其他附件資料,請一併郵寄)
    3.身分證正反面影本乙份(請黏貼於履歷表上)
    4.研究所及大學全份學業成績單各乙份(如為二技畢業者,請附專科全份成績單)
    5.論文(或論文摘要)、著作、研究計畫資料
    6.技能檢定、證照及經歷證明文件影印本(無者免附)
    7.原住民身分證明(具原住民身分者)
    ※以上資料及證件影本如有偽造、變造及其他不實情事,應考人應負法律責任,如
     獲錄取者亦將取消錄取資格。
  (三)請以限時掛號郵寄應繳表件,並請於 98 年 6 月 12 日前(以郵戳為憑)郵寄「(10048)台
    北市信義路一段 21 號(數據通信大樓),中華電信數據分公司 人事室」始完成報名手
    續。
  (四)報名資料請務必留下正確之地址、E-mail 及聯絡電話、手機號碼,以利通知。

五、錄取名額:22名。

詳細資訊請見:http://www.cht.com.tw/CompanyCat.php?CatID=4&NewsID=2795&Page=HotNewsDetail
請問您是指log4j嗎?
目前JForum有附一個log4j.xml的設定檔在WEB-INF目錄下
可以加以調整以便將訊息輸出到我們指定的路徑下, 目前我的設定如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
	<appender name="jforum-stdout" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n"/>
		</layout>
	</appender>
	
	<appender name="jforum.log" class="org.apache.log4j.RollingFileAppender">
		<param name="MaxFileSize"  value="1024KB"/>
		<param name="MaxBackupIndex" value="4"/>

		<param name="File" value="/home/andowson/logs/jforum.log"/>
		
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p [%-c{1}] - %m%n"/>
	   </layout>
	</appender>
	
	<category name="org.jgroups">
		<priority value="info"/>
		<appender-ref ref="jforum.log"/>
	</category>
	
	<category name="org.jboss">
		<priority value="info"/>
		<appender-ref ref="jforum.log"/>
	</category>

	<category name="net.jforum">
		<priority value="info" />
		<appender-ref ref="jforum.log" />
	</category>
	
	<category name="freemarker">
		<priority value="info"/>
		<appender-ref ref="jforum.log"/>		
	</category>

	<category name="com.mchange">
		<priority value="info" />
		<appender-ref ref="jforum.log" />
	</category>
</log4j:configuration>
今天在Tomcat 6.0.18上又遇到這個問題
The type javax.servlet.http.HttpSession cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.jsp.JspException cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.jsp.tagext.Tag cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.jsp.JspApplicationContext cannot be resolved. It is indirectly referenced from required .class files
HttpSession cannot be resolved to a type
JspWriter cannot be resolved to a type
JspWriter cannot be resolved to a type
The type javax.servlet.jsp.JspContext cannot be resolved. It is indirectly referenced from required .class files
org.apache.jasper.runtime.PageContextImpl cannot be resolved to a type

後來找到這篇http://forums.sun.com/thread.jspa?threadID=708154
解法如下
修改Tomcat conf目錄下的 web.xml, 將
<init-param>
  <param-name>fork</param-name>
  <param-value>false</param-value>
</init-param>

修改為
<init-param>
  <param-name>fork</param-name>
  <param-value>true</param-value>
</init-param>

然後重新起動Tomcat
這樣就OK了
OLAT 自6.1.0版起開始支援Cluster架構和更容易引進多國語言的翻譯工具,最近更新的6.1.1版,修正了很多新版剛發行時的bug,如修正了一些正體中文註冊連結的問題,因此,我比較推薦安裝這個版本。底下是整個全新安裝的步驟。

一、設計理念
OLAT是一個網頁應用系統,可以在Tomcat上安裝及執行,後端可以接MySQL或PostgreSQL或其他Hibernate支援的資料庫,如果要執行聊天室功能,我們還需要安裝Openfire,如果要支援Cluster,還要安裝JMS Server(如ActiveMQ)。由於設備有限,我以全部安裝在單部主機(CentOS 5.3 Linux)方式介紹,不考慮Cluster的模式。

我們預計安裝OLAT的目錄是/home/andowson/www/olat,底下如未特別聲明,均是以andowson身份執行(具有sudo權限)。

我們預計安裝下列元素:
1. JDK+Apache+Tomcat+mod_jk
2. PostgreSQL
3. Ant
4. Openfire
5. OLAT

二、實作步驟
1.可以參考這篇文章完成:http://www.andowson.com/posts/list/315.page,並參考這篇http://www.andowson.com/posts/list/309.page建立一個Virtual Host,在此就不浪費篇幅。
2.PostgreSQL的安裝及啟動可以透過下列的指令來完成(以root身份執行):
yum -y install postgresql-server
sed -i -e "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /var/lib/pgsql/data/postgresql.conf

sed -i -e "s/local   all         all                               ident sameuser/local   all         all         trust/g" /var/lib/pgsql/data/pg_hba.conf
sed -i -e "s/host    all         all         127.0.0.1\/32          ident sameuser/host    all         all         127.0.0.1\/32          md5/g" /var/lib/pgsql/data/pg_hba.conf
sed -i -e "69a\host    all         all         192.168.1.0\/24        md5" /var/lib/pgsql/data/pg_hba.conf

chkconfig --level 235 postgresql on
service postgresql start

3.Ant安裝也很簡單,只需要下載並解壓縮即可,這裡我們以安裝1.7.1版為例
cd ~/download
wget http://apache.ntu.edu.tw/ant/binaries/apache-ant-1.7.1-bin.tar.gz
sudo tar zxvf apache-ant-1.7.1-bin.tar.gz -C /usr/local

接著設定環境變數ANT_HOME
vi ~/.bash_profile
ANT_HOME=/usr/local/apache-ant-1.7.1
JAVA_HOME=/usr/java/latest
PATH=$PATH:$HOME/bin:$ANT_HOME/bin:$JAVA_HOME/bin

export PATH ANT_HOME JAVA_HOME

執行source將設定載入
source ~/.bash_profile

4.安裝Openfire(以root身份執行):
cd /root/setup
wget http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-3.6.4-1.i386.rpm
rpm -ivh openfire-3.6.4-1.i386.rpm
chmod 755 /opt/openfire

建立資料庫openfire
sudo -u postgres psql -c "CREATE USER openfire WITH ENCRYPTED PASSWORD 'openfire' VALID UNTIL 'infinity' CREATEDB;" template1
sudo -u postgres psql -c "CREATE DATABASE openfire WITH ENCODING 'UNICODE';" -U openfire template1
sudo -u postgres psql -c "ALTER USER openfire NOCREATEDB;" template1
sudo -u postgres psql openfire openfire -f /opt/openfire/resources/database/openfire_postgresql.sql

手動設定設定檔openfire.xml,將下列設定貼在</jive>之前
vi /opt/openfire/conf/openfire.xml
  <connectionProvider>
    <className>org.jivesoftware.database.DefaultConnectionProvider</className>
  </connectionProvider>
  <database>
    <defaultProvider>
      <driver>org.postgresql.Driver</driver>
      <serverURL>jdbc:postgresql://localhost:5432/openfire</serverURL>
      <username>openfire</username>
      <password>openfire</password>
      <testSQL>select 1</testSQL>
      <testBeforeUse>true</testBeforeUse>
      <testAfterUse>true</testAfterUse>
      <minConnections>1</minConnections>
      <maxConnections>25</maxConnections>
      <connectionTimeout>1.0</connectionTimeout>
    </defaultProvider>
  </database>
  <setup>true</setup>

調整openfire在系統開機時自動啟動的順序(要在PostgreSQL之後,Tomcat之前)
sed -i -e "s/99 1/80 20/g" /etc/init.d/openfire
調整openfire啟動時的JVM參數
sed -i -e "s/-server/-server -Xss256k/g" /etc/init.d/openfire
設定開機自動啟動openfire
chkconfig openfire on
啟動openfire
service openfire start

啟動之後,開啟瀏覽器到http://<your_server_name>:9090/,以admin/admin登入
調整一些系統設定,如mail server,不允許使用者建立帳號跟修改密碼等
接著下載OLAT plugin
http://www.olat.org/downloads/stable/olatUserAndGroupService.jar
然後切換到Plugin頁面,將這個jar檔匯入即可。

注意:如果您有設定iptables或其他防火牆,建議先關閉,等測試沒問題後再打開,並增加Openfire所需要的port。

5.終於到了主菜了,安裝OLAT,我們需要先下載OLAT原始碼的壓縮檔,解壓縮,建立build.properties,然後再執行ant config-all, ant build來編譯。
# get OLAT source
cd ~/download
wget http://www.olat.org/downloads/stable/OLAT-6.1.1.zip
unzip OLAT-6.1.1.zip
mv OLAT-6.1.1-PUBLIC-* olat3
cd olat3
# config build.properties
sed -e "s/\/usr\/local\/opt\/olat\/olat3/\/home\/andowson\/download\/olat3/g" \
-e "s/\/usr\/local\/opt\/olat\/olatdata/\/home\/andowson\/data\/olatdata/g" \
-e "s/\/usr\/local\/opt\/tomcat/\/var\/tomcat6/g" \
-e "1,$$s/www.myolat.com/www.andowson.com/g" \
-e "1,$$s/myolat.com/andowson.com/g" \
-e "1,$$s/myolat/andowson/g" \
-e "s/server.modjk.enabled=false/server.modjk.enabled=true/g" \
-e "55a\server.modjk.jvmRoute=worker1" \
-e "s/defaultcharset=ISO-8859-1/defaultcharset=UTF-8/g" \
-e "s/registration.enableNotificationEmail=false/registration.enableNotificationEmail=true/g" \
-e "s/smtp.host=smtp.andowson.com/smtp.host=smtp.yourcompany.com/g" \
-e "s/smtp.user=/smtp.user=username/g" \
-e "s/smtp.pwd=/smtp.pwd=password/g" \
-e "120,142d" \
-e "1,$$s/#db/db/g" \
-e "1,$$s/net.sf.hibernate/org.hibernate/g" \
-e "s/instantMessaging.enable=false/instantMessaging.enable=true/g" \
-e "s/instantMessaging.server.name=jabber.andowson.com/instantMessaging.server.name=www.andowson.com/g" \
-e "s/instantMessaging.db.name=wildfire/instantMessaging.db.name=openfire/g" \
-e "s/instantMessaging.db.user=wildfire/instantMessaging.db.user=openfire/g" \
-e "s/instantMessaging.db.pass=wildfire/instantMessaging.db.pass=openfire/g" \
-e "s/cluster.catalinaport=8006/cluster.catalinaport=8105/" \
-e "s/cluster.ajpport=8009/cluster.ajpport=8109/" build.properties.default > build.properties
# adjust the original template config files
sed -i -e "s/<enabledLanguages>en,de,fr,it,es<\/enabledLanguages>/<enabledLanguages>en,de,fr,it,es,zh_CN,zh_TW<\/enabledLanguages>/g" ~/download/olat3/webapp/WEB-INF/olat_config.xml.in
sed -i -e "1,$$s/olat-newinstallation.org/andowson.com/g" ~/download/olat3/webapp/WEB-INF/olat_config.xml.in
sed -i -e "13c\        <\!-- default session timeout -->" ~/download/olat3/webapp/WEB-INF/web.xml.in
ant config-all
ant build

接著我們需要先建立一個olat的資料庫再來執行ant dbsetup_postgreSQL。
# create database olat and testdb
sudo -u postgres psql -c "CREATE USER olat WITH ENCRYPTED PASSWORD 'olat' VALID UNTIL 'infinity' CREATEDB;" template1
sudo -u postgres psql -c "CREATE DATABASE olat WITH ENCODING 'UNICODE';" -U olat template1
sudo -u postgres psql -c "CREATE DATABASE testdb WITH ENCODING 'UNICODE';" -U olat template1
sudo -u postgres psql -c "ALTER USER olat NOCREATEDB;" template1

這裡要注意的是PostgreSQL 8.2之前的版本尚未支援drop table if exists這種語法,因在CentOS 5.3發行的是PostgreSQL 8.1.11的版本,由於執行dbsetup_postgreSQL時會先執行deleteDatabase.sql,第一次安裝時由於資料庫是空的,會失敗,故我們需要修正一下deleteDatabase.sql裡面的語法。我們可以先將deleteDatabase.sql換成一個空檔,等第一次建立好table後再換回來。另外第一次啟動時也會執行alter_6_0_x_to_6_1_0.sql,故我們也要同步修正這邊的drop table if exists語法。
# PostgreSQL 8.1 doesn't support if exists
sed -i -e "1,$$s/if exists //g" ~/download/olat3/database/postgresql/deleteDatabase.sql
sed -i -e "1,$$s/if exists //g" ~/download/olat3/database/postgresql/alter_6_0_x_to_6_1_0.sql

# First time install, drop table will fail, use an empty file instead
mv ~/download/olat3/database/postgresql/deleteDatabase.sql ~/download/olat3/database/postgresql/deleteDatabase.sql.bak
touch ~/download/olat3/database/postgresql/deleteDatabase.sql
ant dbsetup_postgreSQL
mv ~/download/olat3/database/postgresql/deleteDatabase.sql.bak ~/download/olat3/database/postgresql/deleteDatabase.sql


接著就可以把編譯好的程式及網頁部署到我們的目的資料夾~/www/olat了,另外OLAT是把程式跟資料分開存放的,這樣子將來要升級新版只要換掉程式碼的目錄即可,我們選定~/data/olatdata作為這個目錄。由於OLAT會將一些檔案解壓縮到static和WEB-INF下,所以記得變更目錄的寫入權限。
# deploy to web directory
cp -rf ~/download/olat3/webapp ~/www/olat
cp -rf ~/download/olat3/htdocs/* ~/www/olat
sudo chgrp -R tomcat ~/www
sudo chgrp -R tomcat ~/data/olatdata
sudo chmod 775 ~/www/olat/static
sudo chmod 775 ~/www/olat/WEB-INF
sudo chmod 775 -R ~/data/olatdata

最後,我們要設定讓Apache將/olat開頭的網址交給Tomcat處理,然後重新啟動Tomcat和Apache。
# add httpd handle setting
echo '/olat/*=loadbalancer' >> /etc/httpd/conf/uriworkermap.properties
sudo /etc/init.d/tomcat stop
sudo killall -9 /usr/java/latest/bin/java
sudo /etc/init.d/tomcat start
sudo /etc/init.d/httpd restart


到此,差不多大功告成了,用administrator/olat登入http://<your_server_name>/olat/dmz/吧!如果可以的話,建議先修改一下密碼再往下進行新的任務囉!
為了升級網站的軟硬體,從四月中開始在別人捐贈的舊電腦上進行安裝及測試,這個週末終於完成進行實際的移機作業。

移機前的硬體大致如下:
CPU: Intel Pentium II-350 MHz/512K L2 Cache
RAM: 512MB (PC-100+PC-133)
HD: 40GB IDE 7200RPM
NIC: 10/100M Fast Ethernet

移機後的硬體大致如下:
CPU: AMD Athlon 1GHz/256K L2 Cache
RAM: 640 MB PC-133
HD: 40GB IDE 7200RPM
NIC: 10/100M Fast Ethernet

對外的Internet網路頻寬目前是HiNet ADSL 8M/640K

粗估大約同時20人上站應該是沒問題

移機後因考量硬體資源不足或網路上已有替代服務,下列的功能或服務項目暫停提供:
Blog(Roller)
Project(Trac + Subversion, JTrac)
Wiki(JSPWiki)
Webmail(JSP Webmail)
Online Message(JSP 線上水球)
Aquamp(線上音樂播放面板)

感謝您對安道生網站技術練功房的支持。
98年度新進從業人員徵才公告

中華電信委託財團法人台灣金融研訓院辦理 98 年度新進從業人員召募作業,預定錄取名額 236 名。

報名期間:自 98 年 6 月 1 日 09:00 至 6 月 11 日 18:00 截止

報名方式:一律採網路報名

報名費用:新台幣 750 元整

遴選方式:分為筆試 ( 7 月 5 日) 及口試 ( 8 月 22、23 日 ) 二部份。

遴選資格及相關規定請依台灣金融研訓院之公告或遴選簡章。
yum clean metadata

參考資料:
http://bugs.centos.org/view.php?id=3481
我今天自己下載執行了一次發現錯誤訊息大致如下:
sed: can't read /var/robust/worker1/conf/web.xml: 沒有此一檔案或目錄
cp: 無法 stat ‘/var/robust/worker1/conf/web.xml’: 沒有此一檔案或目錄

主要原因是下載來源apache.ntu.edu.tw這台主機出了問題,將第67行的參數調整為
MIRROR_HOST=apache.stu.edu.tw
即可正常執行了。
安裝好OpenMeetings後,我們可以用剛剛建立的帳號跟密碼登入。
然後進入任何一間會議室,並試著上傳檔案看看能否正常轉檔。
目前OpenMeetings的轉檔程序是先將所有的檔案轉為PDF,再轉為JPG和Flash(SWF),這部分是使用JODConverter透過OpenOffice.org來處理的,故我們需要安裝必要的套件,不然就會遇到
com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one
這樣的錯誤。
我測試過PowerPoint、Word、Excel均可正常轉檔成功。
另外上傳的檔案如果是txt檔,內容必須是UTF-8編碼的才能正常顯示中文。
目前遇到的一個問題就是上傳的檔名如果包含中文字元的話,會被換成底線(_),已將這個問題回報
http://code.google.com/p/openmeetings/issues/detail?id=726
OpenMeetings是一套免費的Open-Source網頁視訊會議系統(Web-based Video Conferencing System),使用Java語言開發,前端使用Flash作為介面,後端使用免費的Open Source Flash Server Red5作為Flash串流伺服器,資料庫部分使用Hibernate技術,理論上可以支援絕大多數的資料庫。由於PostgreSQL對UTF-8字元的支援較佳,故我選擇使用PostgreSQL作為後端的資料庫。

安裝過程大致如下:
0.JDK安裝:這個應該沒太大問題(已經安裝直接跳過)。
1.資料庫調整:OpenMeetings要求要使用UTF-8編碼的資料庫,PostgreSQL對這方面的支援沒有問題。另外需要開放TCP Listen,我們需要調整兩個檔案/var/lib/pgsql/data/postgresql.conf和/var/lib/pgsql/data/pg_hba.conf即可:
postgresql.sh:
yum -y install postgresql-server
sed -i -e "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /var/lib/pgsql/data/postgresql.conf

sed -i -e "s/local   all         all                               ident sameuser/local   all         all         trust/g" /var/lib/pgsql/data/pg_hba.conf
sed -i -e "s/host    all         all         127.0.0.1\/32          ident sameuser/host    all         all         127.0.0.1\/32          md5/g" /var/lib/pgsql/data/pg_hba.conf
sed -i -e "69a\host    all         all         192.168.1.0\/24        md5" /var/lib/pgsql/data/pg_hba.conf

chkconfig --level 235 postgresql on
/etc/init.d/postgresql start

2.安裝OpenOffice.org並啟動OpenOffice-Service在TCP 8100 port上。
3.安裝ImageMagick(會自動安裝GhostScript)
4.安裝SWFTools
5.安裝FFMpeg
6.安裝Flash Player 10
7.安裝OpenMeetings(含Red5)
8.啟動Red5
openmeetings.sh:
#!/bin/bash
# Name: openmeetings.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 1.0
# Last Modified: 2009-05-10

#
# install openoffice-service running on port 8100 in headless mode
#
yum -y install openoffice.org-base openoffice.org-headless openoffice.org-writer openoffice.org-impress openoffice.org-calc

#
# generate openoffice startup script
#
echo '#!/bin/bash
# openoffice.org  headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice
# 
# Author: Vic Vijayakumar
# Modified by Federico Ch. Tomasczik
#
OOo_HOME=/usr/lib/openoffice.org/program
SOFFICE_PATH=$OOo_HOME/soffice.bin
PIDFILE=/var/run/openoffice-server.pid

set -e

case "$1" in
    start)
    if [ -f $PIDFILE ]; then
      echo "OpenOffice headless server has already started."
      sleep 5
      exit
    fi
      echo "Starting OpenOffice headless server"
      $SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1
      touch $PIDFILE
    ;;
    stop)
    if [ -f $PIDFILE ]; then
      echo "Stopping OpenOffice headless server."
      killall -9 soffice.bin
      rm -f $PIDFILE
      exit
    fi
      echo "Openoffice headless server is not running."
      exit
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    exit 1
esac
exit 0' > /etc/init.d/openoffice
chmod 755 /etc/init.d/openoffice
chkconfig --level 235 openoffice on
/etc/init.d/openoffice start
 
#
# install ImageMagick(=>GhostScript will be installed as dependency)
#
yum -y install ImageMagick

#
# install SWFTools
#
yum -y install giflib-devel libjpeg-devel freetype-devel
if [ ! -r swftools-0.9.0.tar.gz ]; then
   wget http://www.swftools.org/swftools-0.9.0.tar.gz
fi
tar zxvf swftools-0.9.0.tar.gz
cd swftools-*
./configure
make
make install
cd ..

#
# install FFmpeg
#
if [ ! -r ffmpeg-0.5.tar.bz2 ]; then
   wget http://www.ffmpeg.org/releases/ffmpeg-0.5.tar.bz2
fi
tar jxvf ffmpeg-0.5.tar.bz2
cd ffmpeg-*
./configure
make
make install
cd ..

#
# install Flash player 10
#
if [ ! -r flash-plugin-10.0.22.87-release.i386.rpm ]; then
   wget http://fpdownload.macromedia.com/get/flashplayer/current/flash-plugin-10.0.22.87-release.i386.rpm
fi
rpm -Uvh flash-plugin-10.0.22.87-release.i386.rpm

#
# install OpenMeetings with Red5
#
if [ ! -r openmeetings_0_8_rc2.zip ]; then
   wget http://openmeetings.googlecode.com/files/openmeetings_0_8_rc2.zip
fi
unzip openmeetings_0_8_rc2.zip
mv red5-0.8.RC3-build-hudson-red5_jdk6_stable-79_2 /var/red5
# modify hibernate.cfg.xml
cd /var/red5/webapps/openmeetings/conf
sed -i -e '12c\                <property name="connection.username">openmeetings</property>' hibernate.cfg.xml
sed -i -e '13c\                <property name="connection.password">openmeetings</property>' hibernate.cfg.xml
sed -i -e '16c\                <property name="connection.driver_class">org.postgresql.Driver</property>' hibernate.cfg.xml
sed -i -e '18c\                <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>' hibernate.cfg.xml
sed -i -e '19c\                <property name="connection.url">jdbc:postgresql://localhost/openmeetings</property>' hibernate.cfg.xml
sed -i -e '33c\                <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>' hibernate.cfg.xml
sed -i -e '17d' hibernate.cfg.xml
chmod 755 /var/red5/red5-shutdown.sh

#
# create user and database openmeetings 
#
sudo -u postgres psql -c "create user openmeetings createdb;" template1
sudo -u postgres psql -c "create database openmeetings with encoding 'unicode';" -U openmeetings template1
sudo -u postgres psql -c "alter user openmeetings nocreatedb;" template1
sudo -u postgres psql -c "alter user openmeetings with encrypted password 'openmeetings';" template1

#
# start up red5
#
cd /var/red5
nohup ./red5.sh &

9.開啟瀏覽器,輸入網址http://192.168.1.3:5080/openmeetings/install
按照畫面上的提示輸入相關資訊,其中兩個轉檔工具路徑如下:
SWFTools Path /usr/local/bin
ImageMagick Path /usr/bin
注意:這邊建議先關閉系統的防火牆,等測試好了再啟用。
需要設定的有下列:
1935:tcp 9999:tcp 8088:tcp 5080:tcp 8443:tcp
可以利用以下的指令來查詢:
netstat -ant|grep LISTEN|grep -v 192 |grep -v 127
[root@www red5]# netstat -ant|grep LISTEN|grep -v 192 |grep -v 127
tcp        0      0 0.0.0.0:49952               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:1935                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:9999                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:5080                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:5432                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:8443                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN

10.停止服務可以使用
cd /var/red5
./red5-shutdown.sh

參考資料:
http://code.google.com/p/openmeetings/wiki/InstallationOpenMeetings
http://code.google.com/p/openmeetings/wiki/TechnologyPortfolio
如果我們在同一部Linux主機上,重複安裝作業系統兩次以上,就會遇到這個「現象」(可能有些人不認為是個問題)
[root@www ~]# cat /etc/fstab
LABEL=/1                /                       ext3    defaults        1 1
LABEL=/home1            /home                   ext3    defaults        1 2
LABEL=/usr1             /usr                    ext3    defaults        1 2
LABEL=/var1             /var                    ext3    defaults        1 2
LABEL=/boot1            /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-hda6         swap                    swap    defaults        0 0

每個標籤(LABEL)後面都多了一個1,有些人比較隨便可能可以接受,有些人像我比較追求完美就會覺得有點瑕疵,想要將這個多餘的1去除掉。
可是難道要重新再安裝一次嗎?重新安裝一次就可以解決嗎?答案是不用跟不一定。
以下是我試出來的方法:
首先先找出每個掛載點的硬碟分割名稱
[root@www ~]# df -h
檔案系統              容量  已用 可用 已用% 掛載點
/dev/hda5             3.9G  713M  3.0G  19% /
/dev/hda7              24G  173M   23G   1% /home
/dev/hda3             3.9G  1.2G  2.5G  33% /usr
/dev/hda2             3.9G  239M  3.5G   7% /var
/dev/hda1              99M   17M   78M  18% /boot
tmpfs                 189M     0  189M   0% /dev/shm

我們可以發現 / 對應到/dev/hda5分割區,而 / 在/etc/fstab中的LABEL是/1
利用修改硬碟標籤的指令e2label,我們可以將它們依序修改成我們想要的標籤名稱
e2label /dev/hda5 /
e2label /dev/hda7 /home
e2label /dev/hda3 /usr
e2label /dev/hda2 /var
e2label /dev/hda1 /boot

smilie 在重新開機前,記得修改/etc/grub.conf
[root@www ~]# vi /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hda5
#          initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-128.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-128.el5 ro root=LABEL=/1
        initrd /initrd-2.6.18-128.el5.img

將LABEL=/1改為LABEL=/
存檔後,再執行
sync;sync;sync
reboot
這樣子就可以正常開機了

[障礙排除]
如果您忘了修改這個/etc/grub.conf而造成無法正常開機時,可以拿出安裝光碟片的第一片
用光碟開機後,輸入linux rescue
在開機完成後,系統會將目前的root partition掛載到/mnt/sysimage
所以我們可以
cd /mnt/sysimage/etc
vi grub.conf
將LABEL=/1修正為LABEL=/
存檔後再重新開機即可。
以前讀網路概念時,看到IP/Subnet的教學,我的直覺就是「無趣」,因為一方面自己用不到,二來是幹嘛推算這些無聊的二進位?尤其IP /Subnet表示法,為何不用「*」號等DNS hostname這樣直覺的表示法呢?發明人是否故意要考驗初學者的腦袋轉換速度?因此,我當時僅讀個概念,根本沒把背後所代表的深層知識理解。後來在研究所莊東穎老師教的「系統與網路」課程時接觸到它,當時仍用IP暴力AND運算法混過去,直到現在研究Proftpd的Class設定,必須針對連線來源IP的子網路作權限區別,才再次重新拆解這種表示法的概念。假如當時的書本寫得像這樣簡單明瞭,腦袋瓜子就容易吸收了...

在IPv4的協定下,IP位址是由4個8位元組成的數字來表達,如200.1.1.130。一個IP位址分為網路位址(Network Address)+主機位址(Host Address),依網路位址所佔的位元數不同而分為A/B/C/D級網路。IP數字的0及255是預設的主機及廣播位址無法使用,所以每個數字可用的 IP位址變化只有254個(256-2),這也就是一般C級網段的Gateway IP都預設x.x.x.254的緣故。IPv4的位址因為ABCD型網段的配法而無法完全應用到254四次方那樣多的可用IP值,隨著世界上主機數遞增,IP位址漸漸不夠用了!在IPv6的應用尚未完全普及之時,就得利用切分子網路(Subnet)的方式來有效分配IP位址。

某台網路主機,它的IP及子網路表示法為200.1.1.130/28,從這樣簡短的字句,你該立刻看出什麼呢?

1.子網路的遮罩位址為何?
該數字28是代表遮罩IP位址的網路位址所佔位元數,即:11111111.11111111.11111111.11110000,遮罩位元為1者是讓 IP通過(合法),0者為阻擋,所以從上述的32位元分布,我們得知它的網段型態是屬於C型位址,因此十進位的遮罩位址就是 255.255.255.240(只需要求算右邊那四個1),即 128 + 64 + 32 + 16 = 240

2.可切成幾個子網路?
數字1是讓IP通過,所以只要注意1的位元變化組合(因為後面的0怎麼變化都會被擋住),(1111)= 2^4 = 16,共有16種變化。

3.每個子網段有幾個IP值?
子網路ip數為 256/16 = 16 (有效IP為14,因為頭尾IP要去除)

4.每個子網路的IP起迄位址?
200.1.1.0-15,200.1.1.16-31,200.1.1.32-48,...,200.1.1.240-255
例如,主機IP為200.1.1.130/28的所在子網路起迄IP為: 130/16 = 8, 16 * 8 = 128,故在 200.1.1.128-143。

假如上述你都了解的話,讓我們反過來思考,用子網路IP起迄位址,反推出它的IP/Subnet表達格式?例如,我們要讓某C級網段(192.83.184.*)下的IP合法通過,這組子網路該怎麼用IP/Subnet格式表示呢?

首先,第四個IP值不遮封,因此遮罩IP位址的2進位是: 11111111.11111111.11111111.00000000 (255.255.255.0),其網路位址位元數共24個,因此寫法是: 192.83.184.0/24,依此類推,B級網段就是192.84.0.0/16,全部開放就是: 0.0.0.0/0。所以,從IP位址的二進位表示法的位元分布,就可看出其背後的隱藏資訊,只要您能了解這些概念就可直接看出來,不需再作 IP(192.83.184.0)轉二進位的運算(江湖一點訣)。
An Auto Installer for Integrating Apache 2.2 and Tomcat 6.0 for Clustering/Session Replication, Load Balancing with mod_jk 1.2 on CentOS 5.3
Author: Andowson Chang
Date: 2009.04.25
Modified: 2009.07.05 (Update the JDK new version's download URL)
2009.12.23 (Update Tomcat process stop status check method)
2010.01.04 (Update Tomcat's version information URL)
2010.04.14 (Update TOMCAT_VERSION and TOMCAT_CONNECTOR_VERSION and LOG4J_VERSION, remove install JDK section from the shell script)
2010.04.15 (Update Log4J version determination and use useradd -M for not create home directory for user tomcat)
2010.05.01 Add apr-devel for x86_64 support

Design:
1. One Apache and Two Tomcat workers on the same machine.
2. Use mod_jk for load balancer
3. Use mod_ssl for SSL
4. Enable cluster configuration on both Tomcat workers to do session replication
image

Steps:
1.Install CentOS 5.3 (disbale SELinux and Firewall)
2.Install JDK
3.Install Apache and mod_ssl
4.Generate SSL key and certificate
5.Edit httpd.conf
6.Edit ssl.conf
7.Install Tomcat, mod_jk
8.Edit server.xml
9.Edit mod_jk.conf
10.Edit workers.properties
11.Edit uriworkermap.properties
12.Start Apache and Tomcat

Testing:
1.Browsing http://<your_server_ip>/clustertest.jsp, add some keys and values.
2.Shutdown worker1
3.Browsing http://<your_server_ip>/clustertest.jsp, check if the keys and values are still there.
4.Run restart.sh
5.Browsing http://<your_server_ip>/clustertest.jsp, check if the keys and values are still there.
6.Browsing https://<your_server_ip>/clustertest.jsp, check if the keys and values are still there.

Implementation:
1.See http://www.howtoforge.com/perfect-server-centos-5.3-x86_64-ispconfig-2 for step1.
2.Install JDK(check http://java.sun.com for latest version)
#
# install JDK 6.0 Update 20
#
if [ ! -r jdk-6u20-linux-i586-rpm.bin ]; then
   wget "http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u20-linux-i586-rpm.bin?BundledLineItemUUID=PBGJ_hCwt5wAAAEopeNsZ47R&OrderID=_1CJ_hCwkZcAAAEoleNsZ47R&ProductID=guBIBe.oc_wAAAEnaDJHqPYe&FileName=/jdk-6u20-linux-i586-rpm.bin" -O jdk-6u20-linux-i586-rpm.bin
fi
echo 'yes'|sh jdk-6u20-linux-i586-rpm.bin

3.Create a directory /root/setup and download the auto installer script for step 3-11, save it as httpd2_tomcat6-setup.sh in /root/setup
mkdir -p /root/setup
then run it
chmod 755 /root/setup/httpd2_tomcat6-setup.sh
cd /root/setup
./httpd2_tomcat6-setup.sh

httpd2_tomca6-setup.sh:
#!/bin/bash
# Name: Apache 2.2.x && Tomcat 6.0.x auto installer
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 5.10
# Last Modified: 2010-05-01
# Source: http://www.andowson.com
# Assumption: JDK must be installed on /usr/java
# This program will
# 1.install httpd and mod_ssl
# 2.modify /etc/http/conf/httpd.conf
# 3.generate SSL key and a self-signed certificate
# 4.modify /etc/http/conf.d/ssl.conf
# 5.check for the lastest stable version of Tomcat 6.0.x
# 6.download apache-tomcat-6.0.x.tar.gz
# 7.unpack it into /var/apache-tomcat-6.0.x
# 8.make a symbolic link /var/tomcat6 to the above directory for easy upgrade
#   to a later version
# 9.check memory size to determine some JVM parameters
# 10.check for the latest stable verion of Tomcat Connector 1.2.x
# 11.download tomcat-connectors-1.2.x-src.tar.gz
# 12.unpack it
# 13.configure, make and make install
# 14.create user tomcat with home directory /var/tomcat6
# 15.make two instances of tomcat for load balancing, here I put them under 
#    /var/robust/worker[1,2] for easy to backup all of them.
# 16.setup default host directory(for testing)
# 17.generate server.xml
# 18.generate tomcat-users.xml
# 19.modify web.xml for production use
# 20.generate mod_jk.conf
# 21.generate workers.properties
# 22.generate uriworkermap.properties
# 23.generate tomcat startup script
# 24.modify web.xml for cluster test
# 25.generate clustertest.jsp for cluster test
# 26.generate cleanup.sh for easy to uninstall everything

#
# intranet workaround
# If your server don't have Internet access, ie. in the intranet behind 
# a firewall, you have to download all the files manually first. Copy them 
# into ${SETUP_DIR}. And then change the following default version 
# number to the correct number you have downloaded.
#
TOMCAT_VERSION=6.0.26
TOMCAT_CONNECTOR_VERSION=1.2.30
LOG4J_VERSION=1.2.16

#
# auto detect ip and hostname
#
ip=`/sbin/ifconfig|grep "inet addr"|awk '{print $2}'|cut -d":" -f2|head -1`
hostname=`/bin/hostname -f`

#
# adjustable parameters, you can modify any of them to fit your own need
#
DOMAIN=`/bin/hostname -d`
COUNTRY=TW
STATE=Taiwan
LOCATION=Taipei
COMPANY="Andowson Ltd."
ORGANIZATION=
HOSTNAME=${hostname}
hostname=${ip}
MIRROR_HOST=apache.ntu.edu.tw
CATALINA_HOME=/var/tomcat6
WORKER_ROOT=/var/robust
WEBAPP_ROOT=/var/webapps
SETUP_DIR=/root/setup/web
mkdir -p ${SETUP_DIR}
cd ${SETUP_DIR}
echo 'service tomcat stop' > ${SETUP_DIR}/cleanup.sh
echo 'service httpd stop' >> ${SETUP_DIR}/cleanup.sh

#
# install httpd and mod_ssl
#
yum -y install httpd mod_ssl
cp -rf /etc/httpd/conf/httpd.conf /tmp/httpd.conf
cp -rf /etc/httpd/conf.d/ssl.conf /tmp/ssl.conf

#
# modify httpd.conf
#
sed -i -e "44c\ServerTokens ProductOnly" \
-e "74c\KeepAlive On" \
-e "232c\Group tomcat" \
-e "251c\ServerAdmin webmaster@${DOMAIN}" \
-e "265a\ServerName 127.0.0.1:80" \
-e "281a\VirtualDocumentRoot /var/webapps/%0" \
-e "391c\DirectoryIndex sorry.html index.html index.htm default.html default.htm index.html.var index.jsp" \
-e '488a\LogFormat "%V %h %l %u %t \\"%r\\" %>s %b" vcommon' \
-e '488a\LogFormat "%V %h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" vcombined' \
-e '492c\LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\" %I %O" combinedio' \
-e "514c\CustomLog logs/access_log combinedio\nCustomLog logs/vhost.log vcombined" \
-e "524c\ServerSignature Off" \
-e "731c\LanguagePriority zh-TW en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN" \
-e "954a\<Location />" \
-e "954a\    # Insert filter" \
-e "954a\    SetOutputFilter DEFLATE\n" \
-e "954a\    # Netscape 4.x has some problems..." \
-e "954a\    BrowserMatch ^Mozilla/4 gzip-only-text/html\n" \
-e "954a\    # Netscape 4.06-4.08 have some more problems" \
-e '954a\    BrowserMatch ^Mozilla/4\\.0[678] no-gzip\n' \
-e "954a\    # MSIE masquerades as Netscape, but it is fine" \
-e '954a\    # BrowserMatch \\bMSIE \!no-gzip \!gzip-only-text/html\n' \
-e "954a\    # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48" \
-e "954a\    # the above regex won't work. You can use the following" \
-e "954a\    # workaround to get the desired effect:" \
-e '954a\    BrowserMatch \\bMSI[E] \!no-gzip \!gzip-only-text/html\n' \
-e "954a\    # Don't compress images" \
-e '954a\    SetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png)$ no-gzip dont-vary\n' \
-e "954a\    # Make sure proxies don't deliver the wrong content" \
-e "954a\    Header append Vary User-Agent env=\!dont-vary" \
-e "954a\</Location>\n"  \
-e "954a\RewriteEngine on" \
-e "954a\RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)" \
-e "954a\RewriteRule .* - [F]\n" /etc/httpd/conf/httpd.conf
echo 'cp -rf /tmp/httpd.conf /etc/httpd/conf/httpd.conf' >> ${SETUP_DIR}/cleanup.sh

#
# generate SSL key and cert
#
openssl genrsa -out /etc/pki/tls/private/${HOSTNAME}.key 2048
openssl req -new -key /etc/pki/tls/private/${HOSTNAME}.key -out /etc/pki/tls/certs/${HOSTNAME}.csr -subj "/C=${COUNTRY}/ST=${STATE}/L=${LOCATION}/O=${COMPANY}/OU=${ORGANIZATION}/CN=${HOSTNAME}"
openssl x509 -req -days 3650 -in /etc/pki/tls/certs/${HOSTNAME}.csr -signkey /etc/pki/tls/private/${HOSTNAME}.key -out /etc/pki/tls/certs/${HOSTNAME}.crt
echo 'rm -rf /etc/pki/tls/private/'${HOSTNAME}'.key' >> ${SETUP_DIR}/cleanup.sh
echo 'rm -rf /etc/pki/tls/certs/'${HOSTNAME}'.csr' >> ${SETUP_DIR}/cleanup.sh
echo 'rm -rf /etc/pki/tls/certs/'${HOSTNAME}'.crt' >> ${SETUP_DIR}/cleanup.sh

#
# modify ssl.conf
#
sed -i -e "86a\JkMountFile conf/uriworkermap.properties\n" \
-e "112c\SSLCertificateFile /etc/pki/tls/certs/${HOSTNAME}.crt" \
-e "119c\SSLCertificateKeyFile /etc/pki/tls/private/${HOSTNAME}.key" /etc/httpd/conf.d/ssl.conf
echo 'cp -rf /tmp/ssl.conf /etc/httpd/conf.d/ssl.conf' >> ${SETUP_DIR}/cleanup.sh

chkconfig --level 235 httpd on
echo 'chkconfig httpd off' >> ${SETUP_DIR}/cleanup.sh

#
# check the latest stable version of Tomcat 6.0.x
#
wget http://tomcat.apache.org/whichversion.html -q -t 1 -T 5 -O /tmp/tomcat.html
if [ -s /tmp/tomcat.html ]; then
   TOMCAT_VERSION=`grep "6\.0\." /tmp/tomcat.html|grep -v "6\.0\.x"|cut -d">" -f2|cut -d"<" -f1`
fi
rm -rf /tmp/tomcat.html

echo "Install Tomcat ${TOMCAT_VERSION}"
if [ ! -r apache-tomcat-${TOMCAT_VERSION}.tar.gz ]; then
   wget http://${MIRROR_HOST}/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz
fi
tar zxvf apache-tomcat-${TOMCAT_VERSION}.tar.gz -C /var
ln -s /var/apache-tomcat-${TOMCAT_VERSION} ${CATALINA_HOME}

echo 'rm -rf /var/apache-tomcat-'${TOMCAT_VERSION} >> ${SETUP_DIR}/cleanup.sh
echo 'rm -rf '${CATALINA_HOME} >> ${SETUP_DIR}/cleanup.sh

#
# check memory size to determine some JVM parameters
#
mem=`cat /proc/meminfo|grep "MemTotal:"|awk '{print $2}'`
let KB=1024
let memsize=$mem/$KB
let heapsize=$memsize/2
let newsize=$heapsize/4
echo 'JAVA_HOME="/usr/java/latest"
JAVA_OPTS="-server -XX:NewSize='${newsize}'m -XX:MaxNewSize='${newsize}'m -XX:SurvivorRatio=8 -XX:MaxPermSize=128m -Xss256k -Xms'${heapsize}'m -Xmx'${heapsize}'m -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true"' > ${CATALINA_HOME}/bin/setenv.sh
chmod 755 ${CATALINA_HOME}/bin/setenv.sh

#
# check the latest stable version of Tomcat Connector 1.2.x
#
# pre-requirment
yum -y install httpd-devel apr-devel libtool automake make gcc gcc-c++

wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html
if [ -s /tmp/connector.html ]; then
   TOMCAT_CONNECTOR_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d">" -f2|cut -d"<" -f1 |awk '{print $2}'|grep "1.2"|uniq`
fi
rm -rf /tmp/connector.html
echo "Install Tomcat Connector JK ${TOMCAT_CONNECTOR_VERSION}"
if [ ! -r tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz ]; then
   wget http://${MIRROR_HOST}/tomcat/tomcat-connectors/jk/source/jk-${TOMCAT_CONNECTOR_VERSION}/tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz
fi
tar zxvf tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz
cd tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src/native
./buildconf.sh
./configure --with-apxs=/usr/sbin/apxs
make
make install
cd ${SETUP_DIR}
echo 'rm -rf /etc/httpd/modules/mod_jk.so' >> ${SETUP_DIR}/cleanup.sh

#
# check the latest stable version of Log4J
#
wget http://logging.apache.org/log4j/1.2/download.html -q -t 1 -T 5 -O /tmp/log4j.html
if [ -s /tmp/log4j.html ]; then
   LOG4J_VERSION=`grep "1\.2\." /tmp/log4j.html|cut -d"<" -f3|cut -d">" -f2|awk '{print $4}'|head -1`
fi
rm -rf /tmp/log4j.html
echo "Install Log4J ${LOG4J_VERSION}"
if [ ! -r apache-log4j-${LOG4J_VERSION}.tar.gz ]; then
   wget http://${MIRROR_HOST}/logging/log4j/${LOG4J_VERSION}/apache-log4j-${LOG4J_VERSION}.tar.gz
fi
tar zxvf apache-log4j-${LOG4J_VERSION}.tar.gz
cp -rf ${SETUP_DIR}/apache-log4j-${LOG4J_VERSION}/log4j-${LOG4J_VERSION}.jar ${CATALINA_HOME}/lib

#
# replace tomcat-juli.jar and add tomcat-juli-adapters.jar for log4j
#
if [ ! -r tomcat-juli.jar ]; then
   wget http://${MIRROR_HOST}/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/extras/tomcat-juli.jar
fi
cp -rf tomcat-juli.jar ${CATALINA_HOME}/bin
if [ ! -r tomcat-juli-adapters.jar ]; then
   wget http://${MIRROR_HOST}/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/extras/tomcat-juli-adapters.jar 
fi
cp -rf tomcat-juli-adapters.jar ${CATALINA_HOME}/lib

#
# generate log4j.properties
#
echo 'log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.logger.org.apache.catalina=INFO, R' > ${CATALINA_HOME}/lib/log4j.properties

#
# add user tomcat
#
groupadd -g 80 tomcat
useradd tomcat -u 80 -g tomcat -d ${CATALINA_HOME}
echo 'userdel -r tomcat' >> ${SETUP_DIR}/cleanup.sh
echo 'groupdel tomcat' >> ${SETUP_DIR}/cleanup.sh

#
# setup workers' directory
#
mkdir -p ${WORKER_ROOT}/logs
mkdir -p ${WORKER_ROOT}/worker1/logs
mkdir -p ${WORKER_ROOT}/worker1/temp
mkdir -p ${WORKER_ROOT}/worker1/work
cp -rf ${CATALINA_HOME}/conf ${WORKER_ROOT}/worker1/conf
mkdir -p ${WEBAPP_ROOT}
ln -s ${WEBAPP_ROOT} ${WORKER_ROOT}/worker1/webapps
cp -rf ${WORKER_ROOT}/worker1 ${WORKER_ROOT}/worker2
echo 'rm -rf '${WEBAPP_ROOT} >> ${SETUP_DIR}/cleanup.sh

#
# setup default host directory
#
mkdir -p ${WEBAPP_ROOT}/${hostname}
cp -rf ${CATALINA_HOME}/webapps/ROOT/* ${WEBAPP_ROOT}/${hostname}/.
mkdir -p ${WORKER_ROOT}/worker1/conf/Catalina/${hostname}
mkdir -p ${WORKER_ROOT}/worker2/conf/Catalina/${hostname}
cp -rf ${CATALINA_HOME}/webapps/host-manager/manager.xml ${WORKER_ROOT}/worker1/conf/Catalina/${hostname}
cp -rf ${CATALINA_HOME}/webapps/host-manager/manager.xml ${WORKER_ROOT}/worker2/conf/Catalina/${hostname}

#
# generate server.xml
#
echo '<?xml version="1.0" encoding="utf-8"?>
<Server port="workerPort" shutdown="shutdownCode">

  <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <!-- Define an AJP 1.3 Connector on port ajpPort -->
    <Connector port="ajpPort" address="127.0.0.1"
               enableLookups="false" maxThreads="1000" connectionTimeout="3000"
               protocol="AJP/1.3" />

    <Engine name="Catalina" defaultHost="mydomain" jvmRoute="workerNo">
    
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase" />
' > /tmp/server.header.template

sed -e "s/workerPort/8105/g" -e "s/shutdownCode/`head -1024c /dev/urandom | md5sum | cut -d " " -f1`/g" -e "s/ajpPort/8109/g" -e "s/workerNo/worker1/g" -e "s/mydomain/${hostname}/g" /tmp/server.header.template > ${WORKER_ROOT}/worker1/conf/server.header
sed -e "s/workerPort/8205/g" -e "s/shutdownCode/`head -1024c /dev/urandom | md5sum | cut -d " " -f1`/g" -e "s/ajpPort/8209/g" -e "s/workerNo/worker2/g" -e "s/mydomain/${hostname}/g" /tmp/server.header.template > ${WORKER_ROOT}/worker2/conf/server.header
rm -rf /tmp/server.header.template

echo '      <Host name="'${hostname}'" appBase="webapps/'${hostname}'"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve"
               directory="logs" prefix="'${hostname}'_access_log." suffix=".txt" 
               pattern="combined" resolveHosts="false"/>
        <Context path="" docBase="" reloadable="false" />
      </Host>' > ${WORKER_ROOT}/worker1/conf/server.host

cp -rf ${WORKER_ROOT}/worker1/conf/server.host ${WORKER_ROOT}/worker2/conf/server.host

echo '    </Engine>
  </Service>
</Server>' > ${WORKER_ROOT}/worker1/conf/server.footer

cp -rf ${WORKER_ROOT}/worker1/conf/server.footer ${WORKER_ROOT}/worker2/conf/server.footer

cd ${WORKER_ROOT}/worker1/conf
cat server.header server.host server.footer > server.xml
cd ${WORKER_ROOT}/worker2/conf
cat server.header server.host server.footer > server.xml

#
# generate tomcat-users.xml
#
MANAGER_PASSWORD=`head -1024c /dev/urandom | md5sum | cut -d " " -f1 | awk '{print substr($1,1,8)}'`
echo '<tomcat-users>
  <user username="manager" password="'${MANAGER_PASSWORD}'" roles="manager"/>
</tomcat-users>' > ${WORKER_ROOT}/worker1/conf/tomcat-users.xml
echo
echo "Your Tomcat Manager's login is 'manager', password is '${MANAGER_PASSWORD}'"
echo
cp -rf ${WORKER_ROOT}/worker1/conf/tomcat-users.xml ${WORKER_ROOT}/worker2/conf/tomcat-users.xml

#
# modify web.xml for production use
#
sed -i -e "97a\        <init-param>\n            <param-name>readonly</param-name>\n            <param-value>true</param-value>\n        </init-param>" \
-e "246a\        <init-param>\n            <param-name>genStringAsCharArray</param-name>\n            <param-value>true</param-value>\n        </init-param>" \
-e "246a\        <init-param>\n            <param-name>trimSpaces</param-name>\n            <param-value>true</param-value>\n        </init-param>" ${WORKER_ROOT}/worker1/conf/web.xml
cp -rf ${WORKER_ROOT}/worker1/conf/web.xml ${WORKER_ROOT}/worker2/conf/web.xml

chmod 600 ${WORKER_ROOT}/worker*/conf/server.*
chmod 600 ${WORKER_ROOT}/worker*/conf/tomcat-users.xml
chown -R tomcat:tomcat /var/apache-tomcat-*
chown -R tomcat:tomcat ${WORKER_ROOT}

#
# generate mod_jk.conf
#
echo 'LoadModule jk_module modules/mod_jk.so

JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile     logs/jk-runtime-status
JkLogFile     "|/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 86400"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkRequestLogFormat     "%w %V %T"
LogFormat     "%h %l %u %t \"%r\" %>s %b %{JK_WORKER_NAME}n %{JK_LB_FIRST_NAME}n %{JK_LB_FIRST_BUSY}n %{JK_LB_LAST_NAME}n %{JK_LB_LAST_BUSY}n" mod_jk_log
CustomLog     logs/worker_access_log     mod_jk_log

# Load mount points
JkMountFile conf/uriworkermap.properties

# Deny direct access to WEB-INF
<LocationMatch ".*WEB-INF.*">
    deny from all
</LocationMatch>' > /etc/httpd/conf.d/mod_jk.conf
echo 'rm -rf /etc/httpd/conf.d/mod_jk.conf' >> ${SETUP_DIR}/cleanup.sh

#
# generate workers.properties
#
echo '# workers.properties - ajp13
#
# List workers
#
worker.list=loadbalancer, jkstatus

#
# Define worker1
#
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8109
worker.worker1.socket_timeout=1200
worker.worker1.connection_pool_size=1
worker.worker1.connection_pool_timeout=1300
worker.worker1.lbfactor=1
# Define prefered failover node for worker1
worker.worker1.redirect=worker2

#
# Define worker2
#
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8209
worker.worker2.socket_timeout=1200
worker.worker2.connection_pool_size=1
worker.worker2.connection_pool_timeout=1300
worker.worker2.lbfactor=1
# Disable worker2 for all requests except failover
worker.worker2.activation=d

#
# Defining a load balancer
#
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1, worker2

#
# Define status worker
#
worker.jkstatus.type=status' > /etc/httpd/conf/workers.properties
echo 'rm -rf /etc/httpd/conf/workers.properties' >> ${SETUP_DIR}/cleanup.sh

#
# generate uriworkermap.properties
#
echo '/jkmanager/*=jkstatus
/*.jsp=loadbalancer
/*.do=loadbalancer
/*.page=loadbalancer
/dwr/*=loadbalancer
/servlet/*=loadbalancer
/manager/*=loadbalancer' > /etc/httpd/conf/uriworkermap.properties
echo 'rm -rf /etc/httpd/conf/uriworkermap.properties' >> ${SETUP_DIR}/cleanup.sh

#
# generate tomcat startup script
#
echo '#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: - 84 16
# description: Tomcat Servlet Engine
# processname: tomcat
# pidfile: /var/run/worker1.pid /var/run/worker2.pid

# Source function library.
. /etc/rc.d/init.d/functions

# User under which tomcat will run
TOMCAT_USER=tomcat

RETVAL=0

CATALINA_HOME='${CATALINA_HOME}'
WORKER_ROOT='${WORKER_ROOT}'
WORKER_LIST=( worker1 worker2 )
WORKER_PORT=( 8105 8205 )

# start, debug, stop, and status functions
start() {
    i=$1
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
    if [ $SHUTDOWN_PORT -ne 0 ]; then
        echo "Tomcat ${WORKER_LIST[i]} already started"
    else
        echo "Starting tomcat ${WORKER_LIST[i]}..."
        CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}"
        chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME
        chown -R $TOMCAT_USER:$TOMCAT_USER $WORKER_ROOT
        su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/startup.sh"
        SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
        while [ $SHUTDOWN_PORT -eq 0 ]; do
            sleep 1
            SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
        done
        echo "Tomcat ${WORKER_LIST[i]} started in normal mode"
        RETVAL=$?
        [ $RETVAL = 0 ] && touch /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid
    fi
}

debug() {
    i=$1
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
    if [ $SHUTDOWN_PORT -ne 0 ]; then
        echo "Tomcat ${WORKER_LIST[i]} already started"
    else
        echo "Starting tomcat ${WORKER_LIST[i]} in debug mode..."
        CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}"
        rm -rf $CATALINA_BASE/work/*

        chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME
        chown -R $TOMCAT_USER:$TOMCAT_USER $WORKER_ROOT
        su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/catalina.sh jpda start"
        SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
        while [ $SHUTDOWN_PORT -eq 0 ]; do
            sleep 1
            SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
        done
        echo "Tomcat ${WORKER_LIST[i]} started in debug mode"
        RETVAL=$?
        [ $RETVAL = 0 ] && touch /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid
    fi
}

stop() {
    i=$1
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
    if [ $SHUTDOWN_PORT -eq 0 ]; then
        echo "Tomcat ${WORKER_LIST[i]} already stopped"
    else
        echo "Stopping tomcat ${WORKER_LIST[i]} ..."
        CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}"
        su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/shutdown.sh"
        SHUTDOWN_PORT=`ps -ef|grep ${WORKER_LIST[i]}|grep -v grep|wc -l`
        while [ $SHUTDOWN_PORT -ne 0 ]; do
            sleep 1
            SHUTDOWN_PORT=`ps -ef|grep ${WORKER_LIST[i]}|grep -v grep|wc -l`
        done
        echo "Tomcat ${WORKER_LIST[i]} stopped"
        RETVAL=$?
        [ $RETVAL=0 ] && rm -f /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid
    fi
}

status() {
  for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
  do
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
    if [ $SHUTDOWN_PORT -eq 0 ]; then
        echo "Tomcat ${WORKER_LIST[i]} stopped"
    else
        MODE="normal"
        JPDA_PORT=`netstat -vatn|grep LISTEN|grep 8000|wc -l`
        if [ $JPDA_PORT -ne 0 ]; then
            MODE="debug"
        fi
        echo "Tomcat ${WORKER_LIST[i]} running in $MODE mode"
    fi
  done
}

case "$1" in
  start)
        start 0
        start 1
        ;;
  debug)
        debug 0
        debug 1
        ;;
  stop)
        stop 0
        stop 1
        ;;
  restart)
        stop 0
        start 0
        stop 1
        start 1
        ;;
  redebug)
        stop 0
        debug 0
        stop 1
        debug 1
        ;;
  status)
  	status
	;;
  *)
	echo "Usage: $0 {start|debug|stop|restart|redebug|status}"
	exit 1
esac

exit $RETVAL' > /etc/rc.d/init.d/tomcat

chmod 755 /etc/rc.d/init.d/tomcat
chkconfig --add tomcat
chkconfig --level 235 tomcat on

echo 'chkconfig tomcat off' >> ${SETUP_DIR}/cleanup.sh
echo 'chkconfig --del tomcat' >> ${SETUP_DIR}/cleanup.sh
echo 'rm -rf /etc/rc.d/init.d/tomcat' >> ${SETUP_DIR}/cleanup.sh

chmod 755 ${SETUP_DIR}/cleanup.sh

echo 'Tomcat installation is completed!'
echo
echo 'You can type "service tomcat start" to start using tomcat now.'
echo 'You can type "service httpd start" to start using apache now.'
echo 'Open a browser, and go to http://'${hostname}' to see it.'

#
# modify web.xml for cluster test
#
sed -i -e "27a\  <distributable/>" ${WEBAPP_ROOT}/${hostname}/WEB-INF/web.xml

#
# generate clustertest.jsp for cluster test
#
echo '<%@ page contentType="text/html; charset=UTF-8" import="java.util.*"%>
<html>
<head>
<title>Cluster Session Replication Test</title>
</head>
<body>
<%
    out.println("Session ID=" + session.getId() + "<br>");
 
    String key = request.getParameter("key");
    if (key != null && key.length() > 0) {
        String value = request.getParameter("value");
        session.setAttribute(key, value);
    }
 
    out.println("<b>Session Listing</b><br>");
 
    Enumeration e = session.getAttributeNames();
    while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        String value = (String)session.getAttribute(name);
        out.println(name + " = " + value + "<br>");
    }
%>

  <form method="post">
    key:<input type="text" size="20" name="key"> <br>
    value:<input type="text" size="20" name="value"> <br>
    <input type="submit">
  </form>
</body>
</html>' > ${WEBAPP_ROOT}/${hostname}/clustertest.jsp


4.Then you can use the following two commands to do step12
service tomcat start
service httpd start
5. For testing, you can use the following command to shutdown or startup a single Tomcat worker:
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker1; /var/tomcat6/bin/shutdown.sh"
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker1; /var/tomcat6/bin/startup.sh"
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker2; /var/tomcat6/bin/shutdown.sh"
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker2; /var/tomcat6/bin/startup.sh"

Or you may use a shell script to restart Tomcat repeatedly to verify if the session replication really works.
restart.sh
 for (( i = 0 ; i < 10 ; i++ ))
  do
     service tomcat restart
  done


If you can see all of the session objects no matter how Tomcat is restarted, then Tomcat clustering(session replication) is done.

Note: If you have enabled firewall like iptables, please add 45564:udp port to the allowed list.

6. Finally, browse https://<your_server_ip>/ to check SSL works. You have to add this site as your trust site because we use a self-signed SSL certificate.

Reference:
http://tomcat.apache.org/connectors-doc/reference/apache.html
http://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.html
http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/logging.html
http://www.easywayserver.com/implementation-tomcat-clustering.htm
1.Exam type: Multiple choice and drag and drop=>SCJP6的考試跟SCJP5一樣,除了選擇題外還有拖曳題(填充題),選擇題的答案在檢查時還會保留,但拖曳題的答案在檢查時會清空,所以如果可以的話,盡量一次作對拖曳題或者把答案記下來(如果您的考試中心有提供白紙的話)。
2.這兩本書都是對考試通過有幫助的書,如果只有看猛虎出閘,則因觀念說明比較精簡,可能最多只能回答後面的180題考題。如果您參考考試只是為了拿到證照,建議您把這180題的題目跟答案背下來,然後去考試,只要再多猜對幾題證照就可以到手。如果您希望高分通過,建議您一定得看一下另一本書。
3.Sun Certified Java Programmer (SCJP)是資訊專業技能的國際認證(由國際大廠自己推出的認證考試)之一。由於企業普遍採用一些大廠的產品,例如微軟(Microsoft)、甲骨文(Oracle)、昇陽(Sun)、思科(Cisco)和紅帽(Red Hat),為了維持各種系統的正常運作,就需要熟悉這些產品的專業人士來操作或維運它們。這些大廠就推出專業的訓練課程搭配標準化的測驗機制,形成一種專業能力的證明。因此對老闆來說,有證照的人會比沒證照的人來得可靠,所以當有職缺時有相關證照的會比較容易找到工作。
OLAT是用Java語言開發的LMS,支援UTF-8編碼,因此您可以輸入中文課程名稱,並能正常顯示。需要注意的是,教材內容如果有中文字元需要用UTF-8編碼才能正常顯示。
 
Forum Index » Profile for andowson » Messages posted by andowson
Go to:   

交換連結乌托邦博客 
在本站刊登廣告
練功房推薦書單
SCJP 6.0認證教戰手冊 (附光碟) 雲端策略:雲端運算與虛擬化技術 SCJP Java 6專業認證手冊 Java認證SCJP 6.0/5.0--猛虎出閘 SCWCD 5 猛虎出閘:Java Web 應用程式專業認證 SCWCD專業認證手冊 Head First Servlets and JSP
[版權說明] 本站授權方式:創用CC 姓名標示-非商業性-相同方式分享 3.0 台灣 授權條款
Creative Commons License
Powered by JForum 2.2.0 © JForum Team