jboss5的nodename是在
/usr/local/jboss-5.1.0.GA/server/dms/deploy/jbossweb.sar/server.xml 这里的 jvmroute
需要和Apache对应
转载原路径:http://blog.sina.com.cn/s/blog_5ca9fdd80100ecrq.html
最近公司要用到Jboss5.1,临时研究了下,发现与Jboss4配置相当多的不同,现在把配置过程发上来,希望对有需要的朋友,有帮助。(备注:经过测试的)
jboss5.1+jdk6.0+apache2.2.11+mod_jk集群配置 配置: 1:环境变量配置 JAVA_HOME=jdk1.6.0_14 JBOSS_HOME=jboss-5.1.0.GA PATH 2:JBOSS配置 1:修改端口: JBOSS_HOME/server/all/deploy/jbossweb.sar/server.xml <!-- … <Connector protocol="HTTP/1.1" port="8080" address="${0.0.0.0}" -> <Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1"> … </Engine> 将8080修改为你想要的端口,将${jboss.bind.address}修改为0.0.0.0,允许从eth0,eth1,lo都能够访问jboss 80端口,也可以在启动参数中指定ip地址选项,指定绑定的ip地址:run.bat -b x.x.x.* 另外一台jboss同样配置,注意node2。 补充:jboss的监听地址一定要写网卡绑定的ip,要跟前端apache mod_jk配置中指定的ip一致,最好在同一个网段如172.16.9.*,同时一定修改启动监听地址为0.0.0.0,否则apache 的mod-jk无法转发request. 默认启动后,访问apache所在的机器ip。。。如果访问1服务,停掉1服务后,则会自动切换到2服务。 2.放开useJK JBOSS_HOMEserveralldeployersjbossweb.deployerMETA-INFwar-deployers-jboss-beans.xml把下面注释放开,修改 <property name="useJK">true</property> <property name="useSessionPassivation">true</property> <property name="passivationMaxIdleTime">-1</property> <property name="passivationMinIdleTime">-1</property> 3.Apache配置 a. 将下载的apache mod_jk重命名为mod_jk.so,复制到APACHE_HOME/modules/中,修改 APACHE_HOME/conf/httpd.conf,在文件末添加: # Include mod_jk's specific configuration file Include conf/mod-jk.conf LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule status_module modules/mod_status.so <Proxy *> Order deny,allow allow from all </Proxy> ProxyPass / balancer://proxy/ stickysession=JSESSIONID nofailover=On lbmethod=byrequests ProxyPassReverse / balancer://proxy/ <Proxy balancer://proxy> BalancerMember ajp://192.168.1.14:8009/ loadfactor=50 route=note1 BalancerMember ajp://192.168.1.13:8009/ loadfactor=50 route=note2 </Proxy> ProxyPass为代理转发的Url,即将所有访问/的请求转发到群集balancer://proxy loadfactor为各主机间的负载比例参数,可是设置不同指数 BalancerMember为群集的成员,即群集服务器A或B,负载均衡服务器会根据均衡规则来将请求转发给BalancerMember. b. 在APACHE_HOME/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 /*.* 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> c. 在APACHE_HOME/conf/目录创建新文件uriworkermap.properties,内容如下: /jmx-console=loadbalancer /jmx-console/*=loadbalancer /web-console=loadbalancer /web-console/*=loadbalancer 这将配置从mod_jk将转发请求到/jmx-console,转发 /web-console 到JBOSS. d. 在APACHE_HOME/conf/目录创建新文件workers.properties,内容如下: # Define list of workers that will be used # for mapping requests worker.list=loadbalancer,status # worker.list=loadbalancer,node1,node2 # Define Node1 # modify the host as your host IP or DNS name. worker.node1.port=8009 worker.node1.host=192.168.1.14 worker.node1.type=ajp13 worker.node1.lbfactor=1 worker.node1.cachesize=100 # Define Node2 # modify the host as your host IP or DNS name. worker.node2.port=8009 worker.node2.host= 192.168.1.13 worker.node2.type=ajp13 worker.node2.lbfactor=1 worker.node2.cachesize=100 # 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 上面的文件中配置了两个节点,name分别为node1,node2,指定两个节点的IP,并在worker.loadbalancer.balance_workers中指定所有的node列表, worker.loadbalancer.sticky_session设置是否启用“粘着的”Session,sticky session是指来自同一IP的请求将被发送到同一个Jboss节点, sticky session设为0的话同一session的不同请求会被负载均衡分发到不同的jboss节点上。 e. 修改应用程序的web.xml文件,添加<distributable />元素. 保持session同步用 至此,jboss集群环境已经基本配置完成,启动先启动apache,然后启动jboss,可测试,启动jboss时需指定run.bat -c all ,default配置是不支持集群的。
jboss-web.xml
转载:https://www.cnblogs.com/feng9exe/p/11287598.html
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
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/application_1_4.xsd">
<display-name>JBossDukesBank</display-name>
<module>
<ejb>bank-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>web-client.war</web-uri>
<context-root>bank</context-root>
</web>
</module>
</application>