Sunday 2 October 2011

JBoss


JBOSS

JBOSS: JBoss Application Server (or JBoss AS) is a free software/open-source Java EE-based application server. An important distinction for this class of software is that it not only implements a server that runs on Java, but it actually implements the Java EE part of Java. Because it is Java-based, the JBoss application server operates cross-platform: usable on any operating system that supports Java. JBoss AS was developed by JBoss, now a division of Red Hat.

Installation:
Step1: Download the packages of jdk and the tar files required for JBoss installation i.e jboss-5.1.0 GAtar.bz2

Step2: Create directory with mkdir /usr/java and /usr/local, now copy the jdk files into /usr/java & JBoss files in /usr/local directory.

Step3: First of all install jdk for this do the following process:
            # cd /usr/java
            # ls -l
            # chmod +x jdk-6u23-linux-i586-rpm.bin (Replace jdk-6u23 with latest version)
            # ./jdk-6u23-linux-i586-rpm.bin

Step4: Now install the jboss do the following process:
            # cp -r /root/Desktop/jboss-5.1.0 GAtar.bz2 /usr/local/  (Replace the source path from your Download location)
            # cd /usr/local
# bunzip2 jboss-5.1.0 GA.tar.bz2
            # tar -xvf jboss-5.1.0 GA.tar
            # cd /usr/local/jboss/bin
            # vim run.conf
                        Go to line number 34 edit that line with your jdk version installed.
                        wq!
            # ./run.sh
                        (If you want to run it on any particular ip then bind it as “    ./run.sh -b <system ip>”)

Step5: Now JBoss is running in the backend in terminal if it auto synchronies with time its working properly.

Step6: For checking,   Go the browser type “http://127.0.0.1:8080” and hit the enter key, if JBoss screen is appears then its installed.
                        (Replace 127.0.0.1 with your IP if you bind it on any particular IP)


Tasks in JBOSS:

Task1: Deployment
Applications are deploy in the JBoss for various purpose which are Deploy on any particular path which is as below:
            # cd /usr/local/Jboss-5.1.0.GA/server/default/deploy

Task2: Check the Status of application
Check the status of application whatever is deployed is working properly or not.
            http://127.0.0.1:8080/abc.war (where abc.war is your required file need to be checked give extension of particular application also)
Replace 127.0.0.1 & 8080 with your IP and port Numbers respectively if necessary.

Task3: Changing PORT
By default connectors listens on port numbers 8080 for http request and 8009 for AJP requests. We may change the port numbers as per our requirements.
Redirect Port:
If this Connector is supporting non-SSL requests, and a request is received for which a matching <security-constraint> requires SSL transport, Catalina will automatically redirect the request to the port number specified here.

            # cd /usr/local/Jboss-5.1.0.GA/server/default/deploy/jbossweb.sar/
            # vim server.xml
            Go to line number 12 and change the port as per requirement (for HTTP)
            Go to line number 21 and change the port as per requirement (for AJP)

Task4: Changing Password
By default password for the JBoss is admin we can change the password to privileges our JBoss application from unwanted or unauthorized users.
# cd   /usr/local/Jboss-5.1.0.GA/server/default/conf/props/
# vim jmx-console-userproperties
(Open this file goes to line number one and replace the password as per admin requirements)

Task5: Connection Timeout settings
This is the time required to establish a connection between JBoss and its application or through internet. When we try to connect it the number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. The default value is 60000 (i.e. 60 seconds).We can increase or decrease its value.

# cd /usr/local/Jboss-5.1.0.GA/server/default/deploy/jbossweb.sar/
            # vim server.xml
            Go to line number 13 and edit the time in milliseconds.

Task6: Communicate Oracle and JBoss
Oracle is database we need our application server connectivity with it. We can connect our database (ORACLE) with our application server (JBOSS).

# cd /usr/local/Jboss-5.1.0.GA/server/default/deploy/
# vim oracle-ds.xml
Open this file and make an entry in line no: 19, 32 and 33 as per oracle installed.
In line number 19 provide ip of the database.
In line number 32 provide username of database.
In line number 33 provide password of database.
                       

Performance Tuning in JBOSS

Performance tuning is very important part of any application .With the help of performance tuning we can increase the performance and make application faster. There are various methods involved in this process which are described one by one.

  1. Startup settings
If we are using any server configuration other than "default" we will have to specify it in the command line of the server startup script. For example use the following command to run "minimal" configuration.
# cd /usr/local/Jboss-5.1.0.GA/bin/
# ./run.sh  -c minimal

  1. Configuring Memory Settings
The run.conf file in the bin folder contains JVM parameters including memory configuration. In this file we can set maximum and minimum heap size. The actual heap size setting will depend on our application requirements and also on the RAM size of the server machine.

# vim /usr/local/Jboss-5.1.0.GA/bin/run.conf
set "JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m"

Also ensure that adequate permgen space is set. Permgen space is the fixed memory required such as the code footprint. For large applications the default value of 256m may not be sufficient. Following sets the permgen space to 512MB.

# cd /usr/local/Jboss-5.1.0.GA/bin/run.conf
set "JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=512m -XX:MaxPermSize=512m"

If we want to fine tune JVM settings, you can try changing parameters such as NewSize, MaxNewSize.

  1. Changing Port Number
The HTTP port for default JBoss installation is 8080. In production server, you will require this to be on port 80 (default HTTP port).  If you are using HTTPS, you will need to change SSL port from 8443 to 443. In JBoss 5, changing default ports are easy. You just need to modify only one file.

# cd /usr/local/Jboss-5.1.0.GA/server/default/conf/bindingservice.beans/META-INF/
# vim bindings-jboss-beans.xml

