Liferay 集群

本文详细介绍了如何在Liferay应用中配置JBoss服务器实现主从切换模式的负载均衡,包括软件准备、mod_jk.so模块配置、节点集群配置、JBoss集群节点配置、Portal配置、集群测试等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 Liferay JBoss Master/Slave Failover Mode Configuration

 

 

1Prepare software

1.1Apache 2.2 httpd-2.2.22-win32-x86-openssl-0.9.8t.msi

1.2LF JBoss(2 instances) 

1.3mod_jk.so tomcat-connectors-1.2.37-windows-i386-httpd-2.2.x.zip

 

 

2mod_jk.so

2.1Rename to mod_jk.so and copy to %APACHE_HOME%/modules directory

 

2.2Load the mod_jk.so connector

Modify %APACHE_HOME%/conf/httpd.conf file, add below line to bottom line.

LoadModule jk_module modules/mod_jk.so

 

2.3Configure mod_jk for cluster nodes.

Modify “httpd.conf” file, add below lines to bottom line. 

JkWorkersFile conf/workers.properties

JkLogFile logs/mod_jk.log

JkMount /* loadbalancer

 

2.4Need to create a file named workers.properties in conf directory. And add below lines in it.

# Define list of workers that will be used

# for mapping requests

worker.list=loadbalancer,status

 

# Define Master

worker.master.host=10.25.153.107

worker.master.port=8009

worker.master.type=ajp13

worker.master.lbfactor=1

worker.master.cachesize=10

worker.master.cache_timeout=600

worker.master.socket_timeout=5

worker.master.recycle_timeout=20

worker.slave.prepost_timeout=1

worker.master.recovery_options=0

worker.master.connection_pool_timeout=5

worker.master.ping_mode=A

worker.master.ping_timeout=500

worker.master.connect_timeout=500

 

# Define prefered failover node for master

worker.master.redirect=slave

 

# Define Slave

worker.slave.host=127.0.0.1

worker.slave.port=8009

worker.slave.type=ajp13

worker.slave.lbfactor=1

worker.slave.cachesize=10

worker.slave.cache_timeout=600

worker.slave.socket_timeout=60

worker.slave.recycle_timeout=100

worker.slave.prepost_timeout=50

worker.slave.recovery_options=0

worker.slave.connection_pool_timeout=60

worker.slave.ping_mode=A

worker.slave.ping_timeout=20000

worker.slave.connect_timeout=20000

 

#Disable slave for all requests except failover

worker.slave.activation=disabled

 

# Load-balancing behaviour

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=master,slave

worker.loadbalancer.sticky_session=1

 

# Status worker for managing load balancer

worker.status.type=status

 

 

3Configure JBoss to Cluster node.

3.1In file standalone/configuration/standalone.xml, add content as grew part below

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="master" native="false">

            <configuration>

                <jsp-configuration development="true"/>

            </configuration>

            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>

            <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>

            <virtual-server name="default-host" enable-welcome-root="false">

                <alias name="localhost"/>

                <alias name="example.com"/>

            </virtual-server>

        </subsystem>

 

3.2Add interface for specific ip

Add gray part as below, and change xxx.yyy.aaa.bbb to your jboss server ip.

<interfaces>

        <interface name="management">

            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>

        </interface>

        <interface name="public">

            <inet-address value="${jboss.bind.address:127.0.0.1}"/>

        </interface>

        <interface name="unsecure">

            <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>

        </interface>

        <interface name="specific-ip-interface">

            <inet-address value=" xxx.yyy.aaa.bbb "/>

        </interface>

</interfaces> 

 

3.3Change below gray part according to the interface added above.

 

<socket-binding-group name="standard-sockets" default-interface="specific-ip-interface" port-offset="${jboss.socket.binding.port-offset:0}">

<socket-binding name="management-native" interface="specific-ip-interface" port="${jboss.management.native.port:9999}"/>

<socket-binding name="management-http" interface="specific-ip-interface" port="${jboss.management.http.port:9990}"/>

<socket-binding name="management-https" interface="specific-ip-interface" port="${jboss.management.https.port:9443}"/>

<socket-binding name="ajp" port="8009"/>

 

 

4Configure Portal portal-ext.properties

cluster.link.enabled=true

lucene.replicate.write=true

 

5Test cluster server

5.1Visit URL http://localhost, you will see apache server default page.

5.2Visit URL http://localhost/c/portal/login twice with two browsers, you will see 

the same page which response by master node as below.

 

5.3Shut down master node, observe the page from salve node as below.

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值