/lab-jvm-cluster

tomcat6, apache2, postgresql9 cluster

Primary LanguageRubyApache License 2.0Apache-2.0

postgresql9-tomcat6-apache2 cluster:

Provisioning, deployment and clustering of Java Web Applications using puppet.

VM description:

  • OS: Scientific linux 6
  • apache vm: canoe01.farm
  • tomcat vm: marlin01.farm, marlin02.farm
  • postgresql vm: mammoth.farm

Howto

  • create SL64_box using veewee-SL64-box
  • copy ssh_keys from ssh-gerwazy
  • Run on your host machine (desktop): echo '77.77.77.171 canoe_red.qq canoe_blue.qq bering.sea' >> /etc/hosts
    vagrant up
    ssh root@77.77.77.150 #mammoth
    ssh root@77.77.77.161 #marlin01
    ssh root@77.77.77.162 #marlin02
    ssh root@77.77.77.171 #canoe01
    vagrant destroy

Urls to play:

Check on at least 2 webbrowsers to see how load_balancer work or use apache benchmark.

Try stop one tomcatd service and check again.

App Deployment:

Deployment procedure:

Deployment are automated and made by puppet tomcat6::virt_host definition.

Puppet detect if $appSource/context or $appSource/wars directory were changed and apply those modyfications to tomcat server.

Procedure step by step (after change detection):

  • stop tomcatd service
  • clean old appBase
  • deploy new app (new_wars in warBase)
  • deploy new contex
  • start tomcatd service

Example virt_host definition:

    tomcat6::virt_host { "localhost":
        appBase   => "my_webapps",
        warBase   => "my_wars",
        appSource => "/vagrant/samples/java_app",
    }

Deployment play:

wars change:

    touch samples/java_app/wars/empty.war
    vagrant provision
    rm samples/java_app/wars/empty.war
    vagrant provision

contex change:

    mv samples/java_app/context/lighthouse.xml .
    vagrant provision   #then look into bering.sea/lighthouse
    mv lighthouse.xml samples/java_app/context/
    vagrant provision   #then look into bering.sea/lighthouse

src change:

    Import each app to eclipse
    modify sth in source code
    export app as war to proper place
    deploy app (vagrant provision)

Webapps descriptions:

  • java_app (src: samples/java_app/src/):
    • welcome_jsp: simple index.jsp file
    • welcome_servlet: simple servlet with implemented doGet(req,resp) method
    • java_ship_app: simple app with session, doPost(req,resp) method and DB connection

Tests:

Bibliography:

Apache:

Tomcat:

Postgresql:

TODO:

Basic:

Other:

Copyright and license

Copyright 2012, Kamil Wilas (wilas.pl)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.