Windows 2003 Server 網(wǎng)絡負載均衡 Tomcat 5.0 集群_第1頁
Windows 2003 Server 網(wǎng)絡負載均衡 Tomcat 5.0 集群_第2頁
Windows 2003 Server 網(wǎng)絡負載均衡 Tomcat 5.0 集群_第3頁
Windows 2003 Server 網(wǎng)絡負載均衡 Tomcat 5.0 集群_第4頁
Windows 2003 Server 網(wǎng)絡負載均衡 Tomcat 5.0 集群_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、一、設置Windows 網(wǎng)絡負載均衡(Load Balance)以本地 Administrators 組成員身份登錄計算機才能完成此過程。1.在前端網(wǎng)絡接口卡 (NIC) 上設置靜態(tài) IP。要這樣做,請執(zhí)行下列操作:1.1.單擊“開始”,指向“控制面板”,再單擊“網(wǎng)絡連接”。1.2.用鼠標右鍵單擊“前端 NIC”,再單擊“屬性”。1.3.在“此連接使用下列選定的組件”區(qū)域中,選中“Internet 協(xié)議 (TCP/IP)”復選框。1.4.單擊“屬性”。1.5.選中“使用下列 IP 地址”。1.5.1.在“IP 地址”框中,鍵入分配的前端靜態(tài) IP: 100.100.100.150。1.5.2.

2、如果需要,在“子網(wǎng)掩碼”框中,鍵入分配的前端子網(wǎng)掩碼:255.255.255.0。1.5.3.如果需要,在“默認網(wǎng)關”框中,鍵入分配的前端網(wǎng)關:100.100.100.243。1.6.選中“使用下列 DNS 服務器地址”。1.7.在“首選 DNS 服務器”和“備用 DNS 服務器”框中,鍵入適當?shù)?IP:100.100.100.6和100.100.100.7。1.8.單擊“高級”。1.9.在“IP 設置”選項卡上的“IP 地址”節(jié)中,單擊“添加”。1.10.在“IP 地址”框中,鍵入虛擬 IP 地址:100.100.100.201。1.11.在“子網(wǎng)掩碼”框中,鍵入子網(wǎng)掩碼:255.255.2

3、55.0。1.12.單擊“添加”,再單擊“確定”。注釋:虛擬 IP 地址是負載平衡的IP 地址,它是指向服務器場的條目。2.“LAN 連接屬性”對話框上的“此連接使用下列選定的組件”區(qū)域中,選中“網(wǎng)絡負載平衡”復選框。3.單擊“屬性”。4.在“群集參數(shù)”選項卡上,執(zhí)行下列操作:4.1.在“IP 地址”框中,鍵入群集 IP :100.100.100.201。群集 IP 是虛擬 IP 地址,它是指向服務器場的條目。需要將此 IP 地址映射到 DNS 項,以便可以在 Microsoft Internet Explorer 中鍵入群集名稱,而不用鍵入 IP 地址。4.2.在“子網(wǎng)掩碼”框中,鍵入子網(wǎng)掩

4、碼:255.255.255.0。將 IPCONFIG /ALL 報告的此 NIC 的子網(wǎng)掩碼用于此 NIC。4.3.在“完整 Internet 名”框中,鍵入 DNS 名稱:。注釋:如果使用了 Microsoft Windows Internet 名稱服務 (WINS) 解析,請輸入 WINS 名稱,無需輸入域擴展例如,應輸入 server_farm 而不是 server_。4.4.在“群集操作”節(jié)中,單擊“單播”(默認選項)。4.5.保留“允許遠程控制”復選框為其默認設置(清除)。5.在“主機參數(shù)”選項卡上,執(zhí)行下列操作:5.1.在“優(yōu)先級”框中,對第一臺前端 Web 和搜索服務器輸入 1,

