Created by kylin.12th, Dec
Download
httpd-2.2.29.tar.gz
from http://httpd.apache.org/download.cgiapr-1.5.1.tar.gz
and apr-util-1.5.4.tar.gz
from http://apr.apache.org/download.cgiInstall
//
$ cd /opt
$ sudo tar zxvf httpd-2.2.29.tar.gz
$ cd /opt/httpd-2.2.29
$ sudo ./configure --prefix=/opt/httpd --with-mpm=worker --enable-mods-shared=most --enable-maintainer-mode
--with-expat=builtin --enable-ssl --enable-proxy --enable-proxy-http --enable-proxy-ajp --disable-proxy-balancer
--with-included-apr
$ sudo make
$ sudo make install
//Edit the “/opt/httpd/conf/httpd.conf” file, replace “#ServerName www.example.com:80” with
ServerName balancer-one.com:80
//Edit the “/etc/hosts” file, add
127.0.0.1 balancer-one.com
$ cd /opt/httpd/bin
$ ./httpd -k start -f /opt/httpd/conf/httpd.conf
Verify installation http://balancer-one.com/
Download
mod_cluster-1.2.6.Final-linux2-x64-so.tar.gz
from http://mod-cluster.jboss.org/downloads/1-2-6-Final-binInstall
//
$ cd /opt/httpd/modules
$ tar zxvf mod_cluster-1.2.6.Final-linux2-x64-so.tar.gz
mod_advertise.so
mod_manager.so
mod_proxy_cluster.so
mod_slotmem.so
Create a private network interface
//
$ sudo ifconfig eth0:1 10.0.0.1 netmask 255.255.255.0
Comment out mod_proxy_balancer.so(only for yum install)
// Edit the “/opt/httpd/conf/httpd.conf” file, comment out the following line
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
Create “mod_cluster.conf” under “/opt/httpd/conf/extra”
//
$ touch /opt/httpd/conf/extra/mod_cluster.conf
Edit “mod_cluster.conf” with content
//
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
Listen 10.0.0.1:6666
Order deny,allow
Deny from all
Allow from all
SetHandler mod_cluster-manager
Order deny,allow
Allow from all
ServerAdvertise on http://10.0.0.1:6666
EnableMCPMReceive
Edit again the “httpd.conf” file and add the following
//
# ModCluster settings
Include conf/extra/mod_cluster.conf
Restart/Start httpd
//
$ cd /opt/httpd/bin
$ sudo ./httpd -k start -f /opt/httpd/conf/httpd.conf
Verify installation http://10.0.0.1:6666/mod_cluster-manager
//
$ cd $JBOSS_HOME
$ cp -a standalone bl-std-node-1
$ cp -a standalone bl-std-node-2
$ cp balancing-test.war bl-std-node-1/deployments/
$ cp balancing-test.war bl-std-node-2/deployments/
$ sudo ifconfig eth0:2 10.0.1.1 netmask 255.255.255.0
$ sudo ifconfig eth0:3 10.0.1.2 netmask 255.255.255.0
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-std-node-1 --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.1 -Djboss.management.http.port=19990 -Djboss.node.name=node-1
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-std-node-2 --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.2 -Djboss.management.http.port=29990 -Djboss.node.name=node-2
Balancing and clustering communication with UDP
//
$ cd $JBOSS_HOME
$ cp -a standalone bl-tcp-std-node-1
$ cp -a standalone bl-tcp-std-node-2
$ cp balancing-test.war bl-tcp-std-node-1/deployments/
$ cp balancing-test.war bl-tcp-std-node-2/deployments/
$ sudo ifconfig eth0:1 10.0.1.1 netmask 255.255.255.0
$ sudo ifconfig eth0:2 10.0.1.2 netmask 255.255.255.0
Update mod_cluster configuration
//
Order deny,allow
Deny from all
Allow from 10.0.0.1
ServerAdvertise off
EnableMCPMReceive
Configure modcluster in Widfly
//
Start Cluster nodes
//
$ cd $JBOSS_HOME
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-tcp-std-node-1 --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.1 -Djboss.management.http.port=19990 -Djboss.node.name=node-1
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-tcp-std-node-2 --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.2 -Djboss.management.http.port=29990 -Djboss.node.name=node-2
Balancing and clustering communication with TCP
//
$ cd $JBOSS_HOME
$ cp -a standalone bl-http-std-node-1
$ cp balancing-test.war bl-http-std-node-1/deployments/
Configure undertow subsystem
//
Configure modcluster subsystem
//
Configure remoting subsystem
//
Start WildFly
//
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-http-std-node-1 --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.1 -Djboss.management.http.port=19990 -Djboss.node.name=node-1
//
$ cd $JBOSS_HOME
$ cp -a standalone bl-persist-std-node-1
$ cp balancing-test.war bl-persist-std-node-1/deployments/
$ sudo ifconfig eth0:1 10.0.1.1 netmask 255.255.255.0
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-persist-std-node-1 --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.1 -Djboss.management.http.port=19990 -Djboss.node.name=node-1
Configure PersistSlots on in mod_cluster
//
...
Listen 10.0.0.1:6666
PersistSlots On
//
$ cd $JBOSS_HOME
$ cp -a standalone bl-std-node-bar
$ cp -a standalone bl-std-node-foo
$ cp app-bar-with-this-context.war bl-std-node-bar/deployments/
$ cp app-foo-with-this-context.war bl-std-node-foo/deployments/
$ sudo ifconfig eth0:1 10.0.1.1 netmask 255.255.255.0
$ sudo ifconfig eth0:2 10.0.1.2 netmask 255.255.255.0
$ sudo ifconfig eth0:3 10.0.0.1 netmask 255.255.255.0
$ sudo ifconfig eth0:4 10.0.0.2 netmask 255.255.255.0
$ sudo ifconfig eth0:5 10.0.0.3 netmask 255.255.255.0
Configure mod_cluster in Apache
//
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
PersistSlots On
ServerAdvertise Off
Listen 10.0.0.3:80
ServerName mcm.com
SetHandler mod_cluster-manager
Order deny,allow
Deny from all
Allow from all
Configure mod_cluster in Apache
//
Listen 10.0.0.1:80
ServerName bar.com
Order deny,allow
Deny from all
Allow from all
EnableMCPMReceive On
CreateBalancers 1
ProxyPass / balancer://barBalancer/this
Configure mod_cluster in Apache
//
Listen 10.0.0.2:80
ServerName foo.com
Order deny,allow
Deny from all
Allow from all
EnableMCPMReceive On
CreateBalancers 1
ProxyPass / balancer://fooBalancer/this
Mapping app in hosts
//
10.0.0.3 mcm.com
10.0.0.1 bar.com
10.0.0.2 foo.com
Configure node-bar
//
Start node-bar
//
$ cd $JBOSS_HOME
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-std-node-bar --server-config=standalone-ha.xml
-Djboss.bind.address=10.0.1.1 -Djboss.management.http.port=19990 -Djboss.node.name=node-bar -Dbalancer.name=barBalancer
-Dproxy.list=10.0.0.1:80 -Djboss.default.multicast.address=230.0.1.4
Configure node-foo
//
Start node-foo
//
$ cd $JBOSS_HOME
$ ./bin/standalone.sh -Djboss.server.base.dir=bl-std-node-foo --server-config=standalone-ha.xml -Djboss.bind.address=10.0.1.2
-Djboss.management.http.port=29990 -Djboss.node.name=node-foo -Dbalancer.name=fooBalancer
-Dproxy.list=10.0.0.2:80 -Djboss.default.multicast.address=230.0.2.4