tomcat集群

1】 下載安裝

?????? httpd-2.2.15-win32-x86-no_ssl.msi ?? 網頁服務器

?????? 32-bit Windows zip??????????????????????????? tomcat

?????? mod_jk-1.2.30-httpd-2.2.3.so ??????????? Apache/IIS 用來連接后臺Tomcat的模塊,支持集群和負載均衡

?????? JK 分為兩個版本 1,x 和 2.x ,其中 2.x 并不是最新的版本,它是 JK 的另外一個分支,后不知何因沒有繼續開發,因此2.x 版本已經廢棄

?????? 安裝httpd-2.2.15-win32-x86-no_ssl.msi 到指定目錄,我安裝的是C:\Program Files\Apache2.2,以后這個目錄將用Apache_Home代替

?????? 安裝tomcat,我是將兩個tomcat進行集群,所以安裝兩個tomcat,路徑分別為:F:\tomcat\tomcat1,F:\tomcat\tomcat2,以后這兩個目錄將用tomcat1_Home,tomcat2_Home代替

2】 配置Apache_Home\conf\httpd.conf

????? 在httpd.conf文件的最后一行寫入include "C:\Program Files\Apache2.2\conf\mod_jk.conf"

3】 配置mod_jk.conf文件

????? 在Apache_Home\conf下建立mod_jk.conf文件

????? 配置內容:

????? #加載mod_jk Module
???????? LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.3.so

