在Ubuntu下搭建Liferay 集群

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
应用型负载均衡 ALB,每月750个小时 15LCU
网络型负载均衡 NLB,每月750个小时 15LCU
简介:

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

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
目录
相关文章
|
Kubernetes Ubuntu 应用服务中间件
在Ubuntu22.04 LTS上搭建Kubernetes集群
在Ubuntu22.04.4上安装Kubernetes v1.28.7,步骤超详细
6105 3
在Ubuntu22.04 LTS上搭建Kubernetes集群
|
Kubernetes Ubuntu Shell
wsl Ubuntu环境 创建 k8s集群
wsl Ubuntu环境 创建 k8s集群
664 0
|
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 发行版...
1568 2
Kubeadm 快速搭建 k8s v1.19.1 集群(Ubuntu Server 20.04 LTS)
|
监控 Ubuntu 测试技术
Ubuntu 20.04 安装部署 TiDB DM v7.3.0 集群【全网独家】
在Ubuntu上搭建TiDB DM集群的详细步骤分享,作者因工作需求克服了部署难题。测试环境包括3台Ubuntu 20.04主机:1台master和2台worker。首先,确保所有主机安装TiDB单机环境,使用TiUP工具下载并部署。接着,设置主机间免密登录,安装必要组件如sudo、systemd、iproute2和DM组件。配置文件可通过在线或离线方式获取。部署时,根据需求编辑`topology.yaml`,然后使用`tiup dm deploy`命令安装。最后,启动集群并检查节点状态,确认DM集群正常运行。注意,解决内存不足和端口连通性问题以避免错误。
800 3
|
11月前
|
Kubernetes Ubuntu 网络安全
ubuntu使用kubeadm搭建k8s集群
通过以上步骤,您可以在 Ubuntu 系统上使用 kubeadm 成功搭建一个 Kubernetes 集群。本文详细介绍了从环境准备、安装 Kubernetes 组件、初始化集群到管理和使用集群的完整过程,希望对您有所帮助。在实际应用中,您可以根据具体需求调整配置,进一步优化集群性能和安全性。
1022 13
|
存储 关系型数据库 文件存储
Ubuntu22.04LTS基于cephadm快速部署Ceph Reef(18.2.X)集群
这篇文章是关于如何在Ubuntu 22.04LTS上使用cephadm工具快速部署Ceph Reef(18.2.X)存储集群的详细教程,包括ceph的基本概念、集群的搭建步骤、集群管理以及测试集群可用性等内容。
3610 8
Ubuntu22.04LTS基于cephadm快速部署Ceph Reef(18.2.X)集群
|
负载均衡 应用服务中间件 nginx
基于Ubuntu-22.04安装K8s-v1.28.2实验(二)使用kube-vip实现集群VIP访问
基于Ubuntu-22.04安装K8s-v1.28.2实验(二)使用kube-vip实现集群VIP访问
419 1
|
NoSQL Ubuntu Oracle
在Ubuntu 14.04上安装Cassandra并运行单节点集群的方法
在Ubuntu 14.04上安装Cassandra并运行单节点集群的方法
241 0
|
NoSQL Ubuntu Oracle
如何在 Ubuntu VPS 上安装 Cassandra 并运行单节点集群
如何在 Ubuntu VPS 上安装 Cassandra 并运行单节点集群
140 0
|
Kubernetes Ubuntu 安全
Ubuntu 20.04 环境下初始化k8s集群
Ubuntu 20.04 环境下初始化k8s集群
1213 0