JBoss 7 Installation and Tuning
Posted by on 09 January 2012 10:40 AM
|
|||||
Applicable Plans - All Cloud Hosting PlansJBoss 7 Installation and TuningOverviewUsing the eApps Virtual Server in the Cloud Hosting service, Java SE 7, and JBoss 7, you can create web sites and web applications with dynamic content for your customers and users. This User Guide is designed to help you install Java SE 7 and JBoss 7 on your Virtual Server, and to do basic tuning if necessary. Information on how to actually deploy your applications using one of the three supported deployment methods (Apache with mod_jk, Apache with mod_proxy_ajp, and without Apache) are found in the User Guides specific to that method. The two approaches using Apache are covered in the same user guide.
If you do not need the advanced features of JBoss, and just need support for JSP and Servlets, we recommend that you uninstall JBoss and install Tomcat instead, as Tomcat uses less resources and is not as complex as JBoss to configure and use. JBoss is a very complex and powerful application that is intended for advanced users who are deploying enterprise grade applications. Before deploying your applications with JBoss, make sure that you really need all the complexity that JBoss provides. To make the best use of JBoss you need to be an expert in Java application programming and deployment. Installing JBoss 7 Starting and Stopping JBoss 7 JBoss 7 Administration Console JBoss 7 Deployment Approaches Tuning JBoss Installing JBoss 7There are two choices for installing JBoss 7:
For either installment choice, you will need to install either MySQL database server and Mysql JDBC Driver, or PostreSQL database server and PostgreSQL JDBC Driver. Which database you choose will depend on your existing codebase and preferences. If you are going to use the mod_jk deployment method (used by the majority of eApps customers), you will need to install mod_jk. If you are going to use the mod_proxy_ajp deployment method, nothing additional needs to be installed because mod_proxy_ajp is an Apache module, and is available if Apache is installed.
Installing JBoss 7 using a Control PanelInstalling JBoss 7 using the ISPmanager Control PanelIf you are using the ISPmanager Control Panel, you can install JBoss 7 and related applications from that Control Panel.
Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions Installing JBoss 7 using the command lineYou can install JBoss 7 and related applications from the command line of the Virtual Server. You will need to install Java SE 7 and several Java plugins first, and then install JBoss 7. All of this is done using yum. To install Java SE 7 and the related applications, use the [root@eapps-example ~]# yum install -y java-1.7.0-sun java-1.7.0-sun-plugin java-1.7.0-sun-jdbc java-1.7.0-sun-src java-1.7.0-sun-devel java-1.7.0-sun-javafx Note - if you still need to use Java SE 6 for legacy reasons, you can install it using the command above for Java SE 7, but substitute 6 for 7. Be aware that Java SE 6 is End Of Life, and may not be supported in the future. To install JBoss 7, use the [root@eapps-example ~]# yum install -y jboss7 If you are going to use the mod_jk approach for JBoss, you will need to install mod_jk using the [root@eapps-example ~]# yum install -y mod_jk If you are going to install your database from the command line, please see the specific user guide for that database:
Starting and Stopping JBoss 7JBoss can be stopped, started or restarted from your Control Panel or from the command line of the server. Using the Control PanelUsing ISPmanagerThe way to start, stop, and restart JBoss from ISPmanager will depend on which version of ISPmanager you are using.
Using the Command lineThis can be done by connecting to the command line of your VS - Connecting to your Virtual Server (SSH and MindTerm) - http://support.eapps.com/ispmgr/ssh. You will need to be the root user to run these commands. Starting JBoss Start JBoss with the [root@eapps-example ~]# service jboss7 start Stopping JBoss Stop JBoss with the [root@eapps-example ~]# service jboss7 stop Restarting JBoss Restart JBoss with the [root@eapps-example ~]# service jboss7 restart JBoss Status Check the status of JBoss with the [root@eapps-example ~]# service jboss7 status JBoss 7 Administration ConsoleIn JBoss 7, the jmx-console and the web-console have been replaced with the JBoss Administration Console. The Administration Console is the root context for the default JBoss 7 installation, and is available at http://eapps-example.com:8080 (substitute your own domain name or IP address for eapps-example.com). This takes you to the Welcome to AS 7 page (for Application Server 7). ![]()
![]() You will need to follow the instructions on this page to set a username and password for a user that can access the JBoss Administration Console. This needs to be done from the command line, as the root user. Namely, you will need to run the add-user.sh script in the /opt/jboss7/bin directory, adding the user to the ManagementRealm. Connect to the VS using SSH, and change directories to /opt/jboss7/bin. Execute the add-user.sh script by typing in ./add-user.sh (a dot, a slash, and then add-user.sh, with no spaces) When prompted, select a to create a Management User. The Username can only be alphanumeric characters, no special characters (!@#$ etc) are allowed. If your password is easily guessable, the script will warn you. [root@eapps-example ~]# cd /opt/jboss7/bin/ Once you have created the user for the Administration Console, click the Try Again link at the bottom of the page, or go to http://eapps-example.com:9990/ in your browser (make user to substitute your own domain name for eapps-example.com). This will take you to a page where you can enter the User Name and Password for the Administration Console. More information on how to use the JBoss 7 Administration Console to deploy your application can be found in the User Guides for each deployment example. JBoss 7 Deployment ApproachesOverview of three approaches for deploymenteApps Hosting supports three approaches to deploy your JBoss application. Before you proceed you will need to determine which of the three approaches below is appropriate for you. The three supported approaches for deployment are: 1. Using Apache and mod_jkApache as a front end to JBoss using mod_jk - this approach allows you to control what content is served by JBoss and what content (if any) is served by the Apache web server. You will need to specify directives that tell Apache what content to pass on to JBoss. mod_jk is mature, widely used, and also has advanced features for load balancing and other techniques. The majority of eApps customers use this approach. 2. Using Apache and mod_proxy_ajpApache as a front end to JBoss using mod_proxy_ajp - this approach is similar to mod_jk but is simpler to use and allows you to take better advantage of Apache's capabilities, such as mod_rewrite. It provides features for load balancing as well, but is not as sophisticated as mod_jk. 3. Using JBoss without ApacheJBoss without Apache - this approach should only be used if your application specifically requires this method. Generally, this approach is only used when your Virtual Server does nothing but run a JBoss application. In other words, it is not used for e-mail, or any other function other than the JBoss application. This approach is for advanced users who are already very familiar with configuring JBoss and Apache. The vast majority of users do not need this approach.
Tuning JBossSet the Java Heap correctlyJava Heap Settings - an overview
One of the most important parts of tuning JBoss for better performance is to optimize the Java Heap settings. The Java Heap size is the amount of memory allocated to the Java Virtual Machine (JVM). The heap is where Java objects live, and there must be enough memory allocated to the JVM to support the needs of the deployed JBoss applications. How to find the correct Java Heap settingsBy default JBoss is configured to have an Initial Java Heap Size of 512 MB, and a Maximum Java Heap Size of 512 MB. Depending on your application and configuration, you may need to adjust this value in order to correctly optimize JBoss. To find the correct heap size, you will have to stop JBoss, and use the Linux free -m command to see the available memory, and then multiply that value by two, and then subtract that result from the total RAM available for your plan. This number will be roughly what you need to set for the maximum heap size. The following must be done from the command line of the VS. See the User Guide: Connecting to your Virtual Server (SSH and MindTerm) http://support.eapps.com/ispmgr/ssh for more information if needed. [root@eapps-example ~]# service jboss7 status In this example, with JBoss stopped, the operating system and all other applications and services running consume 600 MB of RAM. Multiply this value by two giving a total of 1200, and subtract that from the total available RAM for a value of 848 MB for the maximum heap. Remember, this is just a rough estimate. You may find that you need to adjust this number up or down as necessary, depending on how your application is configured and what other services your system is running. Generally, the maximum heap size should be just under half the amount of memory available. You can of course adjust this value higher or lower, but you may have to experiment to determine the true optimum heap size If your JVM runs out of heap space, the message java.lang.OutOfMemoryError may appear in the /var/log/jboss7/standalone file. This message lets you know that you need to either adjust your heap settings, consider upgrading your plan, or optimize your application to use less memory and resources. You can also use the same free -m command as shown above, but with JBoss still running. This will show you if you are hitting memory limits in your plan. If your free memory drops below 100 MB, that is a sign that you may be pushing the resource limits in your plan. If this is the case, you should monitor the memory usage for several days to see if that number is consistent, or was just an anomaly due to peak load condition. Adjusting the Java Heap settingsTo set the Java Heap for JBoss you must modify the wrapper.java.initmemory and the wrapper.java.maxmemory settings in your /etc/jboss7/jboss.conf file. It is best to set the init parameter lower than the maximum parameter to ensure that Java does not initialize more memory than is actually needed. This will optimize memory for non-Java processes. The following must be done from the command line of the VS. See the User Guide: Connecting to your Virtual Server (SSH and MindTerm) http://support.eapps.com/ispmgr/ssh for more information if needed. [root@eapps-example ~]# cd /etc/jboss7 Using a text editor (in this example the vim editor), edit the jboss.conf file and change the settings below to your desired heap size values. The default values for the Java Heap Size are 512 MB for Initial and 512 MB for Maximum. This is the same no matter which offering you have. You will generally need to adjust the wrapper.java.maxmemory upwards, and leave the wrapper.java.initmemory as is. # Initial Java Heap Size (in MB) Make whatever changes are needed, and then save and exit the jboss.conf file. You will need to restart JBoss for the new Heap settings to take effect. | |||||
|