在Ubuntu下搭建Liferay 集群

 Assumption:

 

(1)All the nodes in cluster share the same version of tomcat ,so that one connector(mod-jk) can be suitable for every connection between apache and tomcat.

(2)All the Ubuntu command are marked with abc

(3)All the modification in file are marked with abc

(4)All the important place are marked with red color

(5)An Ubuntu account is created ,here we use portal/portal123 as the authenication

 

Preparation :

 

Before installation ,you need to create the following folders:

~/Downloads-> this folder is used for putting all the installation files

~/software/liferaycluster->this folder is the root folder of our cluster demo

~/software/liferaycluster/apache-> this folder is the root folder for apache server

~/software/liferaycluster/node1->  this folder is the root folder for liferay node1 in cluster

~/software/liferaycluster/node2->this  folder is the root folder for liferay node2 in cluster

 

In addition ,you need to download the following installers into ~/Downloads folder:

apr-1.4.6.tar.gz

apr-util-1.4.1.tar.gz

pcre-8.30.tar.gz

httpd-2.4.2.tar.gz

tomcat-connectors-1.2.35-src.tar.gz

liferay-portal-6.1.0-ce-ga1.tar.gz

 

Then to every .tar.gz file ,do the following operation:

gunzip –d XXX.tar.gz

 

tar xvf XXX.tar

 

 

 

 

Installation:

 

Part 1: install the foundation services in Ubuntu

(1)    Install the g++ (GNU C++ Compiler) ,we need it to compile all the modules provided by  source package.

sudo apt-get install g++

 

(2)    Install the libtool(It’s used for parsing the dependency between Ubuntu libraries)

sudo apt-get install libtool

 

(3)    Install the apr(Apache Portable Runtime ,it can elevate the capability for processing the static pages in Apache)

If we want to install to /usr/local/apr directory

cd ~/Downloads/apr-1.4.6

 

./configure --prefix=/usr/local/apr

 

make

 

sudo make install

 

(4)    Install the apr-util(the utility package for apr)

cd ~/Downloads/apr-util-1.4.1

 

./configure –prefix=/usr/local/apr-util

 

make

 

sudo make install

 

(5)    Install the pcre(Perl Compatible Regular Expression, it is used for executing the mode-match for regular expression)

cd ~/Downloads/pcre-8.30

 

./configure –prefix=/usr/local/pcre

 

make

 

sudo make install

 

 

Part 2: install the apache    

              cd ~/Downloads/httpd-2.4.2

 

             ./configure             --prefix=/home/portal/software/liferaycluster/apache

--with-apr=/usr/local/apr

--with-apr-util=/usr/local/apr-util/

--with-pcre=/usr/local/pcre

--enable-module=so

 

             make

 

             sudo make install

 

Part 3: install the liferay node 1 in cluster

              cd ~/software/liferaycluster/node1

 

              cp -r  ~/Downloads/liferay-portal-6.1.0-ce-ga1  .

 

Part 4: install the liferay node 2 in cluster

              cd ~/software/liferaycluster/node2

 

              cp -r  ~/Downloads/liferay-portal-6.1.0-ce-ga1  .

 

Part 5: install the mysql db

              [Ignore it ,assume you have installed it.]

 

Part 6: install the apache-tomcat connector(mod-jk module ,this is used for making connection between apache and tomcat via ajp protocol)

             cd  ~/Downloads/tomcat-connectors-1.2.35-src/native

 

            ./configure --with-apxs=/home/portal/software/liferaycluster/apache/bin/apxs

                                  --with-tomcat=home/portal/software/liferaycluster/node1/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23

 

             make

 

             sudo make install

    

              After this step ,if you see  mod-jk.so in ~/software/liferaycluster/apache/modules folder ,it means you’ve generated a correct connector file.

 

Part 7:configure the apache

(1)    Configure all the nodes in the cluster which are dispatched from apache.

cd ~/software/liferaycluster/apache/conf

 

touch workers.properties

 

vi workers.properties

 

Then add the following contents:

#Define list of workers that will be used for mapping requests

worker.list=loadbalancer,status

# Define Node1

# modify the host as your host IP or DNS name.

worker.node1.port=8009

worker.node1.host=172.29.54.6

