设为首页 收藏本站
查看: 339|回复: 0

[经验分享] 在Ubuntu下搭建Liferay 集群

[复制链接]

尚未签到

发表于 2018-5-7 09:50:50 | 显示全部楼层 |阅读模式
  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=&quot;Catalina&quot; defaultHost=&quot;localhost&quot;>
           Replace it with:
           <Engine name=&quot;Catalina&quot; defaultHost=&quot;localhost&quot; jvmRoute=&quot;jvm1&quot;>

           Find the following line:
           <!- - Cluster
           Uncomment it and replace with:
          <Cluster className=&quot;org.apache.catalina.ha.tcp.SimpleTcpCluster&quot; channelSendOptions=&quot;6&quot;>
          <Manager className=&quot;org.apache.catalina.ha.session.BackupManager&quot;
                              expireSessionsOnShutdown=&quot;false&quot;
                              notifyListenersOnReplication=&quot;true&quot;
                              mapSendOptions=&quot;6&quot;/>
         <Channel className=&quot;org.apache.catalina.tribes.group.GroupChannel&quot;>
                   <Membership className=&quot;org.apache.catalina.tribes.membership.McastService&quot;
                                              address=&quot;228.0.0.4&quot;
                                              port=&quot;45564&quot;
                                              frequency=&quot;500&quot;
                                              dropTime=&quot;3000&quot;/>
                  <Receiver className=&quot;org.apache.catalina.tribes.transport.nio.NioReceiver&quot;
                                     address=&quot;auto&quot;
                                     port=&quot;5000&quot;
                                     selectorTimeout=&quot;100&quot;
                                    maxThreads=&quot;6&quot;/>
                 <Sender className=&quot;org.apache.catalina.tribes.transport.ReplicationTransmitter&quot;>
                     <Transport className=&quot;org.apache.catalina.tribes.transport.nio.PooledParallelSender&quot;/>
                 </Sender>
                 <Interceptor className=&quot;org.apache.catalina.tribes.group.interceptors.TcpFailureDetector&quot;/>
                 <Interceptor className=&quot;org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor&quot;/>
                 <Interceptor className=&quot;org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor&quot;/>
         </Channel>
         <Valve className=&quot;org.apache.catalina.ha.tcp.ReplicationValve&quot;
                       filter=&quot;.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;&quot;/>
         <ClusterListener className=&quot;org.apache.catalina.ha.session.ClusterSessionListener&quot;/>
        </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=&quot;true&quot;>


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=&quot;Catalina&quot; defaultHost=&quot;localhost&quot;>
           Replace it with:
           <Engine name=&quot;Catalina&quot; defaultHost=&quot;localhost&quot; jvmRoute=&quot;jvm2&quot;>

           Find the following line:
           <!- - Cluster
           Uncomment it and replace with:
          <Cluster className=&quot;org.apache.catalina.ha.tcp.SimpleTcpCluster&quot; channelSendOptions=&quot;6&quot;>
          <Manager className=&quot;org.apache.catalina.ha.session.BackupManager&quot;
                              expireSessionsOnShutdown=&quot;false&quot;
                              notifyListenersOnReplication=&quot;true&quot;
                              mapSendOptions=&quot;6&quot;/>
         <Channel className=&quot;org.apache.catalina.tribes.group.GroupChannel&quot;>
                   <Membership className=&quot;org.apache.catalina.tribes.membership.McastService&quot;
                                              address=&quot;228.0.0.4&quot;
                                              port=&quot;45564&quot;
                                              frequency=&quot;500&quot;
                                              dropTime=&quot;3000&quot;/>
                  <Receiver className=&quot;org.apache.catalina.tribes.transport.nio.NioReceiver&quot;
                                     address=&quot;auto&quot;
                                     port=&quot;5001&quot;
                                     selectorTimeout=&quot;100&quot;
                                    maxThreads=&quot;6&quot;/>
                 <Sender className=&quot;org.apache.catalina.tribes.transport.ReplicationTransmitter&quot;>
                     <Transport className=&quot;org.apache.catalina.tribes.transport.nio.PooledParallelSender&quot;/>
                 </Sender>
                 <Interceptor className=&quot;org.apache.catalina.tribes.group.interceptors.TcpFailureDetector&quot;/>
                 <Interceptor className=&quot;org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor&quot;/>
                 <Interceptor className=&quot;org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor&quot;/>
         </Channel>
         <Valve className=&quot;org.apache.catalina.ha.tcp.ReplicationValve&quot;
                       filter=&quot;.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;&quot;/>
         <ClusterListener className=&quot;org.apache.catalina.ha.session.ClusterSessionListener&quot;/>
        </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=&quot;true&quot;>


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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-456865-1-1.html 上篇帖子: ubuntu下配置sunjdk和eclipse环境小记 下篇帖子: Ubuntu Server 11.10 安装 Hiphop-php
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表