您的位置:首页 > 运维架构 > Apache

单机创建Glassfish集群(apache jk)

2016-01-05 10:40 549 查看
环境说明:

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

创建集群

运行:asadmin 
启动默认域:start-doamin
创建你的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.*)

将mod_jk.so放到moudles目录下
将如下片段添加到httpd.conf的尾部
将workers.properties放到conf目录下
重启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/>


资料下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: