使用glassfish实现负载均衡和集群
2012-2-27
版本:glassfish v3 apache httpd-2.2.22 mod_jk-apache-2.2.2.so
glassfish已经内部实现集群步骤
启动某个域后,打开后台管理
1.创建一个节点
2.创建一个集群并指向特定节点
3.在集群下创建实例,实例分两种,本机的和远程的。远程的要使用SSH安全套接字。确认后会给出新的监听端口
4.部署一个应用。在应用管理中更改应用的目标,将目标改为集群
5.通过集群实例的url和新端口测试是否成功
使用负载均衡
glassfish内部已经默认支持mod_jk,而且如果使用mod_jk将只能使用apache httpd前端
1.在后台选择glassfish中的集群实例,在实例管理页面中选中使用JK
2.安装httpd
3.在httpd中加入mod_jk加载模块,将mod_jk.so复制到httpd的modules目录下。注意:httpd与mod_jk版本一定要相同
4.配置httpd的conf文件,加入请求监听转向到glassfish集群中的端口
在conf/httpd.conf文件最后加入
include "D:\Apache2.2\conf\mod_jk.conf"
新建文件mod_jk.conf
文件内容
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 error # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " # JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" JkShmFile logs/mod_jk.shm JkMount /* worker1
新建文件workers.properties
内容
# Define 1 real worker using ajp13 worker.list=worker1,worker2,loadbalancer # Set properties for worker1 (ajp13) worker.worker1.type=ajp13 worker.worker1.host=127.0.0.1 worker.worker1.port=28080 worker.worker1.lbfactor=1 worker.worker1.socket_keepalive=1 worker.worker1.reclycle_timeout=300 #worker.worker1.cache_timeout=600 #worker.worker1.cachesize=128 # Set properties for worker2 (ajp13) worker.worker2.type=ajp13 worker.worker2.host=127.0.0.1 worker.worker2.port=28081 worker.worker2.lbfactor=1 worker.worker2.socket_keepalive=1 worker.worker2.reclycle_timeout=300 #worker.worker2.cachesize=128 #worker.worker2.cache_timeout=600 worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=worker1,worker2 #worker.loadbalancer.sticky_session=1
完成,启动httpd,测试成功
相关推荐
phpboy 2008-07-13
中草药代码 2009-07-28
staticnetwind 2013-08-29
netgame 2012-08-09
尘封飞扬 2012-02-22
huangshuailei 2011-10-19
huangshuailei 2010-05-12
tomatoboryj 2009-12-30
程空万里 2009-05-09
huangzhe0 2009-05-01
XingKai 2008-08-30
snctoo 2008-07-13
wangol 2008-06-29
JESSIEfoo 2008-06-24
Qiluluwawa 2008-06-02
being 2008-05-16
JESSIEfoo 2008-03-26
知其然知其所以然 2007-10-26
raksmart0 2011-07-13