tomcatjavascript
./configure --prefix=/usr/local/aprjava
make && make installlinux
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprweb
make && make installapache
./configure --prefix=/data/apache --enable-rewrite --enable-so --with-apr=/data/app/apr --with-apr-util=/data/app/apr-util --with-pcre=/data/app/pcrevim
make && make installtomcat
./configure --prefix=/usr/local/pcresession
make && make installapp
tar -zxvf tomcat-connectors-1.2.32-src.tar.gzdom
cd tomcat-connectors-1.2.32-src/native
./buildconf.sh
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=$JAVA_HOME --with-java-platform=2 --enable-jni
make && make install
若是成功結束,你能夠在/usr/local/apache/modules/下找到mod_jk.so文件。
tar zxvf 包
vim conf/httpd.conf
LoadModule jk_module modules/mod_jk-1.2.26-httpd-2.2.4.so //表示載入JK模塊
JkWorkersFile conf/workers.properties //tomcat實例配置
JkMount /* controller //設置apache分發器,/*表示apache將全部文件都由分發器controller 進行分發,你能夠自行設置*.jsp,*.do等
vim conf/ workers.properties
worker.list=controller
#Tomcat1實例配置
worker.tomcat80.host=10.71.144.80
worker.tomcat80.port=8009 //ajp的端口
worker.tomcat80.type=ajp13
# 分發權重 值越大負載越大
worker.tomcat1.lbfactor = 1
#Tomcat2實例配置
worker.tomcat81.host=10.71.144.81
worker.tomcat81.port=8009
worker.tomcat81.type=ajp13
# 分發權重 值越大負載越大
worker.tomcat81.lbfactor = 1
worker.lbcontroller.type=lb
worker.lbcontroller.balance_workers=tomcat80,tomcat81,tomcat82
worker.lbcontroller.sticky_session=True
這裏就是tomcat80和tomcat82必須與以後tomcat中的server.xml中jvmRoute值一致
vim conf/server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat35">
……
<Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">
<Manager
className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
<Channel
className="org.apache.catalina.tribes.group.GroupChannel">
<Membership
className="org.apache.catalina.tribes.membership.McastServi
ce"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver
className="org.apache.catalina.tribes.transport.nio.NioRece
iver"
address="auto"
port="4000"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>
<Sender
className="org.apache.catalina.tribes.transport.Replication
Transmitter">
<Transport
className="org.apache.catalina.tribes.transport.nio.Poole
dParallelSender"/>
</Sender>
<Interceptor
className="org.apache.catalina.tribes.group.interceptors.Tc
pFailureDetector"/>
<Interceptor
className="org.apache.catalina.tribes.group.interceptors.Me
ssageDispatch15Interceptor"/>
</Channel>
<Valve
className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=""/>
<Valve
className="org.apache.catalina.ha.session.JvmRouteBinderValve
"/>
<Deployer
className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener
className="org.apache.catalina.ha.session.JvmRouteSessionIDBi
nderListener"/>
<ClusterListener
className="org.apache.catalina.ha.session.ClusterSessionListe
ner"/>
</Cluster>
tomcat集羣中的 session管理,主要有兩種方式:
1).粘性session
表示從同一窗口發來的請求都將有集羣中的同一個tomcat進行處理。配 置方式是在上面workers.properties文件中
worker.lbcontroller.sticky_session=True
粘性session的好處在不會在不一樣的tomcat上來回跳動處理請求,可是壞處是若是處理該session的tomcat崩潰,那麼以後 的請求將由其餘tomcat處理,原有session失效而從新新建一個新的session,這樣若是繼續從session取值,會拋出 nullpointer的訪問異常。
2).session複製
session複製是指tomcat彼此之間經過組播方式將session 發到各個tomcat實例上,若是其中一個訪問出錯,則另外tomcat仍然具備有效的session內容,從而能正常接管其session。壞處是當 tomcat實例不少,或者用戶在session中有大量操做時,組播發送的信息量十分驚人。session複製配置則是在發佈的web應用程序中的 web.xml中添加
<distributable/>
此外,session複製所需的JDK必須是JDK 5.0及其以上版本
注:單機部署多個tomcat須要改端口
……/apache/bin/apachectl start
……/apache/bin/apachectl stop 關閉
……/tomcat-xxx/bin/startup.sh
……/tomcat-xxx/bin/shutup.sh 關閉
問題:
configure: error: APR not found. Please read the documentation
解決:
安裝apr apr-util
問題:
執行make命令時報錯
xml/apr_xml.c:35:19: error: expat.h: No such file or directory
……
make[1]: * [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/Downloads/apache_svn/apr-util-1.6.0'
make: * [all-recursive] Error 1
解決:
yum install expat-devel
問題:
編譯APR包的時候,在執行configure可能會出現 rm: cannot remove `libtoolT': No such file or directory
解決:
編輯configure這個文件,將 $RM 「$cfgfile」 那行註釋掉 ,而後從新編譯便可。
問題:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.58.135. Set the 'ServerName' directive globally to suppress this message
vim .../apache/conf/httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
這個主要是記錄tomcat啓動時候的信息,相似於咱們在eclipse中啓動服務的時候在控制檯看到的信息。在裏面能夠看到啓動的JVM參數以及操做系統等日誌信息。若是沒有使用log4j等日誌機制,系統的的錯誤信息與打印語句也在這個日誌文件中記錄。(linux下全部的日誌都在catalina.out中)
這個日期放的估計是利用服務方式啓動tomcat做爲守護進程的日誌記錄,由於個人tomcat啓動方式是以服務的方式啓動的,索引產生這個日誌文件記錄了服務的啓動狀態。
這個估計是放tomcat的自帶的manager項目的日誌信息的,也沒有看到有什麼重要的日誌信息
這個相似於第一種日誌,但是信息沒有第一種全
這個是存放訪問tomcat的請求的全部地址以及請求的路徑、時間,請求協議以及返回碼等信息(重要)
這個估計也是manager項目專有的日誌文件,看不出有什麼重要的信息
這個是log4j的錯誤日誌,所以在程序中要合理的捕捉異常。
相似於eclipse的控制檯的信息
這個是程序中的System語句打印的日誌(包括系統拋出的異常),也終於明白了爲何一再強調不能用打印語句進行系統調試