worker.node1.type=ajp13

worker.node1.lbfactor=1

worker.node1.socket_timeout=60

worker.node1.connection_pool_timeout=60

worker.node1.ping_mode=A

worker.node1.ping_timeout=20000

worker.node1.connect_timeout=20000

 

# Define Node2

# modify the host as your host IP or DNS name.

worker.node2.port=8010

worker.node2.host=172.29.54.6

worker.node2.type=ajp13

worker.node2.lbfactor=2

worker.node2.socket_timeout=60

worker.node2.connection_pool_timeout=60

worker.node2.ping_mode=A

worker.node2.ping_timeout=20000

worker.node2.connect_timeout=20000

 

# Load-balancing behaviour

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=node1,node2

worker.loadbalancer.sticky_session=1

# Status worker for managing load balancer

worker.status.type=status

 

(2)    Configure loading the connector module ,configure  the cluster node ,set the logger, define the dispatch rule to cluster node

vi ~/software/liferaycluster/apache/conf/httpd.conf

 

Add the following contents at the end of the file:

 

#Load the mod_jk connector

LoadModule jk_module modules/mod_jk.so

 

# configure the location of the workers.properties

JkWorkersFile conf/workers.properties

 

# configure the location ,level, format of the log file

JkLogFile logs/mod_jk.log

JkLogLevel error

JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

 

#configure the dispatch rule to cluster node

JkMount /* loadbalancer

 

 

Part 8:configure the node1 in cluster

            cd ~/software/liferaycluster/node1/liferay-portal-6.1.0-ce-ga1

 

            touch portal-ext.properties

 

            vi portal-ext.properties

 

            add the following contents:

            #

            # MySQL

            #

            jdbc.default.driverClassName=com.mysql.jdbc.Driver

            jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false

            jdbc.default.username=liferay

            jdbc.default.password=welcome

 

            cd  ~/software/liferaycluster/node1/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/conf

 

            vi server.xml

           

            Find the following line:

           <Engine name="Catalina" defaultHost="localhost">

           Replace it with:

           <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">

 

           Find the following line:

           <!- - Cluster

           Uncomment it and replace with:

          <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;"/>

         <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

        </Cluster>

 

        cd  ~/software/liferaycluster/node1/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/conf

 

        vi context.xml

       

        Find the following line:

        <Context >

        Replace it with:

        <Context distributable="true">

 

               

Part9: configure the node2 in cluster

            cd ~/software/liferaycluster/node2/liferay-portal-6.1.0-ce-ga1

 

            touch portal-ext.properties

 

            vi portal-ext.properties

 

            add the following contents:

            #

            # MySQL

            #

            jdbc.default.driverClassName=com.mysql.jdbc.Driver

            jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false

            jdbc.default.username=liferay

            jdbc.default.password=welcome

 

            cd  ~/software/liferaycluster/node2/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/conf

 

            vi server.xml

           

            Change the following ports:

            Shutdown port from 8005 to 8006

            Http port from 8080 to 8081

            Ajp port from 8009 to 8010

 

            Find the following line:

           <Engine name="Catalina" defaultHost="localhost">

           Replace it with:

           <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm2">

 

           Find the following line:

           <!- - Cluster

           Uncomment it and replace with:

          <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="5001"

                                     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;"/>

         <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

        </Cluster>

 

        cd  ~/software/liferaycluster/node1/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/conf

 

        vi context.xml

       

        Find the following line:

        <Context >

        Replace it with:

        <Context distributable="true">

 

 

Part 10: start the mysql db

        [Ignore it ,assume it started correctly]

 

Part 11: start the apache server

         cd ~/software/liferaycluster/apache/bin

 

         sudo ./httpd –k start

 

Part 12: start the node1

         cd ~/software/liferaycluster/node1/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/bin

 

         sudo ./startup.sh

 

Part 13: start the node2

         cd ~/software/liferaycluster/node2/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/bin

 

         sudo ./startup.sh

 

最后一步,也是我搞错的:

 

必须在每个节点的ROOT应用里面的web.xml加入<distributable/>

在我们的例子中,要在

~/software/liferaycluster/node{1/2}/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/web.xml 里面加上 <distributable/>

 





本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/839967,如需转载请自行联系原作者

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值