隨筆 - 14, 文章 - 0, 評論 - 15, 引用 - 0
          數據加載中……

          linux下weblogic81集群配置實例

          Linux Weblogic 集群配置

          域,集群,管理服務器和被管服務器之間的關系

          ?????? Weblogic 域是一個服務器 / 集群的管理組,用戶可以通過某個中央位置來管理、監控整個服務器域,這個中心就是管理服務器,相對的,受控服務器或者叫被管服務器是指域中除了管理服務器以外的所有的服務器。

          ?????? Weblogic 集群是一個 weblogic Server 組,在一個集群中的服務器可以獲得集群范圍的命名服務、負載平衡以及容錯等功能。

          ?????? 所以,一個 weblogic 域可以同時管理多個集群以及多個服務器實例。

          ?????? 另外,還有一個節點管理器的概念,節點管理器是指在物理的機器上運行的一個守護進程,通過它,管理服務器可以獲得諸如在控制臺中強制重啟遠程機器上的 server 等功能(沒有節點管理器的情況下也是可以強制關閉遠程服務器的,但是不能重啟)。

          ?????? 除此之外,據說節點管理器還可以自動檢查自己機器上的 server 實例(健康檢查),當發現某個實例出現故障的時候,可以自動進行重啟,這個沒試過。

          注意事項

          1.???????? 本文的 weblogic 均配置在 linux 環境下

          2.???????? 集群中管理服務器和被管服務器之間有用到 ip 組播 UDP ,所以這些服務器之間必須是 UDP 可以到達的。

          3.???????? 好像動態 ip 的機器不能用于集群當中

          4.???????? 最佳實踐說:請不要把管理服務器設置在集群當中

          5.???????? 本文所配置的集群只是實現了 web 層次上的負載平衡和容錯,也就是 servlet jsp ,其他的 j2ee 組件如 ejb , jdbc , jms 等都可以集群化。

          本例測試域的規劃

          Ip/port

          server

          注釋

          10.21.18 .40:7001

          adminServer

          管理服務器

          10.21.18 .40:7003

          mServer1

          被管服務器 1

          10.21.18 .41:7001

          mServer2

          被管服務器 2

          10.21.18 .40:7004

          proxyServer

          代理服務器

          ?

          配置過程

          建立管理服務器

          啟動 linux 下的配置向導

          進入 bea 目錄下的 weblogic81/common/bin 目錄輸入 ./config.sh ,這里使用的終端登陸,所以沒有圖形環境,程序會以控制臺模式啟動

          第一步:選擇建立新的域:

          啟動配置向導后,系統提示如下:

          <------- BEA WebLogic Configuration Wizard---------->

          ?

          Create or Extend a Configuration:

          ---------------------------------

          ?

          Choose between creating and extending a configuration. Based on your selection, the Configuration Wizard guides you through

          the steps to generate a new or extend an existing configuration.

          ?

          ?->1|Create a new WebLogic configuration

          ??? |??? Start here to create a WebLogic configuration in your projects directory.

          ?? 2|Extend an existing WebLogic configuration

          ??? |??? Start here to extend an existing WebLogic configuration.? Use this option to add applications and services,

          ??? |including Database access (JDBC) and Messaging (JMS). This option also enables you to extend functionality by enabling

          ??? |WebLogic Workshop.

          ?

          Enter index number to select OR [Exit][Next]>? 1

          錄入 1 回車,建立一個新的域。

          第二步:選擇模版

          系統提示選擇一個建立域的模版,資料上講配置向導的配置過程可以另存為模版,以便下次配置的時候使用,沒試過下次回去試試。

          <-------- BEA WebLogic Configuration Wizard -------->

          Select a Domain Template:

          -------------------------

          Please select a template from the list or select another directory of templates.

          ??? * [/usr/local/bea/weblogic81/common/templates/domains]

          ?->1|Basic WebLogic Server Domain 8.1.4.0

          ??? |? BEA Systems, Inc.

          ??? |? Create a basic WebLogic Server domain without installing sample applications.

          ?? 2|WebLogic Server Examples Domain 8.1.4.0

          ??? |? BEA Systems, Inc.

          ??? |? Create the WebLogic Server Examples domain in a directory outside of the installed kit.? The Examples domain contains???? |a collection of examples to show best practices for coding individual J2EE APIs.

          ?? 3|Avitek Medical Records Sample Domain 8.1.4.0

          ??? |? BEA Systems, Inc.

          ??? |? Create the Avitek Medical Records domain in a directory outside of the installed kit.? The Avitek Medical Records is

          ??? |a WebLogic Server sample application suite that concisely demonstrates all aspects of the J2EE platform.

          ?? 4|Select another directory location

          Enter index number to select OR [Exit][Previous][Next]> 1

          這里我們選擇 1 ,使用基礎的模版

          第三步:是否以快速模式進行

          第三步系統提示是否以快速模式進行配置,這里選擇 2 。

          <--------- BEA WebLogic Configuration Wizard ----------->

          Choose Configuration Option:

          ----------------------------

          ??? *Do you want to run the wizard in express mode?

          ?->1|Yes

          ?? 2|No

          Enter index number to select OR [Exit][Previous][Next]> 2

          第四步:配置管理服務器

          現在系統提示我們配置管理服務器,把管理服務器的名字改一下,改成 adminServer 就可以了。

          <------- BEA WebLogic Configuration Wizard -------->

          Configure the Administration Server:

          ------------------------------------

          Enter adminstration server configurations. Each WebLogic Server domain must have one Administration Server. The

          Administration Server hosts the Administration Console which is used to perform administrative tasks.

          ??? |?????? Name?????? |??????? Value??????? |

          ?? _|__________________|_____________________|

          ?? 1|????? *Name:????? |????? myserver?????? |

          ?? 2| Listen address:? | All Local Addresses |

          ?? 3|?? Listen port:?? |??????? 7001???????? |

          ?? 4| SSL listen port: |???????? N/A???????? |

          ?? 5|?? SSL enabled:?? |?? ?????false??????? |

          Select Option:

          ??? 1 - Modify "Name"

          ??? 2 - Modify "Listen address"

          ??? 3 - Modify "Listen port"

          ??? 4 - Modify "SSL enabled"

          Enter option number to select OR [Exit][Previous][Next]> 1

          輸入 1 之后,根據系統提示輸入新的管理服務器的名稱 adminServer

          第五步:配置被管服務器

          根據下面系統的提示,配置被管服務器

          <--------- BEA WebLogic Configuration Wizard ---------->

          Configure Managed Servers:

          --------------------------

          Add or delete configuration information for managed servers. A typical production environment has one or more managed

          servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.

          ??? | Name* | Listen address | Listen port | SSL listen port | SSL enabled |

          ?? _|_______|________________|_____________|_________________|_____________|

          Enter name for a new Server OR [Exit][Previous][Next]> mServer1?

          被管服務器我們設置兩個: mServer1 mServer2 mServer1 和管理服務器在一臺機器上,所以端口設置為 7003 避免和管理服務器沖突。

          mServer2 的監聽地址一定要設置成 ip ,否則在啟動被管服務器 2 的時候會得到這樣一個錯誤: using the same address as the admin server (這個錯挺傻的我覺得),如果是實際的集群配置的話,這里建議都寫成 ip 的形式。

          配置完成的畫面如下:

          ?|? Name* ?|? Listen address ??| Listen port | SSL listen port | SSL enabled |

          _|_________|___________________|_____________|_________________|_____________|

          1| mServer1| 10.21.18.41?????? |??? 7003???? |?????? N/A?????? |??? false??? |

          ->2|mServer2|10.21.18.41?????? |?? 7001???? |?????? N/A?????? |??? false??? |

          ?

          第六步:配置集群

          <----BEA WebLogic Configuration Wizard ------>

          Configure Clusters:

          -------------------

          A cluster contains multiple WebLogic Server instances (servers) that run simultaneously and work together to provide

          increased scalability and reliability.? A cluster appears to be a single WebLogic Server instance to clients.

          ??? | Name* | Multicast address | Multicast port | Cluster address |

          ?? _|_______|___________________|________________|_________________|

          Enter name for a new Cluster OR [Exit][Previous][Next]> testCluster

          輸入集群的名字 testCluster ,其他的默認就行了,配置完成后如下:

          ??? |??? Name*??? | Multicast address | Multicast port | Cluster address |

          ?? _|_____________|___________________|________________|_________________|

          ?->1| testCluster |???? 237.0.0.1???? |????? 7001????? |???????????? ????|

          第七步:將服務器組織到集群中

          根據系統的提示,將 mServer1 mServer2 放入集群 testCluster 中去,配置完成后如下:

          ??? Cluster

          ??? |_____testCluster [1]

          ???????? |_____mServer1

          ???????? |_____mServer2

          第八步:配置機器、 jdbc jms 、安全等

          接下來幾步系統提示配置 Machines,jdbc,jms,安全,這里都不用配置,全部回車就行了。

          第九步:輸入管理服務器的用戶名和密碼

          系統提示如下畫面,可以配置管理服務器的用戶名和密碼:

          ??? |????????? Name?????????? |????????????? Value????????????? |

          ?? _|_________________________|_________________________________|

          ?? 1|?????? *User name:?????? |??????????? weblogic???????????? |

          ?? 2|???? *User password:???? |???? ????????????????????????????|

          ?? 3| *Confirm user password: |???????????????????????????????? |

          ?? 4|????? Description:?????? | The default administration user |

          第十步:選擇啟動模式, jdk 和存放目錄

          啟動模式, jdk 和域文件存放目錄的設置比較簡單,根據大家的愛好設置就行了。

          這里啟動模式選擇生產開發模式, jdk 使用 jRockit ,存放目錄默認。

          十一步:配置域名稱

          Edit Domain Information:

          ------------------------

          ??? |? Name? |? Value?? |

          ?? _|________|__________|

          ?? 1| *Name: | mydomain |

          Enter value for "Name" OR [Exit][Previous][Next]> testDomain

          設置域的名稱為 testDomain 。

          十二步:域建立結束

          以上步驟都完成后,系統會自動建立這個域,并會生成一些文件等等,完成的界面如下:

          <----- BEA WebLogic Configuration Wizard --------->

          Creating Domain...

          0%????????? 25%????????? 50%????????? 75%????????? 100%

          [------------|------------|------------|------------]

          [***************************************************]

          **** Domain Created Successfully! ****

          啟動管理服務器

          進入 bea/user_projects/domains/testDomain/ 目錄

          鍵入 ./startWebLogic.sh

          建立被管服務器 1

          這里的被管服務器 1 也就是 mServer1 是和管理服務器在同一臺機器上的,這里我試過了,我們不需要再進行什么配置,只需要啟動它就行了,啟動被管服務器 1 的命令如下:

          進入 bea/user_projects/domains/testDomain/ 目錄

          鍵入 ./startManagedWebLogic.sh mServer1 http://10.21.18.40:7001

          這樣的寫法保證了被管服務器在啟動的時候向管理服務器報告,后面的這個地址就是管理服務器的地址了

          當然,由于是在同一臺機器上,所以你完全可以這樣寫: ./startManagedWebLogic.sh mServer1 就可以了。

          建立被管服務器 2

          被管服務器 2 和管理服務器在不同的機器上,所以你還需要在這臺機器上配置一個域,域的名字要和剛才建立的域名字一致(不一致會怎么樣我也沒試過,誰有時間試一下: >

          建立域的過程前三步和上面講的一樣

          第四步,配置管理服務器的時候,請把這個域的管理服務器的名字設置為 mServer2

          這里需要解釋一下,在每臺機器上建立域的時候都需要有一個管理服務器,以確保整個域的管理服務器當掉的時候,每臺機器自己都是還可以運行的,這里我們是把 mServer2 作為了 41 這臺機器的管理服務器,同時它也是 adminServer 的被管理服務器。

          從第五步開始,都不需要配置,直接回車就可以了。

          配置完成后,用下面的命令啟動 mServer2

          ./startManagedWebLogic.sh mServer2 http://10.21.18.40:7001

          小結

          到目前為止,一個包含一個管理服務器和 2 個被管服務器以及一個 cluster 的域就配置完成了,你可以簡單試驗一下它提供的功能,打開管理服務器的管理控制臺:

          http://10.21.18.40:7001/console

          首先,在這個管理控制臺上你可以監控和管理 mServer1 mServer2 ,選擇 mServer2

          進入 Monitoring 頁面 General 子頁面,如果顯示如下,就說明配置是正確的了:

          進入 Monitoring 頁面的 Performance 子頁面,就可以看到 mServer2 的運行情況了。

          將一個 web 應用上傳上去,將其部署在 testCluster 這個集群上

          部署成功后,分別在 mServer1 mServer2 上訪問剛才部署的 web 應用,應該都是可以訪問的。

          建立代理服務器

          建立了集群以后,集群的負載平衡功能還需要代理( proxy )來實現。目前我所知道的 Weblogic 支持幾種類型的代理:

          ????????? HttpClusterServlet 的代理,這個代理是 weblogic 公司編寫的一個 servlet ,把它部署在一個 weblogic 服務實例上,就可以實現負載平衡和容錯了。

          ????????? IIS 代理,用 IIS 作為前段的 http 的代理,需要往 IIS 中裝一個插件

          ????????? Netscape/iPlanet 代理,需要裝插件

          ????????? Apache 代理,用 Apache 作為 http 代理,需要裝插件。推薦使用

          當然,實際應用中可能更加復雜,可能會這樣:

          使用 HttpClusterServlet 作為代理

          建立代理服務器實例

          代理服務器 proxyServer 實例實際上和 mServer1 一樣,都是屬于 testDomain 域的一個被管服務器,回頭看建立管理服務器的第五步,在那個時候配置被管服務器的時候如果也把 proxyServer 加上的話,現在直接啟動就可以了。

          當然也可以在管理服務器的管理控制臺上新建這個 server

          在管理服務器的控制臺上,左邊的菜單中 Server 上單擊左鍵,選擇“新建一個 Server

          然后,在出現的頁面中設置這個 server 的名字為 proxyServer ,監聽端口為 7004 ,如圖:

          點擊應用,這個服務就配置完成了。

          配置結束后,在后臺使用 ./startManagedWebLogic.sh proxyServer 來啟動代理服務器。

          部署代理 webapp

          建立一個標準的 web 應用,這個應用里面什么也不用有,只需要配置 web.xml weblogic.xml 就可以了。 web.xml weblogic.xml 代碼如下:

          web.xml

          <!-- DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.

          //DTD Web Application 1.2//EN"

          "http://java.sun.com/dtd/web-app_2_3.dtd"

          -->

          <web-app>

          <servlet>

          ? <servlet-name>HttpClusterServlet</servlet-name>

          ??? <servlet-class>

          ????? weblogic.servlet.internal.HttpClusterServlet

          ??? </servlet-class>

          ? <init-param>

          ??? <param-name>defaultServers</param-name>

          ??? <param-value>

          ?????? 10.21.18.40:7003|10.21.18.41:7001

          ??? </param-value>

          ? </init-param>

          ? <init-param>

          ??? <param-name>DebugConfigInfo</param-name>

          ??? <param-value>ON</param-value>

          ? </init-param>

          </servlet>

          <servlet-mapping>

          ? <servlet-name>HttpClusterServlet</servlet-name>

          ? <url-pattern>/</url-pattern>

          </servlet-mapping>

          <servlet-mapping>

          ? <servlet-name>HttpClusterServlet</servlet-name>

          ? <url-pattern>*.jsp</url-pattern>

          </servlet-mapping>

          <servlet-mapping>

          ? <servlet-name>HttpClusterServlet</servlet-name>

          ? <url-pattern>*.htm</url-pattern>

          </servlet-mapping>

          <servlet-mapping>

          ? <servlet-name>HttpClusterServlet</servlet-name>

          ? <url-pattern>*.html</url-pattern>

          </servlet-mapping>

          </web-app>

          ?

          weblogic.xml

          <?xml version="1.0" encoding="UTF-8"?>

          <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 6.1//EN" "http://www.bea.com/servers/wls610/dtd/weblogic-web-jar.dtd">

          <weblogic-web-app>

          ? <context-root>/</context-root>

          </weblogic-web-app>

          將這個應用打包成 war 文件,上傳到管理服務器上,然后部署在 proxyServer 上面。

          部署成功后的頁面:

          測試

          打開一個瀏覽器,在其中輸入:

          http://10.21.18.40:7004/abc.jsp? __WebLogicBridgeConfig

          jsp 的名字隨便輸入可以了,如果看到如下頁面,就說明配置成功了:

          ?

          ?

          ?

          然后再做一個 web 應用,里面放兩個 servlet , jsp 啥的,部署在集群上面,比如說部署成功了以后應用叫做 testApp ,其中有一個頁面叫 index.jsp

          鍵入如下的地址:

          http://10.21.18.41:7001/testApp/index.jsp

          http://10.21.18.40:7003/testApp/index.jsp

          http://10.21.18.40:7004/testApp/index.jsp

          應該都是可以運行的,請注意第一、二個地址是單獨訪問集群中的機器的,而第三個地址是通過了代理的。

          你可以做一個這樣的測試,在 index.jsp 里面寫一句 System.out.println(“ok!!!”);

          然后再 http://10.21.18.40:7004/testApp/index.jsp 這個地址上多刷幾次,到 mServer1 mServer2 的控制臺去看的話應該兩邊都有輸出。

          使用 apache 作為代理

          安裝代理插件

          weblogic 安裝目錄下面,找到 bea/weblogic81/server/bin 目錄,下面有兩個文件:

          mod_wl_20.so

          mod_wl128_20.so

          分別是對應不同版本的 apache ,這里用來測試的是 2.0 版的 apache ,所以使用了第一個文件。

          安裝過程如下:

          ????????? mod_wl_20.so 這個文件 copy apache 安裝目錄下的 modules 目錄中

          ????????? apache httpd.conf 文件中,加入這樣一句:

          LoadModule weblogic_module modules/mod_wl_20.so

          表示在啟動 apache 的時候加載 weblogic 的插件

          ????????? apache httpd.conf 文件中,加入如下代碼:

          ?

          <IfModule mod_weblogic.c>

          ? WebLogicCluster 61.152.114.141:7003,61.152.114.142:7001

          ? MatchExpression *.jsp

          ? MatchExpression *.do

          </IfModule>

          第一行表示集群的各個成員地址

          下面幾行可以寫出要代理的 url 后綴。

          ?

          注:如果 weblogic 這邊沒有集群,只有一臺機器的話,也是可以配置 apache 插件的,這樣寫:

          <IfModule mod_weblogic.c>
          ??WebLogicHost myweblogic.server.com
          ??WebLogicPort 7001
          ??MatchExpression *.jsp
          ??MatchExpression *.xyz
          </IfModule>

          測試

          啟動 apache ,訪問 http://apachehost:part/testApp/index.jsp 應該可以看到正確的響應。其中 apachehost part apache 的配置而定。

          使用 iis 作為代理

          安裝插件

          IIS weblogic 插件安裝非常的簡單:

          ????????? 找到 bea/weblogic81/server/bin 目錄下的 iisproxy.dll ,拷貝到一個 IIS 能夠訪問到的目錄,比如 WINNT\system32\inetsrv\

          ????????? 建立兩個文本文件: iisproxy.ini iisproxy.log

          ????????? 右鍵單擊某個站點,打開屬性頁面

          ????????? 點擊下面的配置,界面如下:

          ????????? 點擊添加,在其中可執行文件選擇 iisproxy.dll ,擴展名錄入 *.jsp ,如圖:

          ????????? 配置完畢后啟動 iis 的這個站點

          測試

          訪問 http://iishost:part/testApp/index.jsp 應該可以看到正確的響應。其中 iishost part IIS 的配置而定。

          簡單測試

          想要進行一些性能方面的測試,可以使用 apache 帶的 apacheBench 工具,這個工具在 apache 安裝目錄下的 bin 目錄下有( ab.sh ),用法如下:

          ab –c 200 –n 60 url

          含義是請求 url 這個地址 200 次, 60 次的并發。

          以下是我做的一些簡單測試的結果的一部分:

          單獨訪問集群中一臺機器的時候:

          Percentage of the requests served within a certain time (ms)

          ? 50%? 13734

          ? 66%? 17046

          ? 75%? 33234

          ? 80%? 34000

          ? 90%? 34343

          ? 95%? 34437

          ? 98%? 34515

          ? 99%? 34515

          ?100%? 34546 (longest request)

          使用 HttpClusterServlet 代理訪問集群的情況:

          Percentage of the requests served within a certain time (ms)

          ? 50%? 18234

          ? 66%? 19187

          ? 75%? 19718

          ? 80%? 19921

          ? 90%? 21296

          ? 95%? 22203

          ? 98%? 22593

          ? 99%? 22640

          ?100%? 22703 (longest request)

          使用 apache 代理訪問集群的情況:

          Percentage of the requests served within a certain time (ms)

          ? 50%?? 2000

          ? 66%?? 2578

          ? 75%?? 3421

          ? 80%?? 3421

          ? 90%?? 3625

          ? 95%?? 3640

          ? 98%?? 3640

          ? 99%?? 3640

          ?100%?? 3656 (longest request)

          使用 iis 代理訪問集群的時候:

          出錯, 200 次請求當中有 190 次失敗:(

          可能是因為 iis 在我的機器上的原因

          另外,在測試的時候檢測 mServer1 mServer2 的吞吐量( Throughput ),也是在使用 apache 的時候最高。大家也可以多做一些各個方面的測試,很有意思的。


          注:由于上傳圖片太麻煩了,所以本文的圖片我都刪除了,如果要看完整的版本,可以下載word版本的文件。本文下載地址:

          不知道為什么,原來上傳的附件不見了,以下是我在dev2dev上發的帖子,word版的資料在上面可以下載
          http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=81&threadID=23915&messageID=164966#164966


          blogjava下載:
          http://www.aygfsteel.com/Files/lqsun/linux環境weblogic81集群配置.rar環境weblogic81集群配置.rar

          posted on 2005-06-16 10:32 Boris-Java 閱讀(4066) 評論(7)  編輯  收藏 所屬分類: weblogic

          評論

          # re: linux下weblogic81集群配置實例  回復  更多評論   

          你寫的非常好能不能把word版本的文件給我發一份,好像不能下載,謝謝!
          larry838@126.com
          2006-03-20 14:07 | larry

          # re: linux下weblogic81集群配置實例  回復  更多評論   

          可以給我發你份word版的嗎?
          你給的地址下不了,提示文件不存在!
          2006-09-26 11:35 | yinchong

          # re: linux下weblogic81集群配置實例  回復  更多評論   

          我的信箱是 yinchonging@yahoo.com.cn
          謝謝
          2006-09-26 11:36 | yinchong

          # re: linux下weblogic81集群配置實例  回復  更多評論   

          可以給我一份word版的嗎?我的信箱是 yinchonging@yahoo.com.cn,非常感謝 。
          2006-10-08 17:30 | weblogic

          # re: linux下weblogic81集群配置實例[未登錄]  回復  更多評論   

          mod_wl.so: wrong ELF data format: ELFDATA2LSB
          2007-01-23 15:20 | dd

          # re: linux下weblogic81集群配置實例[未登錄]  回復  更多評論   

          為什么我用APACHE時
          ./httpd -t
          httpd: Syntax error on line 494 of
          /apache/conf/httpd.conf: Cannot load
          /apache/modules/mod_wl.so into server: ld.so.1: ./httpd: fatal:
          /apache/modules/mod_wl.so: wrong ELF data format: ELFDATA2LSB
          太假了!
          2007-01-23 15:21 | dd

          # re: linux下weblogic81集群配置實例  回復  更多評論   

          看上去不錯,等會試驗一下,謝謝!
          2008-01-13 16:14 | eyou
          主站蜘蛛池模板: 大同市| 桃园市| 浪卡子县| 内江市| 石家庄市| 和龙市| 望江县| 新郑市| 蓝山县| 惠东县| 启东市| 清苑县| 县级市| 合肥市| 西乌珠穆沁旗| 甘孜县| 邯郸市| 青铜峡市| 婺源县| 陇南市| 旌德县| 乳源| 新泰市| 海淀区| 浑源县| 抚松县| 贺州市| 德江县| 石屏县| 晋州市| 辛集市| 永定县| 泰顺县| 安化县| 平顶山市| 泰安市| 东丰县| 怀安县| 新龙县| 安福县| 武安市|