Resin2.1.x configuration instructions

Source: Internet
Author: User
Tags mysql connection pool

 

Resion 2. x configuration

 

1. <HTTP host = 'localhost' Port = '000000'/>
The host parameter specifies the server, and the port specifies the http port. The default value is localhost and 8080.
2. <srun host = 'localhost' Port = '000000'/> This is the engine configuration of JSP and Java Servlet.
3. When using resin to develop a Java Web project, you must create your own webapp.
4. Applications in resin can be published in two ways:
First, it is published in the resin directory;
The second is to package the package into war for release.
5. Search for the <web-app> tag in resin. conf, which indicates a web application.

The ID attribute indicates the web path of the application. For example, <web-app id = '/test' app-Dir = 'e:/PIC'> indicates that the application should use HTTP when accessing the Web: // hostname/test. The app-Dir attribute indicates the actual path of the application.

For example, <web-app id = '/test' app-Dir = 'e:/PIC'>

For example, the preceding configuration maps http: // localhost: 8080/test/to the local C:/webapp directory of the server. The content of the directory should be the code or script of the Web application.

Three error-page: 404 errors can be configured for resin.

The error page is not found in the file. The exception page cannot be connected to the Java engine page. They can be set in this way respectively.

404 page not found for file
<Web-app id = '/app1'>
<Error-page error-code = '000000' location = '/file_not_found.jsp'/>
</Web-app>

Exception page
<Web-app id = '/foo'>
<Error-page exception-type = 'java. Lang. nullpointerexception' location = '/nullpointer. jsp'/>
</Web-app>

Cannot connect to the srun servlet engine error page

The settings on this page are irrelevant to the application and belong to the server settings.
<Http-Server>
<Error-page exception-type = 'connection' location = '/missing_file.html'/>
</HTTP-Server>

See the following statement:

<Classpath id = 'web-INF/classes 'source = 'web-INF/src' compile = 'true'/>

The value of the ID parameter indicates the storage path of the compiled class in classpath;
The value of the Source parameter indicates the storage path of the Java source code in classpath;
The value in compile may be true or false, indicating whether Java source code is automatically compiled by resin's srun.
The classpath settings are generally related to the use of JavaBean or servlet. The value of ID indicates the root of the compiled package of JavaBean,

The value of source indicates the root of the Java source code of JavaBean. The servlet is the same.
6. servlet settings
<Servlet-mapping URL-pattern = '*. xtp' servlet-name = 'xtp '/>
<Servlet-mapping URL-pattern = '*. jsp' servlet-name = 'jsp '/>
<Servlet-mapping URL-pattern = '/servlet/*' servlet-name = 'invoker '/>
Generally, it is to specify the resolutions that need to pass the srun. For example, if you change *. jsp to *. JSS, the rest will not change.

*. JSS files are processed in the same way as *. jsp files. This allows you to specify the parsing engine, as shown in the following Configuration:
<Servlet-mapping URL-pattern = '*. xtp' servlet-name = 'com. Caucho. jsp. xtpservlet '/>
In servlet, you can also specify servlet. For example
<Servlet-name = 'helloworld' servlet-class = 'test. helloworld'/>
<Servlet-mapping URL-pattern = '/hello.html' servlet-name = 'hello'/>
When servlet-mapping has an important parameter case-sensitive, if it is on Windows, it is best to set it to false, case-insensitive, from

It is consistent with the Windows conventions.
7. session configuration
<Session-config>
<Sessions-max> 4096 </session-max>
<Session-Timeout> 30 </session-Timeout>
<Enable-Cookies> true </enable-Cookies>
<Enable-URL-rewriting> true </enable-URL-rewriting>
<File-store> WEB-INF/sessions </file-store>
</Session-config>

Session-MAX: Maximum number of sessions
Session-Timeout: The expiration time of the session, in minutes.
COOKIE: whether the session uses cookies. If cookies are used, the browser must support session to use and publish

