Window上配置JBoss集群
原创文章,欢迎转载,转载时务必注明原文地址及作者
一.安装前的准备
1.JDK1.5 (jdk1.5.0_18)
2.JBOSS4.2 (jboss-4.2.3.GA)
3.Apache2.0 (apache_2.0.63-win32-x86-no_ssl.msi)
4.mod_jk (mod_jk-1.2.28-httpd-2.0.52.so)
二.安装Apache
双击运行 apache_2.0.63-win32-x86-no_ssl.msi 安装Apache2.0,无需任何配置
下面步骤中提到的[APACHE_HOME]就是指这里安装Apache2.0的根目录
三.配置负载平衡mod_jk
1.修改 APACHE_HOME/conf/httpd.conf 文件,在文件的最后添加下面内容:
# Include mod_jk's specific configuration file Include conf/mod-jk.conf
# 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 /SessionSample/* 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>
# Simple worker configuration file# Mount the Servlet context to the ajp13 worker/jmx-console=loadbalancer/jmx-console/*=loadbalancer/web-console=loadbalancer/web-console/*=loadbalancer
# Define list of workers that will be used# for mapping requestsworker.list=loadbalancer,status# Define Node1 worker.node1.port=8009worker.node1.host=192.168.1.43worker.node1.type=ajp13worker.node1.lbfactor=1worker.node1.cachesize=10# Define Node2 worker.node2.port=8009worker.node2.host=192.168.1.17worker.node2.type=ajp13worker.node2.lbfactor=1worker.node2.cachesize=10# Load-balancing behaviour worker.loadbalancer.type=lbworker.loadbalancer.balance_workers=node1,node2 worker.loadbalancer.sticky_session=0# Status worker for managing load balancer worker.status.type=status
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">...</Engine>
...<attribute name="UseJK">true</attribute>...
<?xml version="1.0"?> <web-app xmlns="http://java.sun.com/xml/ns/"Whats_new_in_JBoss_4-J2EE_Certification_and_Standards_Compliance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <distributable/> <!-- ... --></web-app>
<jboss-web> <replication-config> <replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger> <replication-granularity>SESSION</replication-granularity> <replication-field-batch-mode>true</replication-field-batch-mode> </replication-config></jboss-web>
run.bat -c all -b 192.168.1.43