在Ubuntu下搭建Liferay 集群

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

 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,如需转载请自行联系原作者

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
3月前
|
Kubernetes Ubuntu 应用服务中间件
在Ubuntu22.04 LTS上搭建Kubernetes集群
在Ubuntu22.04.4上安装Kubernetes v1.28.7,步骤超详细
400 1
在Ubuntu22.04 LTS上搭建Kubernetes集群
|
Kubernetes 网络协议 Ubuntu
Kubeadm 快速搭建 k8s v1.19.1 集群(Ubuntu Server 20.04 LTS)
安装准备工作安装环境要求:角色 实验环境 生产环境 操作系统 master cpu/内存:2 Core/2G cpu/内存:2 Core/4G linux 内核 4.4+ node cpu/内存:1 Core/2G cpu/内存:4 Core/16G linux 内核 4.4+ 备注 Node:应根据需要运行的容器数量进行配置; Linux 操作系统基于 x86_64 架构的各种 Linux 发行版...
982 2
Kubeadm 快速搭建 k8s v1.19.1 集群(Ubuntu Server 20.04 LTS)
|
4月前
|
Kubernetes Ubuntu Docker
百度搜索:蓝易云【Ubuntu系统搭建K8s集群教程】
现在,你已经在Ubuntu系统上成功搭建了一个Kubernetes集群。记得保留好Kubernetes配置文件以便后续管理。
34 0
|
5月前
|
存储 Kubernetes Ubuntu
百度搜索:蓝易云【基于Ubuntu下安装kubernetes集群指南】
通过按照以上步骤,你应该能够在Ubuntu上成功安装和配置Kubernetes集群。请根据具体情况调整IP地址和网络插件的配置。如果遇到任何问题,可以参考Kubernetes官方文档或社区寻求更多帮助。
38 0
|
5月前
|
Kubernetes Cloud Native 安全
云原生|kubernetes|kubernetes集群升级+证书更新(Ubuntu-18.04+kubeadm)
云原生|kubernetes|kubernetes集群升级+证书更新(Ubuntu-18.04+kubeadm)
191 0
|
5月前
|
Kubernetes 负载均衡 Ubuntu
Ubuntu部署K8S1.27.1/containerd集群
Ubuntu部署K8S + containerd 生产环境实践
116 0
|
8月前
|
弹性计算 Ubuntu 应用服务中间件
在Ubuntu 18.04上快速构建minikube集群
本文为您介绍如何快速搭建一个基于Ubuntu的MiniKube集群并部署nginx服务。
159 0
|
Kubernetes Ubuntu 安全
Ubuntu 20.04 环境下初始化k8s集群
Ubuntu 20.04 环境下初始化k8s集群
694 0
|
存储 Ubuntu
Ubuntu用Apache2快速搭建一个HTTP文件服务器
Ubuntu用Apache2快速搭建一个HTTP文件服务器
430 0
|
数据安全/隐私保护
ubuntu2004安装corosync和pacemaker并为集群添加浮动IP
ubuntu2004安装corosync和pacemaker并为集群添加浮动IP
341 0