To false. Enable-URL-rewriting and enable-cookies are generally used together. If enable-cookies are false,
Enable-URL-rewriting should be set to true.
File-store: indicates whether the server stores the session as a file on the server. If this item is commented out

-The web-INF/sessions directory in the app directory does not save the serialized session object.

The JDBC-store configuration also exists in the session, which stores the session permanently in the database through JDBC.

It is actually the physical implementation of saving and reloading session variables after serialization.
The following is a detailed example

There is only one resin configuration file. In the conf folder of the installation directory, the file name is resin. conf. The file is an XML structure file, which can be opened and edited by notepad or other text editors.

 

The following describes common configuration items.
1. Database Connection Pool Configuration
If the application uses a database connection pool, a MySQL connection pool example is provided directly after decompression. To change the search result, add the following configuration information to the database connection pool:
SQL Server
========================================================== ======================================
<Resource-ref>
<Res-ref-Name> JDBC/testxml </RES-ref-Name>
<Res-type> javax. SQL. datasource </RES-type>
<Init-Param driver-name = "com. Microsoft. JDBC. sqlserver. sqlserverdriver"/>
<Init-Param url = "JDBC: Microsoft: sqlserver: // 192.168.1.84: 1433; Create = true; databasename = test"/>
<Init-Param user = "sa"/>
<Init-Param Password = "sa"/>
<Init-Param max-connections = "10"/>
<Init-Param enable-transaction = "true"/>
</Resource-ref>

Oracle
========================================================== ======================================
<Resource-ref>
<Res-ref-Name> JDBC/testxml </RES-ref-Name>
<Res-type> javax. SQL. datasource </RES-type>
<Init-Param driver-name = "oracle. JDBC. Driver. oracledriver"/>
<Init-Param url = "JDBC: oracle: thin: @ 192.168.1.10: 1521: Test"/>
<Init-Param user = "root"/>
<Init-Param Password = "root"/>
<Init-Param max-connections = "10"/>
<Init-Param enable-transaction = "false"/>
</Resource-ref>
Note: To access the database, make sure that the Lib folder in the resin installation directory has the JDBC driver of the corresponding database, such as MSSQLServer. jar or oracle_jdbc.jar. Otherwise, copy the driver file to this directory. Otherwise, you cannot access the database.
<Res-ref-Name> the connection pool name must be the same as the business application configuration;
The <init-Param URL> field is the database connection string, and the blue part is the database server IP Address: Port, database name, or Sid. <Init-Param user> database user name.
<Init-Param password> password.
The <init-Param max-connections> field indicates the maximum number of connections in the connection pool. This data may affect the web-based database applicability. We recommend that you set the number to 10 ~ 40 (when there are many database applications, the configuration should be too small, and when there are many web applications, the configuration should be too large ).

2. Service port configuration
Search for If you need to start multiple resin services on one server, configure the application port number in the configuration file of each resin installation directory according to the corresponding plan.

3. Update Interval
<Class-Update-interval> 60 S </class-Update-interval>. The blue character is a configuration item, in seconds.
The class-Update-interval field has a great impact on the performance of resin services. Please change the value as needed. We recommend that you set the value to 2 or smaller in the development environment, this helps to reflect the application changes caused by program modifications in a timely manner. We recommend that you set a minimum of 60 in the production environment. Based on the characteristics of the production environment, there may be no frequent class changes or Java script changes, or there will be no changes at all. Therefore, set it to 60 ~ 3600.

4. Maximum number of processes
<Thread-max> 20 </thread-max>. The blue character is the configuration item.
The thread-Max field is the maximum number of processes received by the resin service. To achieve better performance output, we recommend that you set this parameter to one time of the Max-connections parameter in the 3.1 connection pool. That is, if the connection pool max-connections is set to 10, thread-Max is set to 20.

