Friday, October 20, 2006

Jboss HTTP Clustering Part1 (Load balancing)
  1. Download apache2.x and mod_jk 1.2.x. Compile and install.
  2. Modify APACHE_HOME/conf/httpd.conf and add a single line at the end of the file:
    # Include mod_jk's specific configuration file
    Include conf/mod-jk.conf
  3. Create a new file named APACHE_HOME/conf/mod-jk.conf:

    # Specify the filename of the mod_jk lib
    LoadModule jk_module modules/mod_jk.so

    # Where to find workers.properties
    JkWorkersFile conf/workers.properties

    # Where to put jk logs
    JkLogFile logs/mod_jk.log

    # Set the jk log level [debug/error/info]
    JkLogLevel info

    # Select the log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

    # JkOptions indicates to send SSK KEY SIZE
    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

    # JkRequestLogFormat
    JkRequestLogFormat "%w %V %T"

    # Mount your applications
    JkMount /application/* loadbalancer

    # You can use external file for mount points.
    # It will be checked for updates each 60 seconds.
    # The format of the file is: /url=worker
    # /examples/*=loadbalancer
    JkMountFile conf/uriworkermap.properties

    # Add shared memory.
    # This directive is present with 1.2.10 and
    # later versions of mod_jk, and is needed for
    # for load balancing to work properly
    JkShmFile logs/jk.shm

    # Add jkstatus for managing runtime data
    <Location /jkstatus/>
    JkMount status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Location>

    The LoadModule directive must reference the mod_jk library you have downloaded in the previous section. You must indicate the exact same name with the "modules" file path prefi

  4. Create a uriworkermap.properties file in the APACHE_HOME/conf directory.
    # Simple worker configuration file

    # Mount the Servlet context to the ajp13 worker
    /jmx-console=loadbalancer
    /jmx-console/*=loadbalancer
    /web-console=loadbalancer
    /web-console/*=loadbalancer
  5. Create a file APACHE_HOME/conf/workers.properties

    # 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=node1.mydomain.com
    worker.node1.type=ajp13
    worker.node1.lbfactor=1
    worker.node1.cachesize=10

    # Define Node2
    # modify the host as your host IP or DNS name.
    worker.node2.port=8009
    worker.node2.host= node2.mydomain.com
    worker.node2.type=ajp13
    worker.node2.lbfactor=1
    worker.node2.cachesize=10

    # Load-balancing behaviour
    worker.loadbalancer.type=lb
    worker.loadbalancer.balance_workers=node1,node2
    worker.loadbalancer.sticky_session=1
    #worker.list=loadbalancer

    # Status worker for managing load balancer
    worker.status.type=status
  6. Configure JBoss

    Edit the
    JBOSS_HOME/server/all/deploy/jbossweb-tomcat50.sar/server.xml
    file (replace /all with your own server name if necessary).
    Locate the <Engine> element and add an attribute
    jvmRoute:


    <Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">
    ... ...
    </Engine>


    Edit the
    JBOSS_HOME/server/all/deploy/jbossweb-tomcat50.sar/META-INF/jboss-service.xml
    file (replace /all with your own server name). Locate the
    <attribute> element with a name of UseJK, and
    set its value to true:


    <attribute name="UseJK">true</attribute>


    The full document is located @
    http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html





0 comments: