Control Panel Login to your Control Panel, and click on the System Tab. If necessary, click the Select Another System (Subscription) link on the left and choose the correct Virtuozzo container. Go to Applications, and either click on the All Applications link and then the JBoss link, or click directly on the application link for JBoss (if available). There will be a radio button to either Stop or Start the JBoss server, depending on its current status. JBoss can also be stopped or started from the Services link on the System Tab. Click on the link for JBoss, and there will be a radio button to Stop or Start the JBoss server, depending on its current status. Server ConfigurationsStarting with JBoss 4.2.x, the instance of JBoss provided by eApps supports 3 server configurations. The configuration that is used depends on the -c option that is passed to the startup script. Each configuration is in /opt/Jboss4/server/[config-name]. The configuration you use will determine the default services JBoss will make available to your application.
How to use the JBoss jmx-console and web-consoleUsing the JBoss Jmx-ConsoleAfter JBoss has been installed you can access the Jmx-console at http://example.com://8080/jmx-console. The default user name and password isadmin/example.com (the VPS host name at the time JBoss was installed.) The JMX console provides a raw view into the microkernel of the JBoss application server. It lists all registered services (MBeans) that are active in the application server and that can be accessed either through the JMX console itself or programmatically from Java code. Using The JBoss web-console After JBoss has been installed you can access the web-console at http://example.com:8080/web-console. The default user name and password isadmin/example.com (the VPS host name at the time JBoss was installed) The web console provides a tree like view of management statistics on several things such as servlets, ejb, user defined domains and Mbeans. Securing The jmx-console and web-console The default user name and password for the jmx-console and the web-console are the same and are managed by the user.properties files. The file is located in /opt/jbossX/server/default/conf/props. To change the user name and password to something other than the default values, here is what to do. This assumes you are going to change the user name to eapps and the password to hosting. Note – the following must be done from the command line of the VPS while logged in via SSH as the root user. Do not edit these files from the Control Panel.
Using a text editor (in this example the vi editor) edit users.properties and change this line:
to
and save and exit the file. Next change the roles.properties file in the same directory to set the new user with the correct role. Again, this assumes you are editing the file in the vi editor. Change this line:
to
and save and exit the file. Restart JBoss for the changes to take effect. Multiple users can be added in the format above for access to jmx-console and web-console. How to upload your JBoss applicationsUploading application files – an overviewTo upload your JBoss application, place the files in the JBoss deployment directory, and then restart JBoss. You can upload your files using the File Manager in the System Tab of the Control Panel if they are under 5 MB in size, or you can use SFTP to upload the files to the correct directory.Once you have uploaded your files, make sure they have the correct owner and group for their location. Using SFTPSFTP allows you to upload files of any size to your deployment directories, and is much faster than using the Control Panel. If you are going to be frequently uploading/changing/working with your JBoss applications, SFTP is the best choice. For more information on SFTP, please see the SFTP User Guide.Using the Control PanelYou can use the File Manager to upload your application to your deployment directory if your application is less than 5MB in size.To use the File Manager, login to your Control Panel, and click on the System Tab. If necessary, click the Select Another System (Subscription) link on the left and choose the correct Virtuozzo container. Then, click on File Manager. Using the File Manager, navigate to the directory you are using for your JBoss application files. Once you are in that directory, click on Upload File. In the Upload File screen, you can Browse for the file to be uploaded on your local computer, and also specify a New file name if necessary. You also can set the Permissions for the files, and the Ownership. Make sure you choose Permissions and Ownership that match the other files where you are uploading your applications. Once you have everything ready, click OK to upload your files. Once you have uploaded your JBoss application files, restart JBoss as per the instructions in Starting and Stopping JBoss using either the Control Panel or the command line. Using the File Manager in the Control Panel is the slowest and most restrictive way to upload your files. If you are going to be frequently working with your JBoss application files, you will be better served by using SFTP to connect to your VPS and upload your files. For example, you cannot upload a file over 5 MB using the Control Panel, while there is no such restriction using SFTP. It is not uncommon for the WAR file for a complex JBoss application to be larger than 5 MB, which means that you will not be able to use the Control Panel to upload that file. Three approaches for deploying JBoss applicationsOverview of three approaches for deploymentYour eApps Virtual Private Server includes the Apache web server as part of the base environment. Apache is designed to serve static content, perl scripts, php scripts, and other types of content that requires a web server. JBoss is designed primarily to serve JBoss specific applications, J2EE applications, JSP pages and servlets.One of the decisions you will need to make when deploying your JBoss application is how you want JBoss and Apache to interact. In most cases you will want to use Apache as a front end to JBoss. In some cases you may want to run JBoss without Apache. eApps 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:
Using 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.Using 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. Mod_proxy_ajp is a new approach and in fact does not work with Apache versions prior to 2.2. This approach can only be used by eApps customers running on the CentOs 5 or later version of operating system. To verify what OS you are on login to your control panel, click on the My Account tab, then the Subscription for your VPS. You will see the operating system version at the top.Using JBoss in standalone modeJBoss standalone (without Apache) - this approach allows you to run JBoss without Apache. JBoss has a built in web server so Apache is not strictly needed even if web pages need to be served. Since all requests are directed to JBoss, it theoretically is more efficient than approaches that use Apache as a front end, although the difference is not meaningful for most deployments. One major shortcoming is that the eApps Hosting service uses the Apache web server to serve all web based applications such as AWStats, Web mail, PHP applications, etc. Running JBoss standalone results in these applications being unavailable to you, by default, in your eApps VPS. This approach is generally used when deploying a commercial or open source application for a specific purpose and that is all that the VPS is intended to be used for.For instructions on how to use each of the three supported approaches, please see the User Guide for that specific approach:
Tuning JBossSet the Java Heap correctlyJava Heap Settings - an overviewThe most important part 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. The most common issue with JBoss, by far, is a lack of available resources. In many cases, this is due to the Java Heap size either not being configured at all, or not being configured correctly. In other cases, the VPS is simply too small for the type of application being run on it. For example, while it is possible to run JBoss on the Standard Max plan, that plan does not have the resources for a true enterprise application or a site that receives a high volume of traffic. How to find the correct Java Heap settingsBy default JBoss is configured to use a maximum of 64 MB of RAM allocated to the heap. This setting will have to be changed in order to correctly optimize JBoss. To find the correct heap size , you will have to stop JBoss, and use the Linux ‘free’ command to see the available memory, and then multiple 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.Note – the following must be done from the command line of the VPS while logged in via SSH as the root user. Also remember to substitute your version of JBoss for the X in JBossX.
In this example, with JBoss stopped, the VPS plus all other applications and services running consume 250 MB of RAM. Multiply this value by two giving a total of 500, and subtract that from the total available RAM on the VPS for a value of 300 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 VPS is running. Generally, the maximum heap size should be just under half the amount of memory available to your VPS. You can of course adjust this value higher or lower, but you may have to experiment to determine the true optimum heap size. See the chart below for the eApps recommendations for the maximum heap size broken down by Plan. This chart shows the recommended maximum heap size per plan.
If your JVM runs out of heap space, the message java.lang.OutOfMemoryError may appear in the /opt/jbossX/server/default/deploy/logs/server.log 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/jbossX/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.Note – the following must be done from the command line of the VPS while logged in via SSH as the root user. Also remember to substitute your version of JBoss for the X in jbossX.
Using a text editor (in this example the vi 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 64 MB for Initial and Maximum. This is the same no matter which plan you have.
In this example, the defaults are changed to 256 MB for the Initial Heap Size and 432 for the Maximum Heap Size
Save and exit the jboss.conf file, and restart JBoss for the new Heap settings to take effect. Turn off Debug Information in JSP ClassesThe JSP compiler will compile JSP classes in debug mode. In production systems you should turn this off to increase the resources available to your application.Note – the following must be done from the command line of the VPS while logged in via SSH as the root user. Also remember to substitute your version of JBoss for the X in jbossX. First, make a backup of the web.xml file before making any changes.
Using a text editor (in this example the vi editor), edit the web.xml file and add the section in bold.
Turn Development Mode offFor performance reasons, we have changed the default mode for JBoss's JSP Development Mode setting to False. What this means is that changes to JSP pages will not be picked up automatically by JBoss.If Development mode set to true, JBoss will check for a new version of a jsp every time it is accessed from the client side and will attempt to reload the JSP pages. This can create a large performance hit on a busy productions system, so this option should be set to false especially in production systems. Note – the following must be done from the command line of the VPS while logged in via SSH as the root user. Also remember to substitute your version of JBoss for the X in jbossX. First, make a backup of the web.xml file before making any changes.
Using a text editor (in this example the vi editor), edit the web.xml file and add the section in bold.
Use Database Connection Pool (DBCP) When NecessaryDatabase Connection Pooling – an overviewDatabase connection pooling can reduce connection creation time and resource usage, especially on sites with a high load. The steps below can help you implement Database Connection Pooling for your application deployed with JBoss. Install the correct JDBC driver Login to your Control Panel, and click on the System Tab. If necessary, click the Select Another System (Subscription) link on the left and choose the correct Virtuozzo container. Go to Applications, and click on the Add Application link. Select the box next to either MySQL-connector-J or PostgreSQL-JDBC-Driver, and then scroll down and click the Next button. This takes you back to the All Applications screen. Wait for five minutes, then click on the Refresh link at the upper right, just under the word Parallels. The application should now show as installed. If it is still in a Scheduled state, wait another five minutes, and click Refresh again. If you see it in Error state, or it still shows as Scheduled, please contact eApps Technical Support. Create a Datasource ds.xml FileIn the jbossX/server/default/deploy directory, create a data source file named yourappname-ds.xml. The file name must end with the characters ds.xml so that the JBoss server can recognize it as a data source file; however, the file name can be prefixed with any set of characters. In this example, substitute the name of your application for "yourappname".For MySQL
For PostgreSQL
jboss-web.xml Configuration You now need to configure your application WEB-INF/jboss-web.xml file to use the database resource. In your jboss-web.xml file add a resource reference like the one below for both MySQL and PostgreSQL
There are several other things that can be done to tune JBoss which are out of the scope of this documentation. Please see the Links to other information section for external resources. Common Issues and SolutionsQuestion: Why am I getting a "jdbc error"?Answer: This is an indication that your application is having problems connecting to the database. Make sure your database server is installed and running. Make sure you have installed the JDBC driver, as explained in the user guide for the database server you are using. Make sure your jdbc connection string url is correct. Try to connect to the database with the user name and password you are using in your application. Question: Why am I getting a "class not found error"? Answer: This is an indication that you are trying to use a lib that is not in your class path. Check that the jar file is in /opt/jbossX/server/default/lib or in your application WEB-INF/lib directory. Question: JBoss is not starting after I added a host. What can it be? Answer: If JBoss fails to start after you added a Host there is most likely a configuration error in your server.xml file. Check and make sure all tags are properly closed and that there are no syntax errors. Question: JBoss is not starting and never has, what am I doing wrong? Answer: If JBoss fails to start right from the start, you probably do not have the Java language application installed. You will see an error "cannot initialize JVM" in the catalina.out error file. Go to the All Applications area on the System tab of your control panel and make sure you have the J2SE (java 5) or Java 6 application installed in your VPS. |
【转】jboss安全指南
最新推荐文章于 2020-12-01 08:54:21 发布