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/>
本文出自 “平行线的凝聚” 博客,转载请与作者联系!