JBOSS-5.0.0GA的集群搭建(一)來源: 作者: 發(fā)布時間:2009-3-17 9:41:08 -
最近看了一下JBOSS-5.0.0GA的集群搭建的文檔,,于是把自己的理解發(fā)上來和大家共享一下。不過還是有好多問題需要和大家,,共同討論一下 下面的JBOSS-5.0.0GA的集群部署的官方文檔,,不過有點舊,和實際情況有些出入,, http://www./file-access/default/members/jbossas/freezone/docs/Clustering_Guide/5/html/index.html 我采用的是 apache2.27 JK_mod1.2.7 apache的下載地址: http://httpd./download.cgi JK_mod的下載地址: http://www./dist/tomcat/tomcat-connectors/jk/binaries/ 安裝完畢后開始進行配置 首先,,編輯 apache的conf/http.conf 文件,保證apache加載jk_mod文件,,再文件中加入下面的代碼 Java代碼
Include conf/mod-jk.conf
然后再apache的conf/http.conf 創(chuàng)建一個新的文件 名字要和上面的 mod-jk.conf 一致,,再文件中計入下面的代碼: Java代碼
# Load mod_jk module # Specify the filename of the mod_jk lib LoadModule jk_module modules/mod_jk.so # Where to find workers.properties JkWorkersFile conf/workers.properties # Where to put jk logs JkLogFile logs/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel info # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" # JkOptions indicates to send SSK KEY SIZE JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # JkRequestLogFormat JkRequestLogFormat "%w %V %T" # Mount your applications JkMount /application/* loadbalancer # You can use external file for mount points. # It will be checked for updates each 60 seconds. # The format of the file is: /url=worker # /examples/*=loadbalancer JkMountFile conf/uriworkermap.properties # Add shared memory. # This directive is present with 1.2.10 and # later versions of mod_jk, and is needed for # for load balancing to work properly JkShmFile logs/jk.shm # Add jkstatus for managing runtime data <Location /jkstatus/> JkMount status Order deny,allow Deny from all Allow from 127.0.0.1 </Location>
這里注意這句話,要把你下載的mod_jk的文件拷貝到 apache安裝目錄的modules/下 名字要和mod_jk.so一致 Java代碼
LoadModule jk_module modules/mod_jk.so
然后,,我們再apache安裝目錄下的conf/創(chuàng)建 Java代碼
/jmx-console=loadbalancer /jmx-console/*=loadbalancer /web-console=loadbalancer /web-console/*=loadbalancer
然后再 apache安裝目錄下conf/workers.properties加入 負載均衡的配置代碼 Java代碼
# Define list of workers that will be used # for mapping requests worker.list=loadbalancer,status # Define Node1 # modify the host as your host IP or DNS name. worker.node1.port=8009 worker.node1.host=192.168.1.188 worker.node1.type=ajp13 worker.node1.lbfactor=1 worker.node1.cachesize=10 # Define Node2 # modify the host as your host IP or DNS name. worker.node2.port=8009 worker.node2.host= 192.168.1.100 worker.node2.type=ajp13 worker.node2.lbfactor=1 worker.node2.cachesize=10 # Load-balancing behaviour worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=node1,node2 worker.loadbalancer.sticky_session=1 #worker.list=loadbalancer # Status worker for managing load balancer worker.status.type=status
到此 JK_mod 的配置就完成了,,下面配置JBOSS的,,這里注意這里文檔說的有些問題,,因為JBOSS-5.0.0GA的目錄有些變化 文檔上說的是下面的路徑
但正確的應該是
/jbossweb.sar/ 配置修改如下:注意 這里面的jvmRoute="node1"的名字要和jk_mod里面的一致否則會有問題 Java代碼
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1"> ... ... </Engine>
到這里JBOSS的基本配置就完成了,JBOSS-5.0.0GA的session共享是默認的配置的 只要再APPLICATION中加入下面的代碼就可以 Java代碼
<?xml version="1.0"?> <web-app xmlns="http://java./xml/ns/j2ee" xmlns:xsi="http://www./2001/XMLSchema-instance" xsi:schemaLocation="http://java./xml/ns/j2ee http://java./xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <distributable/> <!-- ... --> </web-app>
啟動的JBOSS run.sh -c all -b 192.168.2.100 注意IP地址要和JK_MOD配置的一致 我把我寫的簡單的測試放入到 附件中,,測試的時候先打開一個node1 做登陸
然后啟動第二個node2 然后停掉node1 還是登陸狀態(tài) http://localhost/cluster-test/index2.jsp JBOSS的配置 缺少了集群的hot-deploy 因為JBOSS5里面已經(jīng)沒有farm service 了,,找了很多文檔,沒有找到解決的辦法,,希望和大家共同研究,。 |
|