Sunday, August 2, 2009

Installing Jboss On Linux

This blog decribes how to install and setup jboss to start automatically on RedHat Linux

Step1: Install Java and set environment variables

Please follow this link for instructions

Step2: Create a user called jboss

It always advisable to create a user "jboss" that can be used to start/stop jboss and can be assign permissions
#useradd jboss

Step3: Download appropriate package from Jboss and Install it

#tar -xvxf jboss-5.1.0.GA-jdk6.zip
#mv jboss-5.1.0.GA /usr/local/
#chown -R jboss:jboss /usr/local/jboss-5.1.0.GA
Step4: Set Environment variables for JBOSS

Create a file /etc/profile.d/jboss
# touch /etc/profile.d/jboss
# chmod +x /etc/profile.d/jboss

#vi /etc/profile.d/jboss ( Add the following entries)

#***** Set Env Variables for Jboss

JBOSS_HOME=/usr/local/jboss-5.1.0.GA
export JBOSS_HOME
export PATH=$JBOSS_HOME/bin:$PATH
export LAUNCH_JBOSS_IN_BACKGROUND=1

Step5: Logout from shell to get the above path settings updated

Note: [Instead of creating /etc/profile.d/jboss we can always update the variables in /etc/profile]

Step6: Configure Jboss to script start automatically on restart
Starting from JBoss 4.0.1 and above a sample start-up script ( eq: jboss_init_redhat.sh for redhat) is supplied with the package , we just need to modify it
Copy the script to /etc/init.d and name it as jboss
#cp /usr/local/jboss-5.1.0.GA/bin/jboss_init_redhat.sh /etc/init.d/jboss
#chmod +x /etc/init.d/jboss
Step7: create links

The links will be used to identify at which run levels JBoss should be started and stopped.
#ln -s /etc/rc.d/init.d/jboss /etc/rc3.d/S84jboss
#ln -s /etc/rc.d/init.d/jboss /etc/rc5.d/S84jboss
#ln -s /etc/rc.d/init.d/jboss /etc/rc4.d/S84jboss

#ln -s /etc/rc.d/init.d/jboss /etc/rc6.d/K15jboss
#ln -s /etc/rc.d/init.d/jboss /etc/rc0.d/K15jboss
#ln -s /etc/rc.d/init.d/jboss /etc/rc1.d/K15jboss
#ln -s /etc/rc.d/init.d/jboss /etc/rc2.d/K15jboss
Linux will execute the equivalent of "service jboss start" for the "S" links and "service jboss stop" for the K links.
Red Hat has a chkconfig command to manage these links, which may or may not work (it uses comments in the top of the script to determine which run-levels it should be started/stopped in)
Step8: Modify the script to work with chkconfig command in Redhat

Add the following entries just after #!/bin/sh in the script

#
# JBoss Control Script
#
# chkconfig: 345 80 20
# description: JBoss Startup File
#
#
# To use this script run it as root - it will switch to the specified user
#
Step9: Modify the script with JJboss,JavaPath, User and Host details

Find out the following entries and change according to you installation directories and path

#define where jboss is - this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/usr/local/jboss-5.1.0.GA"}

#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"jboss"}

#make sure java is in your path
JAVAPTH=${JAVAPTH:-"/usr/java/jdk1.6.0_14/bin"}
#bind jboss services to a specific IP address - added by rasith

JBOSS_HOST=${JBOSS_HOST:-"yourserver.yourdomain.com"} Note:[Either give FQDN of your server or IP Address]

Step10: set chkconfig to start jboss in different runlevel

#chkconfig --level 345 jboss on
Step11: Start Jboss and Verify whether it is running properly

#/sbin/service jboss start
You should be able to see jboss up and running at http:://yourserver.yourdomain.com:8080
Use /sbin/service jboss start|stop|restart to start , stop and to restart jboss
Stept12: Restart your server and verify jboss is running automatically after the restart







9 comments:

  1. im abit confuse at step 8:
    how can i go to the #!bin/sh

    im really lost

    ** im very new to Linux..this is my first time acctually using Linux.

    thanks in advance.

    ReplyDelete
  2. as i come to step10:
    i run the #chkconfig --level 345 jboss on
    i face a message "service jboss does not support chkconfig"...any idea where does it goes wrong? pls assist..

    thanks in advance

    ReplyDelete
  3. If you are using redhat linux , adding the below lines in /etc/init.d/jboss (as per step 8) should resolve this issue


    #
    # JBoss Control Script
    #
    # chkconfig: 345 80 20
    # description: JBoss Startup File
    #
    #
    # To use this script run it as root - it will switch to the specified user
    #

    ReplyDelete
  4. how about if i use CentOs 5?

    ReplyDelete
  5. It should work in CentOS too , if you need a sample email script just email me easylinuxstuffs@gmail.com

    ReplyDelete
  6. thanks... i overlook at step7..some typpo error..thanks yar!...

    ReplyDelete
  7. this is vety usefull tips...thanks a lot bussy for your contribution....PLease keep it up your good job. Thanks again

    ReplyDelete
  8. These steps (as posted) worked on Centos 5.
    Thanks!

    ReplyDelete
  9. had a problem with Step 4. Script hasn't been executed. Solved it by renaming "/etc/profile.d/jboss" to "/etc/profile.d/jboss.sh"

    Same is true for "/etc/profile.d/java" to "/etc/profile.d/java.sh"

    ReplyDelete