5、對第二臺前端 Web 和搜索服務器輸入 2。5.2.在“專用 IP 配置”區(qū)域的“IP 地址”框中,鍵入初始分配給此前端 NIC 的地址:100.100.100.150。注釋:要為前端 NIC 分配兩個 IP 地址。5.3.在“子網(wǎng)掩碼”框中,鍵入初始分配給此前端 NIC 的子網(wǎng)掩碼:255.255.255.0。5.4.請勿更改“初始主機狀態(tài)”節(jié)中的任何設置。6.在“端口規(guī)則”選項卡上,單擊“編輯”。7.在“篩選模式”節(jié)中,單擊“多個主機”。8.在“關系”組中,單擊“無”;負載量選擇“相等”或輸入負載的比例(百分比),可按照“二八”比例分配負載量。9.單擊“確定”,然后再次單擊“確定”。注釋:

6、如果顯示一個對話框,提示您必須在 TCP/IP 組件中輸入新地址,則說明您沒有完成之前的所有步驟。請單擊“確定”,然后在繼續(xù)操作之前執(zhí)行下列步驟:9.1.在前端 NIC 的“屬性”對話框的“常規(guī)”選項卡上,單擊“Internet 協(xié)議 (TCP/IP)”,再單擊“屬性”。9.2.單擊“高級”。9.3.在“IP 設置”選項卡上的“IP 地址”節(jié)中,單擊“添加”。9.4.在“IP 地址”框中,鍵入虛擬 IP 地址:100.100.100.201。9.5.在“子網(wǎng)掩碼”框中,鍵入子網(wǎng)掩碼: 255.255.255.0。9.6.單擊“添加”,再單擊“確定”。10.重新啟動服務器。11.在所有前端 We

7、b 和搜索服務器上重復前面的步驟。請確保更改每一臺服務器的優(yōu)先級設置,使其唯一。12.測試網(wǎng)絡負載平衡:12.1.打開命令提示符,然后從服務器場之外的客戶端計算機 ping 服務器場的虛擬名稱。例如,如果 server_farm 是輸入的完整 Internet 名,或者使用了 WINS,則應該鍵入 ping server_farm。在本示例中 Server_farm 是虛擬服務器場名稱。12.2.請確認是否收到答復。如果未收到答復,請使用服務器場的虛擬 IP 地址 ping 服務器場。虛擬 IP 地址是在前面的步驟中指定的群集 IP 地址。如果未收到答復,請與負責 DNS/WINS、路由和靜態(tài)

8、 IP 支持的網(wǎng)絡操作聯(lián)系人聯(lián)系。12.3.鍵入 ping virtual_server_farm_name -t。此命令將執(zhí)行連續(xù)的 ping 操作。12.4.在第一臺前端 Web 和搜索服務器上執(zhí)行下列操作:12.4.0. 在任務欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”,然后單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”。12.4.1. 在“常規(guī)”選項卡上,單擊“禁用”。12.5.在第二臺前端 Web 和搜索服務器上執(zhí)行下列操作:12.5.0. 在任務欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”,然后單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”。12.5.

9、1. 在“常規(guī)”選項卡上,單擊“禁用”。12.6.在連續(xù) ping 服務器場的虛擬名稱的客戶端計算機上,應該會出現(xiàn)一條消息,說明請求超時。 12.7.在第一臺前端 Web 和搜索服務器的任務欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”。 然后用鼠標右鍵單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”,再單擊“啟用”。12.8.在連續(xù) ping 服務器場的虛擬名稱的客戶端計算機上,應該會在 10 秒鐘內(nèi)顯示對 ping 的答復。 如果未顯示答復,請確認網(wǎng)絡負載平衡配置和網(wǎng)絡配置是否正確。12.9.在第一臺前端 Web 和搜索服務器上執(zhí)行下列操作:12.9.0.在任務欄上,單擊“開始”

