单机创建Glassfish集群(apache jk)

环境说明:

Windows、jdk1.7、Glassfish4.1、apache2.2.25


创建集群

  1. 运行:asadmin 
  2. 启动默认域:start-doamin
  3. 创建你的cluster:multimode -f commands.txt
create-cluster cluster1
create-local-instance --cluster cluster1 ins1
create-local-instance --cluster cluster1 ins2
create-local-instance --cluster cluster1 ins3
create-network-listener --protocol http-listener-1 --listenerport \${AJP_PORT} --target cluster1 --jkenabled true jk-connector
create-jvm-options --target cluster1 "-DjvmRoute=\${AJP_INSTANCE_NAME}"


create-system-properties --target ins1 AJP_PORT=28009
create-system-properties --target ins2 AJP_PORT=28019
create-system-properties --target ins3 AJP_PORT=28029

create-system-properties --target ins1 AJP_INSTANCE_NAME=ins1
create-system-properties --target ins2 AJP_INSTANCE_NAME=ins2
create-system-properties --target ins3 AJP_INSTANCE_NAME=ins3

list-clusters
start-cluster cluster1


配置apache(2.2.*)
  1. 将mod_jk.so放到moudles目录下
  2. 将如下片段添加到httpd.conf的尾部
  3. 将workers.properties放到conf目录下
  4. 重启apache




使用apache httpd 2.2.*作为前端进行带来配置,样例如下:

LoadModule jk_module modules/mod_jk.so
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 indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /clustWeb to worker named worker1 (ajp13)
JkMount /* checc

workers.properties样例如下:

worker.list=checc
worker.ins1.type=ajp13
worker.ins1.host=localhost
worker.ins1.port=28009
worker.ins1.lbfactor=1
worker.ins1.socket_keepalive=1
worker.ins1.socket_timeout=300

worker.ins2.type=ajp13
worker.ins2.host=localhost
worker.ins2.port=28019
worker.ins2.lbfactor=1
worker.ins2.socket_keepalive=1
worker.ins2.socket_timeout=300

worker.ins3.type=ajp13
worker.ins3.host=localhost
worker.ins3.port=28029
worker.ins3.lbfactor=1
worker.ins3.socket_keepalive=1
worker.ins3.socket_timeout=300

worker.checc.type=lb
worker.checc.sticky_session=1
worker.checc.balance_workers=ins1,ins2,ins3


到此,单机集群搭建完成,下面测试下,测试方法很简单,启动集群后轮流关闭实例,看看应用是否可访问。session复制问题,自己写个简单的jsp应用试试就好,懒得写可以把tomcat的那个关于session的改改就行。

注意web.xml中需要加入此条:

<distributable/>


资料下载




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值