Open this file and then modify Web server properties located towards the end of the file. You can also search for 8080 and 8443.

  1. Configuring Data source Settings
The data source settings are stored in xml files under deploy folder of the server. For example, oracle-ds.xml is the configuration file I used in my application. This maps a connection setting to a JNDI name. The important parameters to configure are,

min-pool-size:– This is the initial number of connections kept open to database.
max-pool-size:– This is the maximum number of concurrent connections possible to the database. This value should be based on your application needs and also on the database configuration.

  1. Configuring HTTP Connector Settings
The underlying HTTP connector of JBoss needs to be fine tuned for production settings. The following settings are applied to the Connector tag in the default/deploy/jbossweb.sar/server.xml file. The important parameters are,

maxThreads:– This indicates the maximum number of threads to be allocated for handling client HTTP requests. This figure corresponds to the concurrent users that are going to access the application. Depending on the machine configuration, there is a physical limit beyond which you will have to do clustering.

acceptCount:– This is the number of request threads that are put in request queue when all available threads are used. When this exceeds, client machines get a request timeout response.

compression:– If you set this attribute to "force", the content will be compressed by JBoss and will be send to browser. Browser will extract it and display the page on screen. Enabling compression can substantially reduce bandwidth requirements of your application.

  1. Configuring JSP Compilation Settings for Production
JBoss application server regularly checks whether a JSP requires compilation to a servlet before executing a JSP. In a production server, JSP files won’t change and hence you can configure the settings for increased performance.

Open the web.xml in “default/deployers/jboss-web.deployer” folder. Look for the jsp servlet (org.apache.jasper.servlet.JspServlet) in the file and modify the following XML fragment as given below,
<init-param>
            <param-name>development</param-name>
            <param-value>false</param-value>
</init-param>
<init-param>
            <param-name>checkInterval</param-name>
            <param-value>300</param-value>
</init-param>

  1. Removing unwanted applications and services
JBoss comes with a lot of services and your enterprise applications may not need all of them.  Removing these unwanted services can boost application server performance. Following are some of the JBoss services you can remove if your application is not using them in production. Delete the files/folders given in brackets to remove these services completely.

(a) Home page server: (deploy/ROOT.war)
(b) JMX Console server: (deploy/jmx-console.war)
(c) Web Console server: (deploy/management)
(d) Unique ID key generator: (deploy/uuid-key-generator.sar, lib/autonumber-plugin.jar)
(e) HTTP Invoker service: (deploy/http-invoker.sar)
(f) Quartz scheduler service: (deploy/quartz-ra.rar)
(g) Mail service: (deploy/mail-service.xml, lib/mail*.jar)
(h) Monitoring service: (deploy/monitoring-service.xml,lib/jboss-monitoring.jar)
(i) Scheduler service: (deploy/scheduler-service.xml, deploy/schedule-manager-service.xml,lib/ scheduler-plugin*.jar)
(j) Messaging (JMS) service: (deploy/messaging, deploy/jms-ds.xml, deploy/jms-ra.rar, lib/ jboss-messaging*.jar)

  1. Protecting Administration Console Applications
Some of the default Web applications in JBoss are very useful in monitoring server status. For example the Web Console can give valuable information such as server memory status and active HTTP active connections. Please see the Web Console screenshot below (http://localhost/web-console)

So you may decide to leave them enabled on the JBoss production server. But the problem is that these can be accessed by anyone through Internet and is unprotected. When you run JBoss with production settings you obviously want to protect these applications.

You can protect these applications using JAAS or by limiting access to these applications only from the local machine (server machine). Of course the easiest way to secure them is to remove them as I have shown in the previous section. In order to enable access only from local machine,

Add the following in server.xml (default/deploy/jbossweb.sar) just before "Engine" closing tag.
<Host name="loopback" autoDeploy="false" deployOnStartup="false" deployXML="false">
</Host>

Then add the following in jboss-web.xml in WEB-INF of the following admin applications.
<virtual-host>loopback</virtual-host>

For JMX Console use deploy/jmx-console.war and for Web Console use deploy/management folder. Now these monitoring apps can be accessed only from http://loopback address.

  1. Configuring Log4J Logging for Production
The default logging configuration in JBoss is not suitable for production deployment. In production, you only want the errors to be logged. Open jboss-log4j.xml file in default/conf folder.
            First change the root category located at the end of the file jboss-log4j.xml to contain only FILE appender. This ensures that there is logging to the screen (CONSOLE) and all errors are only logged to a file.
   <root>
      <appender-ref ref="FILE"/>
   </root>

Then add the following limiting categories.
   <category name="org">
      <priority value="ERROR"/>
   </category>
   <category name="com">
      <priority value="ERROR"/>
   </category>
   <category name="net">
      <priority value="ERROR"/>
   </category>

Remove the following entries. Please note that the following list is not exhaustive. You can remove all categories and then add the three categories given above. This ensures that only errors are logged. Also the changes to the logging configuration are hot deployed within a minute and hence you don’t need to restart the server.
   <category name="org.apache">
      <priority value="INFO"/>
   </category>
   <category name="org.quartz">
      <priority value="INFO"/>
   </category>
   <category name="org.jboss.management">
      <priority value="INFO"/>
   </category>
   <category name="org.jboss.serial">
      <priority value="INFO"/>
   </category>

Another simpler way to control logging is to change the priority attribute of the root logger. Set it to ERROR as shown below.
   <root>
      <priority value="ERROR"/>
      <appender-ref ref="FILE"/>
   </root>



             
     

No comments:

Post a Comment

Boot to UEFI Mode or legacy BIOS mode

Boot to UEFI Mode or legacy BIOS mode Choose UEFI or legacy BIOS modes while installing Windows. After Windows is installed, if you nee...