10、,指向“控制面板”,再指向“網(wǎng)絡連接”,然后單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”。12.9.1.在“常規(guī)”選項卡上,單擊“禁用”。12.10.在連續(xù) ping 服務器場的虛擬名稱的客戶端計算機上,應該會出現(xiàn)一條消息,說明請求超時。 12.11.在第二臺前端 Web 和搜索服務器的任務欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”。 然后用鼠標右鍵單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”,再單擊“啟用”。12.12.在連續(xù) ping 服務器場的虛擬名稱的客戶端計算機上,應該會在 10 秒鐘內(nèi)顯示對 ping 的答復。如果未顯示答復,請確認網(wǎng)絡負載平衡配置和網(wǎng)絡配置是

11、否正確。12.13.在第二臺前端 Web 和搜索服務器上執(zhí)行下列操作:12.13.0.在任務欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”,然后單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”。12.13.1.在“常規(guī)”選項卡上,單擊“禁用”。12.14.在連續(xù) ping 服務器場的虛擬名稱的客戶端計算機上,應該會出現(xiàn)一條消息,說明請求超時。 12.15.在第一臺前端 Web 和搜索服務器的任務欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”。 然后用鼠標右鍵單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”,再單擊“啟用”。12.16.在第二臺前端 Web 和搜索服務器的任務

12、欄上,單擊“開始”,指向“控制面板”,再指向“網(wǎng)絡連接”。 然后用鼠標右鍵單擊與網(wǎng)絡負載平衡相關的 NIC 的“本地連接”,再單擊“啟用”。12.17.在連續(xù) ping 服務器場的虛擬名稱的客戶端計算機上,按下 Ctrl+C 中斷 ping 循環(huán)。二、設置DNS設置DNS服務,域名:,解析為對應的虛擬 IP :100.100.100.201 。三、設置服務心跳(HeartBaet)設置IP和掩碼即可。Web服務心跳之一IP:192.168.10.1掩碼: 255.255.255.0Web服務心跳之二IP:192.168.10.2掩碼: 255.255.255.0四、設置 Tomcat 5.0

13、集群打開 Tomcat 安裝目錄中的confserver.xml 文件,把 Server/Service/Engine/Host 下的 Cluster 結點前后的注釋符刪除并保存。注意,在新安裝的Tomcat5.0中可找到 Cluster 結點。如果已經(jīng)在Tomcat的管理程序中設置過Tomcat的連接池,則在server.xml 文件中不會有 Cluster 結點,因為Cluster 結點默認是被注釋的,在設置連接池的過程中,系統(tǒng)會自動刪除server.xml 文件中的注釋內(nèi)容。修改后的server.xml,大致成為如下的樣子:-<Cluster className="org

14、.apache.catalina.cluster.tcp.SimpleTcpCluster"managerClassName="org.apache.catalina.cluster.session.DeltaManager" expireSessionsOnShutdown="false"useDirtyFlag="true"><MembershipclassName="org.apache.catalina.cluster.mcast.McastService"mcastAddr=&quo

15、t;228.0.0.4"mcastPort="45564"mcastFrequency="500"mcastDropTime="3000"/><ReceiverclassName="org.apache.catalina.cluster.tcp.ReplicationListener"tcpListenAddress="auto"tcpListenPort="4001"tcpSelectorTimeout="100"tcpThread

16、Count="6"/><SenderclassName="org.apache.catalina.cluster.tcp.ReplicationTransmitter"replicationMode="pooled"/><Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"filter=".*.gif;.*.js;.*.jpg;.*.htm;.*.html;.*.txt;"/></

17、Cluster>-此時,mcastAddr的默認值是“228.0.0.4”,修改此值并保存。對應不同的Web服務器,mcastAddr 為其心跳的IP地址。Web服務之一: mcastAddr="192.168.10.1"Web服務之二: mcastAddr="192.168.10.2"其他內(nèi)容保持不變。在 Tomcat 5.0 中對 Cluster 的配置,將使Tomcat群集中能夠實現(xiàn)Session的復制,即群集中各個Web服務節(jié)點的Session保持一致,實現(xiàn)Session共享。注:對server.xml中的Cluster的一段文字的翻譯:&

