Liferay Portal 集群配置指南

最近公司的 OA 系统出现性能问题,虽然问题的根源是应用中的签报系统采用的是 JBPM 框架,该框架在数据库设计方面的低效的惊人,但是在新的签报系统开发出来之前,作为系统运维人员的我们只能先采取其他曲线救国的方式来减少性能问题发生的可能性,所以就有了 OA 系统集群测试环境的搭建这个项目,这篇博文的诞生也拜该项目所赐。配置过程中费了老大的劲,尝试了很多种配置方式,其中的艰辛我就不说了,至少结果是好的。由于公司的 OA 系统是在 Liferay Portal 定制开发的,所以该集群测试环境的搭建也主要是围绕着 Liferay Portal 以及 Apache,Tomcat 来进行。我就不废话了,下面详细介绍 Liferay Portal 集群配置过程:
1. 在两个节点上分别编译安装 Apache :
[root@oaclstest1 media]# yum install openssl openssl-devel
[root@oaclstest1 media]# cd httpd-2.2.14
[root@oaclstest1 httpd-2.2.14]# ./configure --prefix=/usr/local/apache --enable-so --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-scgi --enable-proxy-ajp --enable-proxy-balancer --enable-ssl
[root@oaclstest1 httpd-2.2.14]# make
[root@oaclstest1 httpd-2.2.14]# make install
2. 配置 httpd.conf 文件,添加以下内容:
<VirtualHost *:80>
ServerName 10.1.2.200
#ErrorLog /var/log/apache2/ajp.error.log
#CustomLog /var/log/apache2/ajp.log combined
<Proxy *>
AddDefaultCharSet Off
Order deny,allow
Allow from all
</Proxy>
ProxyPass /balancer-manager !
ProxyPass / balancer://ajpCluster/ stickysession=JSESSIONID
ProxyPassReverse / balancer://ajpCluster/ stickysession=JSESSIONID
<Proxy balancer://ajpCluster>
BalancerMember ajp://10.1.2.190:8009 route=node2
BalancerMember ajp://10.1.2.189:8009 route=node1
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Allow from all
</Location>
</VirtualHost>
3. 配置 RHCS 集群,cluster.conf 文件内容如下:
<?xml version="1.0" ?>
<cluster alias="OaHA" config_version="17" name="OaHA">
<fence_daemon post_fail_delay="0" post_join_delay="3"/>
<clusternodes>
<clusternode name="oaclstest1" nodeid="1" votes="1">
<fence/>
</clusternode>
<clusternode name="oaclstest2" nodeid="2" votes="1">
<fence/>
</clusternode>
</clusternodes>
<cman expected_votes="1" two_node="1"/>
<fencedevices/>
<rm>
<failoverdomains>
<failoverdomain name="Failover_Oa" ordered="0" restricted="1">
<failoverdomainnode name="oaclstest1" priority="1"/>
<failoverdomainnode name="oaclstest2" priority="1"/>
</failoverdomain>
</failoverdomains>
<resources>
<ip address="10.1.2.200" monitor_link="1"/>
<script file="/usr/local/apache/bin/apachectl" name="httpd_script"/>
</resources>
<service autostart="1" domain="Failover_Oa" name="OaHA_Service" recovery="relocate">
<ip ref="10.1.2.200"/>
<script ref="httpd_script"/>
</service>
</rm>
</cluster>
4. 启动集群
[root@oaclstest1 ~]# service cman start
[root@oaclstest2 ~]# service cman start
[root@oaclstest1 ~]# service rgmanager start
[root@oaclstest2 ~]# service rgmanager start
5. 配置 server.xml 文件以(node1 为例):
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="node1">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.BackupManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"
mapSendOptions="6"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="5000"
selectorTimeout="100"
maxThreads="6"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
6. 配置 context.xml 文件:
<?xml version='1.0' encoding='utf-8'?>
<Context distributable="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
7. 配置 EHcache :将 hibernate-clustered.xml 和 liferay-multi-vm-clustered.xml 文件从 portal-impl.jar 里解压出来并且放到一个命名为 myehcache 的文件夹内。然后将 myehcache 文件夹复到 [TOMCAT-HOME]/webapps/ROOT/WEB-INF/classes 目录下。在 portal-ext.properties 文件里加上如下配置信息:
net.sf.ehcache.configurationResourceName=/myehcache/hibernate-clustered.xml
ehcache.multi.vm.config.location=/myehcache/liferay-multi-vm-clustered.xml
8. 配置 Jackrabbit : 请确认在 portal-ext.properties 文件里包含如下配置信息:
dl.hook.impl=com.liferay.documentlibrary.util.JCRHook
9. 开启 clusterLink: 在 portal-ext.properties 文件里加上如下配置信息:
cluster.link.enabled=true
10. 在 Liferay 后台配置 LDAP:将 Authentication Search Filter field 设置成 (&(objectCategory=person)(sAMAccountName=@screen_name@))。
11. 分别启动两个节点上的 Tomcat 应用。
12. 在浏览器中输入 http://10.1.2.200 进行测试。
需要再说明一下的是:在配置 Apache 的负载均衡的过程中,我使用红帽自带的 Apache,一直没有配置成功,最后通过编译安装特定版本的 Apache 才得以成功,这其中失败的原因我还没找到,另外,在编译安装 Apache 后,我没有再尝试使用 mod_jk 模块来实现负载均衡,不过貌似该模块比我配置的 mod_proxy 模块效率高,稳定性好。想更多了解这两个模块的区别的朋友请参考这里。未来我会找时间,再尝试用 mod_jk 模块配置一下。
相关日志:
- 2011年10月11日 -- Oracle HA 脚本 (0)
- 2011年05月20日 -- 在 Cacti 下实现对 Tomcat 的监控 (9)
- 2011年04月19日 -- Red Hat Cluster Suite 概览 (0)
- 2011年03月7日 -- Red Hat GFS 存储解决方案 (1)
Categories
- 信息世界 | IT (85)
- Certification (1)
- Database (15)
- Google (10)
- Hardware (2)
- J2EE (4)
- Network (17)
- OS (17)
- Programming (11)
- Virtualization (1)
- Webmaster (5)
- 数码先锋 | Digital (15)
- 时事评论 | Event (5)
- 时光飞驰 | News (2)
- 杂七杂八 | Mix (2)
- 流金岁月 | Life (9)
- 游戏志 | Game (13)
- 看电影 | Movie (10)
- 红魔拥趸 | ManUtd (5)
- 读书频道 | Reading (1)
- 音乐无限 | Music (5)
- 信息世界 | IT (85)
Latest Comments
- Robin 发表在《查看已经安装的 Perl 模块》
- xiaochuanjiejie 发表在《查看已经安装的 Perl 模块》
- 马继军 发表在《About Me》
- Robin 发表在《在 Cacti 下实现对 Tomcat 的监控》
- 酱油 发表在《在 Cacti 下实现对 Tomcat 的监控》
- dream 发表在《理解 pkg-config 工具》
Twitter
- Chenjunlu’s Blog: 在 MIUI 系统下开启 App2SD+ 功能 http://t.co/t6F5HiRm 2012-02-15
- Chenjunlu’s Blog: 虚拟化 hypervisor 的类型对比 http://t.co/T7hvle03 2012-01-31
- I'm at 公主岭 (Siping) http://t.co/mpEU711u 2012-01-27
- 好像又没动静了。 2012-01-09
- I'm at 宜家家居 IKEA (Dalian) http://t.co/MJWDZt3g 2012-01-07
- I'm at 中山广场 Zhongshan Circus (大连) http://t.co/MyBQWjOF 2012-01-04
- I'm at Changchun Railway Station 长春站 (长白路5号, 长春市) http://t.co/sdcmprTJ 2012-01-03
- I'm at 万达广场 (Shenyang) http://t.co/EfAqBrNn 2011-12-31
- Chenjunlu’s Blog: Liferay Portal 集群配置指南 http://t.co/ANxjlSID 2011-12-26
- I'm at 壹品星海 (Dalian, China) http://t.co/knlcVidX 2011-12-14
- I'm at 五殼日本料理 (Dalian) http://t.co/Zocw45vI 2011-12-10
- I just became the mayor of 五殼日本料理 on @foursquare! http://t.co/rfHazBzj 2011-12-10
- I'm at 壹品星海 (Dalian, China) http://t.co/hQH7xCNa 2011-12-10
- I'm at 奥林匹克广场 Olympics Square (五四路, 大连) http://t.co/BWEGsBpt 2011-12-02
- Chenjunlu’s Blog: Kindle Keyboard 上手玩 http://t.co/hhN6HoN4 2011-12-02
豆瓣生活
Foursquare Checkins
标签
Android Apache Apple Cacti CPAN Digital Signature England Excel VBA Facebook Froyo Google Gravatar HA HTC Desire httpd https IBM iPad J2EE Java JBoss Konami Linux Man Utd Oracle Perl PES2011 Playstation Premier League PSP Red Hat RHCS RHEL RMAN Rooney RSA Secure Shell SNMP South Africa 2010 ssh Windows World Cup 人生 桌游 爱电影