???????? 將下載的 mod_jk-1.2.30-httpd-2.2.3.so 文件放入到Apache_Home\modules下
????? # 配置 mod_jk
????? #加載集群中的workers
???????? JkWorkersFile conf/workers.properties
????? #加載workers的請求處理分配文件
???????? JkMountFile conf/uriworkermap.properties
??? ? #指定jk的日志輸出文件
???????? JkLogFile logs/mod_jk.log
????? #指定日志級別
???????? JkLogLevel warn
???? #指定哪些請求交給tomcat處理,"controller"為在 workers.propertise里指定的負載分配控制器名
???????? JkMount /* controller

4】? 配置workers.propertise文件

?????? 在Apache_Home\conf下建立workers.propertise文件

?????? 配置內容:

?????? #server 列表
???????? worker.list=controller,tomcat1,tomcat2
????? #========tomcat1========
????? #ajp13 端口號,在tomcat下server.xml配置,默認8009
??????? worker.tomcat1.port=8009
????? #tomcat的主機地址,如不為本機,請填寫ip地址
??????? worker.tomcat1.host=localhost
??????? worker.tomcat1.type=ajp13
???? #server的加權比重,值越高,分得的請求越多
??????? worker.tomcat1.lbfactor=1
???? #========tomcat2========
???? #ajp13 端口號,在tomcat下server.xml配置,默認8009
?????? worker.tomcat2.port=9009
???? #tomcat的主機地址,如不為本機,請填寫ip地址
????? worker.tomcat2.host=localhost
????? worker.tomcat2.type=ajp13
??? #server的加權比重,值越高,分得的請求越多
?????? worker.tomcat2.lbfactor=1
??? #========controller,負載均衡控制器========
??? #server名為controller,用于負載均衡
????? worker.controller.type=lb
?? #重試次數
????? worker.retries=3
?? #指定分擔請求的tomcat
???? worker.controller.balanced_workers=tomcat1,tomcat2
?? #粘性Session(默認是打開的) 當該屬性值=True(或1)時,代表Session是粘性的,即同一Session在集群中的同一個節點上處理,Session不跨越節點。在集群環境中,一般將該值設置為False
???? worker.controller.sticky_session=false
? #設置用于負載均衡的server的session可否共享 有不少文章說設置為1是可以的,也有設置為0才可以的
???? worker.controller.sticky_session=1
? #worker.controller.sticky_session_force=1
? #worker.status.type=status

5】 配置uriworkermap.properties文件

????? 在Apache_Home\conf下建立uriworkermap.properties文件

????? 配置內容:

???? #所有請求都由controller這個server處理
???? /*=controller
???? #所有包含jkstatus請求的都由status這個 server處理
???? #/jkstatus=status
???? #這里的"!”是“非”的意思。
???? !/*.gif=controller
???? !/*.jpg=controller
???? !/*.png=controller
???? !/*.css=controller
???? !/*.js=controller
???? !/*.htm=controller
???? !/*.html=controller

6】修改tomcat1_Home\conf\server.xml配置

????? Starting Coyote HTTP/1.1 on http-8081 默認端口為8080,修改為8081

???? <Connector port="8081" protocol="HTTP/1.1"
?????????????? connectionTimeout="20000"
?????????????? redirectPort="8443" />

????? JK: ajp13 listening on /0.0.0.0:8009 修改端口必須與workers.propertise文件內worker.tomcat1.port=8009一致

???? <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

???? 需要添加的內容:

??? <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2"> ? <!--tomcat1將與tomcat2黏貼session 在這里指定黏貼對象-->

????? <!--For clustering, please take a look at documentation at:
????????? /docs/cluster-howto.html? (simple how to)
????????? /docs/config/cluster.html (reference documentation) -->
????? <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.McastService"
??????????????????????? address="228.0.0.4"
??????????????????????? port="45564"
??????????????????????? frequency="500"
??????????????????????? dropTime="3000"/>
??????????? <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
????????????????????? address="auto"
????????????????????? port="4000" ?
????????????????????? autoBind="100"
????????????????????? selectorTimeout="5000"
????????????????????? maxThreads="6"/>

??????????? <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
????????????? <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
??????????? </Sender>
??????????? <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
??????????? <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
????????? </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.JvmRouteSessionIDBinderListener"/>
????????? <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
??????? </Cluster>???

????? 上面部分如果需要詳細的說明可以看webapps\docs\cluster-howto.html

7】修改tomcat2_Home\conf\server.xml配置

????? Starting Coyote HTTP/1.1 on http-8082 默認端口為8080,修改為8082

???? <Connector port="8082" protocol="HTTP/1.1"
?????????????? connectionTimeout="20000"
?????????????? redirectPort="8443" />

????? JK: ajp13 listening on /0.0.0.0:9009 修改端口必須與workers.propertise文件內worker.tomcat2.port=9009一致

???? <Connector port="9009" protocol="AJP/1.3" redirectPort="8443" />

???? 需要添加的內容:

??? <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"> ? <!--tomcat2將與tomcat1黏貼session 在這里指定黏貼對象-->

????? <!--For clustering, please take a look at documentation at:
????????? /docs/cluster-howto.html? (simple how to)
????????? /docs/config/cluster.html (reference documentation) -->
????? <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.McastService"
??????????????????????? address="228.0.0.4"
??????????????????????? port="45564"
??????????????????????? frequency="500"
??????????????????????? dropTime="3000"/>
??????????? <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
????????????????????? address="auto"
????????????????????? port="4001" ?
????????????????????? autoBind="100"
????????????????????? selectorTimeout="5000"
????????????????????? maxThreads="6"/>

??????????? <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
????????????? <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
??????????? </Sender>
??????????? <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
??????????? <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
????????? </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.JvmRouteSessionIDBinderListener"/>
????????? <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
??????? </Cluster>???

????? 上面部分如果需要詳細的說明可以看webapps\docs\cluster-howto.html

8】session黏貼(共享)方面,如果session中存放的為javabean,javabean必須實現Serializable接口,如果沒有實現會報錯誤 Exception thrown: class java.lang.IllegalArgumentException


9】補充:

?

??????看到jameswxx的回復發現確實有欠妥的地方,現在進行改正

????? 在工程的web.xml文件內加入?<distributable/>??? 標簽

????? 標題名不夠準確,將原名稱“tomcat集群配置流程”更正為“基于apache的tomcat負載均衡和集群配置”

?

?

?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388471.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388471.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388471.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

pdf.js插件使用記錄,在線打開pdf

pdf.js插件使用記錄&#xff0c;在線打開pdf 原文:pdf.js插件使用記錄&#xff0c;在線打開pdf天記錄一個js庫&#xff1a;pdf.js。主要是實現在線打開pdf功能。因為項目需求需要能在線查看pdf文檔&#xff0c;所以就研究了一下這個控件。 有些人很好奇&#xff0c;在線打開pdf…

程序員 sql面試_非程序員SQL使用指南

程序員 sql面試Today, the word of the moment is DATA, this little combination of 4 letters is transforming how all companies and their employees work, but most people don’t really know how data behaves or how to access it and they also think that this is j…

Apache+Tomcat集群負載均衡的兩種session處理方式

session共享有兩種方式&#xff1a; 1、session共享&#xff0c;多個服務器session拷貝保存&#xff0c;一臺宕機不會影響用戶的登錄狀態&#xff1b; 2、請求精確集中定位&#xff0c;即當前用戶的請求都集中定位到一臺服務器中&#xff0c;這樣單臺服務器保存了用戶的sessi…

SmartSVN:File has inconsistent newlines

用SmartSVN提交文件的時候&#xff0c;提示svn: File has inconsistent newlines 這是由于要提交的文件編碼時混合了windows和unix符號導致的。 解決方案 SmartSVN設置做如下修改可以解決問題&#xff1a; Project–>Setting選擇Working copy下的EOL-style將Default EOL-sty…

我要認真學Git了 - Config

有一天&#xff0c;當我像往常一樣打開SourceTree提交代碼&#xff0c;然后推送的時候&#xff0c;我突然意識到我只是根據肌肉記憶完成這個過程&#xff0c;我壓根不知道這其中到底發生了什么。這是個很嚴重的問題&#xff0c;作為一個技術人員&#xff0c;居然只滿足于使用工…

計算機科學與技術科研論文,計算機科學與技術學院2007年度科研論文一覽表

1Qiang Sun,Xianwen Zeng, Raihan Ur Rasool, Zongwu Ke, Niansheng Chen. The Capacity of Wireless Ad Hoc Networks with Power Control. IWCLD 2007. (EI收錄: 083511480101)2Hong jia ping. The Application of the AES in the Bootloader of AVR Microcontroller. In: DC…

r a/b 測試_R中的A / B測試

r a/b 測試什么是A / B測試&#xff1f; (What is A/B Testing?) A/B testing is a method used to test whether the response rate is different for two variants of the same feature. For instance, you may want to test whether a specific change to your website lik…

一臺機器同時運行兩個Tomcat

如果不加任何修改&#xff0c;在一臺服務器上同時運行兩個Tomcat服務顯然會發生端口沖突。假設現在已經按照正常的方式安裝配置好了第一個Tomcat,第二個如何設置呢&#xff1f;以下是使用Tomcat5.5解壓版本所做的實驗。 解決辦法&#xff1a; 1.解壓Tomcat到一個新的目錄&#…

PHP獲取IP地址的方法,防止偽造IP地址注入攻擊

PHP獲取IP地址的方法,防止偽造IP地址注入攻擊 原文:PHP獲取IP地址的方法,防止偽造IP地址注入攻擊PHP獲取IP地址的方法 /*** 獲取客戶端IP地址* <br />來源&#xff1a;ThinkPHP* <br />"X-FORWARDED-FOR" 是代理服務器通過 HTTP Headers 提供的客戶端IP。…

工作10年厭倦寫代碼_厭倦了數據質量討論?

工作10年厭倦寫代碼I have been in tons of meetings where data and results of any sort of analysis have been presented. And most meetings have one thing in common, data quality is being challenged and most of the meeting time is used for discussing potential…

Java基礎回顧

內容&#xff1a; 1、Java中的數據類型 2、引用類型的使用 3、IO流及讀寫文件 4、對象的內存圖 5、this的作用及本質 6、匿名對象 1、Java中的數據類型 Java中的數據類型有如下兩種&#xff1a; 基本數據類型: 4類8種 byte(1) boolean(1) short(2) char(2) int(4) float(4) l…

oracle數據庫 日志滿了

1、 數據庫不能啟動SQL> startupORACLE 例程已經啟動。Total System Global Area 289406976 bytesFixed Size 1248576 bytesVariable Size 83886784 bytesDatabase Buffers 197132288 bytesRedo Buffers 7139328 byt…

計算機應用基礎學生自查報告,計算機應用基礎(專科).docx

1.在資源管理器中&#xff0c;如果要選擇連續多個文件或文件夾&#xff0c;需要單擊第一個文件或文件夾&#xff0c;按下鍵盤()&#xff0c;再用鼠標單擊最后一個文件或文件夾即可。(A)Shift(B)Tab(C)Alt(D)Ctrl分值&#xff1a;2完全正確?得分&#xff1a;2?2.下列數據能被E…

Random隨機數

Random 隨機數 1 產生隨機數 1.1 Random的使用步驟 我們想產生1-100(包含1和100)的隨機數該怎么辦&#xff1f;我們不需要自己寫算法&#xff0c;因為額Java已經為我們提供好了產生隨機數的類---Random 作用&#xff1a;用于產生一個隨機數 使用步驟(和Scanner類似)&#xff1a…

模擬一個簡單計算器_閱讀模擬器的簡單介紹

模擬一個簡單計算器Read simulators are widely being used within the research community to create synthetic and mock datasets for analysis. In this article, I will introduce some recently proposed, commonly used read simulators.閱讀模擬器在研究社區中被廣泛使…

計算機部分應用顯示模糊,win10系統打開部分軟件字體總顯示模糊的解決方法-電腦自學網...

win10系統打開部分軟件字體總顯示模糊的解決方法。方法一&#xff1a;win10軟件字體模糊1、首先&#xff0c;在Win10的桌面點擊鼠標右鍵&#xff0c;選擇“顯示設置”。2、在“顯示設置”的界面下方&#xff0c;點擊“高級顯示設置”。3、在“高級顯示設置”的界面中&#xff0…

Tomcat調節

Tomcat默認可以使用的內存為128MB&#xff0c;在較大型的應用項目中&#xff0c;這點內存是不夠的&#xff0c;需要調大,并且Tomcat本身不能直接在計算機上運行&#xff0c;需要依賴于硬件基礎之上的操作系統和一個java虛擬機。 AD&#xff1a; 這里向大家描述一下如何使用Tom…

假如不工作了,你還有源源不斷的收入嗎?

擁有金山跟銀礦&#xff0c;其實不值得羨慕。俗話說&#xff1a;授人以魚不如授人以漁。與其選擇萬貫家財&#xff0c;倒不如選擇一個會持續冒出錢的杯子。很多人害怕上班的收入不確定&#xff0c;上班族急于尋找雙薪&#xff0c;下班之后還要辛勤工作&#xff0c;以為這樣就可…

turtle 20秒畫完小豬佩奇“社會人”

轉載&#xff1a;https://blog.csdn.net/csdnsevenn/article/details/80650456 圖片源自網絡 作者 丁彥軍 如需轉載&#xff0c;請聯系原作者授權。 今年社交平臺上最火的帶貨女王是誰&#xff1f;范冰冰&#xff1f;楊冪&#xff1f;Angelababy&#xff1f;不&#xff0c;是豬…

最佳子集aic選擇_AutoML的起源:最佳子集選擇

最佳子集aic選擇As there is a lot of buzz about AutoML, I decided to write about the original AutoML; step-wise regression and best subset selection. Then I decided to ignore step-wise regression because it is bad and should probably stop being taught. That…