18、lt;!- Defines a cluster for this node,By defining this element, means that every manager will be changed.So when running a cluster, only make sure that you have webapps in there that need to be clustered and remove the other ones.A cluster has the following parameters:為這個結點定義一個群集,通過定義這個元素,意味著每個管理員都將

19、被改變。因此,當運行一個群集時,只有確認在必須被聚集和移除其他的地方有你的web軟件。 一個群集有下面這些參數(shù):className = the fully qualified name of the cluster classclassName = 這個群集類的全限定名name = a descriptive name for your cluster, can be anythingname = 你的群集的描述名,可以是任何描述debug = the debug level, higher means more outputdebug = 調(diào)試級別,更高意味著更多的輸出mcastAddr =

20、 the multicast address, has to be the same for all the nodes mcastAddr = 多播地址,所有的節(jié)點都必須有同樣的多播地址mcastPort = the multicast port, has to be the same for all the nodes mcastPort = 多播端口,對所有的節(jié)點都必須有同樣的多播端口mcastBindAddr = bind the multicast socket to a specific addressmcastBindAddr = 綁定多播套接字到一個指定的地址mcastTTL

21、= the multicast TTL if you want to limit your broadcastmcastTTL = 多播生存期,如果你想要限制你的廣播的話mcastSoTimeout = the multicast readtimeoutmcastSoTimeout = 多播讀取超時mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeatmcastFrequency = 發(fā)送“I'm alive”(我還活著)信息的間隔毫秒數(shù)mc

22、astDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is receivedmcastDropTime = 多長時間沒有收到“I'm alive”就將這個節(jié)點標識為死節(jié)點(單位:毫秒) tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as no

23、destcpThreadCount = 用于處理重復引入請求的線程數(shù),最好是每個節(jié)點都有相同的線程數(shù) tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,in case of multiple ethernet cards.auto means that address becomesInetAddress.getLocalHost().getHostAddress()tcpListenAddress = 在有多塊以太網(wǎng)卡的主機上的監(jiān)聽TCP群集請求的地址(綁定地址)

24、, auto意味著地址由InetAddress.getLocalHost().getHostAddress()取得。 tcpListenPort = the tcp listen porttcpListenPort = tcp監(jiān)聽端口tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OShas a wakup bug in java.nio. Set to 0 for no timeouttcpSelectorTimeout = 在操作系統(tǒng)中有java.nio喚醒錯的情況下,使用

25、Selector.select()的超時毫秒數(shù)。設為0則沒有超時限制printToScreen = true means that managers will also print to std.outprintToScreen = true意味著管理員的相關信息也將打印輸出到std.outexpireSessionsOnShutdown = true means thatexpireSessionsOnShutdown = true 意味著?useDirtyFlag = true means that we only replicate a session after setAttribut

26、e,removeAttribute has been called.false means to replicate the session after each request.false means that replication would work for the following piece of code:<%HashMap map = (HashMap)session.getAttribute("map");map.put("key","value");%>useDirtyFlag = true意味著我們

27、只能在調(diào)用setAttribute,removeAttribute后才能復制一個會話;false意味著在每個請求后復制會話。false意味著復制將以下列代碼方式工作:<%HashMap map = (HashMap)session.getAttribute("map");map.put("key","value");%>replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.* Poo

28、led means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. T

29、o use this, also increase the nr of tcp threads that you have dealing with replication.* Synchronous means that the thread that executes the request, is also thethread the replicates the data to the other nodes, and will not return until allnodes have received the information.* Asynchronous means th

30、at there is a specific 'sender' thread for each cluster node,so the request thread will queue the replication request into a "smart" queue,and then return to the client.The "smart" queue is a queue where when a session is added to the queue, and the same sessionalready ex

