Introduction
In this tutorial, we will demonstrate how to download, install, start and stop a JBoss EAP 6.0.0 server on Red Hat 6.3. We use OpenJDK 6 for this tutorial. This is the same installation procedure for CentOS and Fedora. All steps in this tutorial must be performed as root.
This tutorial consists of the following steps
- Step 1: JDK installation and verification
- Step 2: Download JBoss and the installation procedure
- Step 3: Add the appropriate user
- Step 4: Create the JBoss EAP 6.0.0 standalone service
- Step 5: Activate the JBoss EAP 6.0.0 standalone service
- Step 6: Start the JBoss EAP 6.0.0 standalone service
- Step 7: Stop the JBoss EAP 6.0.0 standalone service
- Step 8: Restart the JBoss EAP 6.0.0 standalone service
Step 1: JDK Installation and verification
The first step before installing JBoss EAP 6, is to install a JDK. Any JDK can be used, such as Sun JDK, OpenJDK, IBM JDK, or JRocket etc. We chose Open JDK 6 for this tutorial, because it is the new Java reference implementation starting with Java 7.
NOTE: JDK 7 and above can also be used with JBoss. A JRE is also sufficient to run JBoss EAP 6, however a JRE does not include some of the additional feature of a JDK.
Installing OpenJDK:
Issue the following command to install the JDK:
$ yum install java-1.6.0-openjdk-devel
Confirming the install:
Issue the following command to confirm that the proper version of the JDK is on your classpath:
$ java -version
Step 2: Download JBoss and the installation procedure
The next step is to download the appropriate version of JBoss EAP 6. We will download the .zip version of JBoss AS EAP 6.0.0, and install it using the unzip utility.
Downloading JBoss EAP 6.0.0:
jboss-eap-6.0.0.zip can also be downloaded with your favorite browser from the https://access.redhat.com/jbossnetwork/restricted/listSoftware.html.
Installing JBoss EAP 6.0.0:
Next, we issue the following unzip command to finally install jboss-eap-6.0.0 in the /usr/share directory:
$ unzip jboss-eap-6.0.0.zip -d /usr/share
Alternatively, any directory can be chosen for the JBoss 6 installation.
Step 3: Add the appropriate user
Now that JBoss EAP 6 is installed, we need to make sure that we create a user with the appropriate privileges. It is never a good idea to run JBoss as root for various reasons.
Create the new user:
We create a new user called jboss by issuing the following command:
$ adduser jboss
Alternatively, any username can be used. However, the username must be specified in the jboss-as.conf file.
Change ownership of the installation directory:
We need to assign the appropriate ownership to the installation directory for the newly created jboss user by issuing the command:
$ chown -fR jboss.jboss /usr/share/jboss-eap-6.0/
Change directory to the jboss bin directory:
Now, lets change directories to the JBoss bin directory. This dorectory contains the necessary scripts to start, stop and manage your JBoss installation.
$ cd /usr/share/jboss-eap-6.0/bin
Add a jboss management user:
The final step before we install the service, is to add a management user. This is an internal JBoss management user, necessary to access the new JBoss management console.
$ ./add-user.sh
You should see the following message on the console after executing the command:
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): a
We select “a”, next you should see the following message:
Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : jboss
Password :
Re-enter Password :
* hit enter for Realm to use default, then provide a username and password
We select the default value for the Realm (ManagementRealm), by hitting enter, and select “jboss” as our username. By default, we supply “jb0ss” as our password, of course, you can provide any password you prefer here.
Step 4: Create the JBoss EAP 6.0.0 standalone service:
Now that JBoss EAP 6 are configured with the admin user, we can proceed with creating the JBoss service.
Link the jboss-as-standalone.sh script to init.d:
We need create a symbolic into init.d. The name of the target is the name of the service, which in this example is jboss-as:
$ /bin/ln -s -T /usr/share/jboss-eap-6.0/bin/init.d/jboss-as-standalone.sh /etc/init.d/jboss-as
Link the jboss-as installation directory to /usr/share/jboss-as:
/bin/ln -s -T /usr/share/jboss-eap-6.0 /usr/share/jboss-as
Create the /etc/jboss-eap directory:
$ mkdir /etc/jboss-as
Change ownership of the /etc/jboss-as directory:
$ chown jboss:jboss /etc/jboss-as
Link the jboss-as.conf file to /etc/jboss-as:
There is also a jboss-as.conf file that is included with the JBoss EAP 6 Service script. this file is extremely useful in configuring the init.d service with the username, startup and shutdown wait time, and the location of the console log file.
$ /bin/ln -s -T /usr/share/jboss-eap-6.0/bin/init.d/jboss-as.conf /etc/jboss-as/jboss-as.conf
Add the “jboss” user to the jboss-as.conf file:
Edit the “jboss-as.conf” to update the “jboss” user we created:
$ vi /etc/jboss-as/jboss-as.conf
Change the default “jboss-as” user to the “jboss” user we created:
#JBOSS_USER=jboss-as
To:
JBOSS_USER=jboss
Step 5: Setup the server to listen on all interfaces:
Once the appropriate JBoss service is created, we will configure the server to listen on all interfaces for the management and public interfaces.
More information on how to setup an interface of ipaddress is available in the following tutorials:
IP Addresses and Interfaces on JBoss EAP 6 and JBoss AS 7 – Standalone
Edit the default standalone.xml file:
Step 1:
Edit the /usr/share/jboss-as/standalone/configuration/standalone.xml file in your favorite text editor.
Step 2:
Next, update the following section:
From:
<interface name=”management”>
<inet-address value=”${jboss.bind.address:127.0.0.1″/>
</interface>
To:
<interface name=”management”>
<inet-address value=”${jboss.bind.address:0.0.0.0}”/>
</interface>
<interface name=”public”>
<inet-address value=”${jboss.bind.address:0.0.0.0}”/>
</interface>
NOTE: By default, JBoss EAP 6 will only bind to localhost. This does not allow any remote access to your jboss server. For our amazon aws installation, we define the jboss.bind.address property as 0.0.0.0 and jboss.bin.address.management property to 0.0.0.0 as well. This allows us to access the remote JBoss amazon instance over the internet. We could have also defined the hostname of the ami or the ip address. However, unless an elastic ip is used, this value can change. This is why we opted for 0.0.0.0.
Step 6: Activate the JBoss EAP 6.0.0 standalone service:
Now that we have the setup completed, and the appropriate links created, we can activate our JBoss EAP 6 service and register it.
Activate the JBoss EAP 6, standalone service:
In order to activate our service, the first step is to add the service to the system configuration by executing the following using the chkconfig command:
$ chkconfig –add jboss-as
Configure the JBoss EAP 6 service to automatically start and stop:
Next, we issue the following command to start the JBoss EAP 6 standalone service at boot time, and stop it gracefully when the server is shutdown or restarted using the chkconfig command:
$ chkconfig jboss-as on
Step 7: Start the JBoss EAP 6 standalone service:
Once the JBoss EAP 6 standalone service has been setup, we are now ready to start our new JBoss EAP 6 server. We can do this either by restarting our Operating System, or by starting the service manually for the first time. Subsequent Operating System restarts will of course be handled trasparently by the service we added.
Manually startup the JBoss EAP 6 standalone service for the first time:
To manually startup your JBoss EAP 6 service, execute the following command:
$ /sbin/service jboss-as start
Test your JBoss EAP 6 installation:
A good indication of a successful startup is that you can login to the JBoss admin console. Type in the following in your browser window, where yourip should be replaced with the address of your amazon ami:
http://yourip::9990/
This should provide you access to the new admin console, which will be the topic of a future tutorial.
You can also easily check the startus by executing the status command:
$ /sbin/service jboss-as status
Step 8: Stop the JBoss EAP 6 standalone service:
After successfully starting up JBoss EAP 6, lets demonstrate how to shut your JBoss server down in this section.
Manually shutdown the JBoss EAP 6 standalone service:
To shutdown your JBoss EAP 6 service, execute the following command:
$ /sbin/service jboss-as stop
Step 9: Restart the JBoss EAP 6 standalone service:
Your JBoss EAP 6 service can also be easily restarted with one command. This is demonstrated in this section.
Restart the JBoss EAP 6 standalone service:
To shutdown your JBoss EAP 6 service, execute the following command:
$ /sbin/service jboss-as restart
Step 10: Disable the default firewall on Red Hat 6.3:
Our JBoss instance was not accessible over any HTTP port other than ssh on Amazon, even though the firewall through the amazon security group allowed these ports. This is because the default firewall on our Red Hat installation was enabled by default. To access your JBoss server remotely, this firewall must be updated. For the purpose of this tutorial, we disabled the firewall all together.
Disable the Red Hat firewall:
To disable the Red Hat firewall, execute the following command:
$ yum install system-config-firewall
Using the system-config-firewall
$ system-config-firewall
From the menu, the firewall can be disabled.