5. Maintain the number of active processes
<Thread-keepalive id = '19'/>. The blue character is the configuration item.
The thread-keepalive field is the maximum number of links that the resin Service maintains. Its value must be smaller than the value of thread-max in section 3.4. Otherwise, the resin cannot be started. No recommended value for this item.

6. Request timeout duration
<Request-Timeout id = '65s'/>. The blue character is a configuration item, in seconds.
The request-Timeout field is the time when the resin service returns the request link timeout. The default value is.

7. Received link buffer size
<Accept-buffer-size id = '000000'/>. The blue character is the configuration item.
The accept-buffer-size Id field is the number of waiting process buffers received by the resin service when the number of processes is full. The value depends on the server and network conditions, and no recommended value is set.

8. cache file expiration time
<Cache-mapping URL-pattern = '/' expires = '2s '/>. The blue character is the configuration item.
During the resin operation, the accessed file data is cached (the default cache directory is the cache directory under the resin installation directory, you can modify the <cache dir = 'cache' size = '000000' entries = '000000'/> field to the specified path, the cache-mapping URL-pattern field is the time when the resin Service maintains the validity of the cache file. The default value is 2 in the development environment. It is recommended that the cache-mapping configuration be less effective in the production environment, such as 15 or 30. This configuration increases the cache validity time based on applications, reduces the service logic of the server when there are many identical page services, and uses the disk buffer file to provide data; however, if the request rate for the same page is small or even not the same for a fixed length of time (such as 10 minutes), a cache file matching action will be added, which reduces the server efficiency. Therefore, in special applications, you can set this configuration item to 2, or comment <cache dir = 'cache' size = '000000' entries = '000000'/>, disable the cache function.

9 VM settings

9.1 default document settings
<Welcome-file-List> index. xtp, index. jsp, index.html </welcome-file-List>.
The wecome-file-list field is the file list of the default document. The default document is to access the Web server on the client, such as resin. If no file to be accessed is specified (that is, the input URL is the directory name rather than the specific file name, for example, http: // localhost: 8080/). At this time, resin searches the URL Access Directory based on the value of this field to find the matching file. If the file is found, it returns it to the user without entering all the URLs. For example: http: // localhost: 8080/index.html.
This configuration item is generally used to set the default homepage.

9.2 host ID
<Host ID = ''>.
The host ID field does not need to be configured when a single host environment and a server needs to start multiple different resin services. Keep the default null value. Modify this configuration item only when used with other Web servers, such as Apache.

9.3 logs
<! -- Access-log ID = 'logs/access. log 'format = '% H % L % u % t "% R" % S % B "% {Referer} I" "% {User-Agent} I "'
Rolover-period = '1w'/-->
<Error-log ID = 'logs/error. log'/>. The blue character is the configuration item.
? The access-log ID field is resin, which records the access logs during runtime. This log is not recommended for individual servers, even in hybrid servers (such as IIS and Apache) it is not recommended unless you want to analyze the access status of a server. If you do not use the comment section, add the red part of the code ).
? The error-log ID field is resin. The default value is recommended. Logs are saved in the logs folder of the resin installation directory.

9.4 virtual directory
In the The web-app Id field is the resin virtual directory name, and the app-Dir field is the local path value.
For example, the preceding configuration maps http: // localhost: 8080/test/to the local C:/webapp directory of the server. The content of the directory should be the code or script of the Web application.

10 single-server multi-resin service configuration
In some applications, the configuration of multiple resin services on a single server is used, that is, multiple different resin services are required on one server, such as the resin of a web site, the resin of a voice IVR or SMS is as follows:
1. Retain the default configuration for the host ID field.
2. the http port values of each resin configuration file cannot be the same. Configure the values based on the planned port number.
3. <srun host = '20180101' for each resin configuration file. the port value in 0.0.1 'port = '000000'> cannot be the same. This value can be configured at will, but it must not conflict with other ports. We recommend incremental configuration, such as 6802 and 6802, generally, 680x is not used.
4. manually enter the address to test whether the address is normal.
Configuration complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.