31、ists in the queue from a previous request, that session will be replacedin the queue instead of replicating two requests. This almost never happens, unless there is alarge network delay.replicationMode = 可以是“pooled”、“synchronous”或者“asynchronous”* Pooled意味著在多個套接字上同步進行復制。例如,先復制數(shù)據(jù),然后請求返回。這與“synchronous

32、”相同,除了它使用一個套接字池,因此,它是多線程的。它是最快和最高級的設置,使用這個配置也增加了處理復制的tcp線程的域。* Synchronous指執(zhí)行請求的線程,它也是向其他節(jié)點復制數(shù)據(jù)的線程,并且直到所有的節(jié)點都己經(jīng)收到信息后才返回。* Asynchronous,對每個群集節(jié)點而言,這是一個特別的“sender”(發(fā)送者)線程,因此請求線程將復制請求排隊到一個小隊列中,然后,返回給用戶。這個小隊列是一個當會話被添加到隊列中,而從先前的請求中,同一個會話己經(jīng)存在,這個會話將被放置在隊列中以代替重復的兩個請求。這幾乎從不會發(fā)生,除非存在較大的網(wǎng)絡延遲。-><!-When conf

33、iguring for clustering, you also add in a valve to catch all the requestscoming in, at the end of the request, the session may or may not be replicated.A session is replicated if and only if all the conditions are met:1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND2. a

34、 session exists (has been created)3. the request is not trapped by the "filter" attributeThe filter attribute is to filter out requests that could not modify the session, hence we don't replicate the session after the end of this request.The filter is negative, ie, anything you put in

35、the filter, you mean to filter out, ie, no replication will be done on requests that match one of the filters.The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.filter=".*.gif;.*.js;" means that we will not replicate the session after requests with

36、the URIending with .gif and .js are intercepted.-><!- 當配置群集時,你也添加一個值來捕獲所有傳入的請求,在請求結束時,這個會話可能被子復制,也可能不被復制。一個會話是否復制取決于下列條件是否發(fā)生:1. useDirtyFlag為真,或者setAttribute或者removeAttribute己經(jīng)被調(diào)用。2. 會話己經(jīng)存在(己經(jīng)被創(chuàng)建了)。3. 請求沒有被“filter”屬性所捕獲。這個filter(過濾器)屬性用于過濾那些不能修改會話的請求,因此,我們在這個請求結束后不復制會主。這個過濾器是消極的,例如,你向過濾器發(fā)送了一些東

37、西,然后被過濾出去,在那個匹配的過濾器上不會發(fā)生復制。過濾器屬性以分號為分隔,因此你不能換行,即使你想這么做。filter=".*.gif;.*.js;"意味著在進行以.gif和.js結束的URI請求后不復制會話。五、啟動Web服務當 Load Balance 和 Cluster 配置完畢,可啟動Web服務。啟動Web服務,需按照在 Load Balance 中設置的“優(yōu)先級”順序,依次啟動Tomcat服務。 主服務啟動時,Tomcat控制臺會輸出大致如下的信息:-Creating ClusterManager for context /thams using class

38、org.apache.catalina.cluster.session.DeltaManager- Starting clustering manager.:/thams- Manager/thams, skipping state transfer. No members active in cluster group. -次級服務啟動時,Tomcat控制臺會輸出大致如下的信息:-Creating ClusterManager for context /thams using class org.apache.catalina.cluster.session.DeltaManager- St

39、arting clustering manager.:/thams- Manager/thams, requesting session state from org.apache.catalina.cluster.mcast.McastMembertcp:/192.168.10.1:4001,192.168.10.1,4001, alive=20500. This operation will timeout if no session statehas been received within 60 seconds- Manager/thams, session state received in 109 ms.-六、測試可以使用如下代碼做測試:-<% page contentType="text/html; charset=GBK" pageEncoding="GBK"import="java.util.Enumeration"%><html><head><title>Cluster App Test</title></head><bo

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論