Agile DevOps - People and Process then Automation!!!

Use Cloud and DevOps to build infrastructure by rapid agile iterative development using collaborative open source tools:
-Terraform or Cloud Formation for easy orchestration.
-chef cookbooks, puppet modules or ansible playbooks to build servers.
-Test Kitchen to deploy and test them.
-Packer for build server images or containers.
-EC2Dream a graphic user interface that provides a 'single pane of glass' to do agile devops primarily on cloud servers.
-Amazon AWS, Azure, Google Compute Engine, IBM, Openstack, Local and Hosted servers.

JBoss Clustering in Amazon EC2

Amazon AWS does not allow multicasting so the default clustering configuration for JBoss needs configuration.  Here are the steps to configure 2 JBoss nodes of a cluster that will run on AWS.

1. Create 2 security groups JBoss1 and JBoss2 that have group access to each other.

2.  Choose a Linux image and launch with security group JBoss1.  I used image:
           amazon/suse-sles-11-sp1-v1.01.x86_64.

3. Install Java JDK 6.

4. Download JBoss 4.3.2 and unzip:
    wget http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip/download

5. Download concurrent-1.3.2 jar and copy to $JBOSS_HOME/lib as the gossip server requires it.

6. In the jboss bin directory create a file gossip.sh to run the gossip server 
     export JBOSS_HOME=/xxx/jboss-4.2.3.GA
     java -cp $JBOSS_HOME/server/all/lib/jgroups.jar:$JBOSS_HOME/lib/commons-logging.jar:$JBOSS_HOME/lib/concurrent-1.3.2.jar org.jgroups.stack.GossipRouter -port 5555 -expiry 30000 -bindaddress jboss1

7. Edit jboss-4.2.3.GA/server/all/deploy/cluster-service.xml

replace
           <UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}"
                 mcast_port="${jboss.hapartition.mcast_port:45566}"
                 tos="8"
                 ucast_recv_buf_size="20000000"
                 ucast_send_buf_size="640000"
                 mcast_recv_buf_size="25000000"
                 mcast_send_buf_size="640000"
                 loopback="false"
                 discard_incompatible_packets="true"
                 enable_bundling="false"
                 max_bundle_size="64000"
                 max_bundle_timeout="30"
                 use_incoming_packet_handler="true"
                 use_outgoing_packet_handler="false"
                 ip_ttl="${jgroups.udp.ip_ttl:2}"
                 down_thread="false" up_thread="false"/>
            <PING timeout="2000"
                  down_thread="false" up_thread="false" num_initial_members="3"/>
with
            <UDP ip_mcast="false" mcast_addr="244.0.0.35" mcast_port="45566" ip_ttl="32"
             mcast_send_buf_size="150000" mcast_recv_buf_size="80000"/>
            <PING gossip_host="jboss1" gossip_port="5555"
            gossip_refresh="15000" timeout="2000" num_initial_members="2"/>

8.  Save the image

9.  Start a second instances using this image and security group jboss2.

10. On both servers add to the /etc/hosts file the internal ip addresses
For example:
  10.248.11.223  jboss1
  10.248.10.253  jboss2

11. Wait until the operating systems updated network addresses by running
      ping jboss1
      ping jboss2

12. On jboss1 start gossip server
   ./gossip.sh &

13. On jboss1 started jboss
     ./run.sh -c all -g TestCluster -b jboss1

14. On jboss2 started jboss2
   ./run.sh -c all g-TestCluster -b jboss2

15. You will see messages in the startup that show that the cluster formed.
  11:00:59,124 INFO  [TestCluster] Dead members: 0 ([])
  11:00:59,124 INFO  [TestCluster] New Members : 1 ([10.248.10.253:1099])
  11:00:59,124 INFO  [TestCluster] All Members : 2 ([10.248.11.223:1099, 10.248.10.253:1099])

16. To automate the setting of the jboss1 and jboss2 ip addresses:
 a. Install Ruby if not already installed

b.  install rubygems
     wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.19.tgz
     tar xvf rubygems-1.8.19.tgz
    cd rubygems-1.8.19
    ruby setup.rb

c. install right_aws amazon interface
    gem install right_aws

d. download scripts and configure
     settings.rb
     cloud_init.rb

e. create cron job
    crontab -e
    */5 * * * * ruby /root/cloud_init.rb generate_hosts=Y

References
http://www.hugotroche.com/my_weblog/2008/06/clustering-jbos.html
http://xebee.xebia.in/2009/12/03/jboss-clustering-in-5-minutes/
https://community.jboss.org/message/209111
http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html

2 comments:

Anonymous said...

Hi, is there a reason you used such an old JBoss 4.3.2? Will newer JBoss work the same way?

Anonymous said...

No, AS 7 can use the S3_PING protocol instead of the gossip router. It's quiet easy with the Red Hat/JBoss EAP AMIs. This thread could help you with the community version:

https://community.jboss.org/thread/177941

Post a Comment