resin.conf配置详解
 
1. <!-- - Resin 3.1 配置文件.-->                            
2. <resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core">
3. <!-- 加载resin/lib下的所有.jar文件-->
4. <class-loader>
5. <tree-loader path="${resin.home}/lib"/>
6. <tree-loader path="${resin.root}/lib"/>
7. </class-loader>
8. <!-- - 管理配置 -->                                   
9. <management path="${resin.root}/admin">
10. </management>
11. <!-- -JDK日志接口的配置. -->                              
12. <log name="" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
13. <!-- 日志信息的级别:'info' 生产环境 'fine' 开发环境 'finer' 调试环境 -->
14. <logger name="com.caucho" level="info"/>
15. <logger name="com.caucho.java" level="config"/>
16. <logger name="com.caucho.loader" level="config"/>
17. <!-- - 环境上下文的检测时间,对于生产站点, 这个要设置长一点,例如600秒,10分钟 -->
18. <dependency-check-interval>2s</dependency-check-interval>
19. <!-- - 发送邮件通知的SMTP服务器 -->
20. <system-property mail.smtp.host="127.0.0.1"/>
21. <system-property mail.smtp.port="25"/>
22. <!-- - 你可以把编译器改成 "javac", "eclipse" 或者 "internal". -->      
23. <javac compiler="internal" args="-source 1.5"/>
24. <!-- Security providers.
25. - <security-provider>
26. - com.sun.net.ssl.internal.ssl.Provider
27. - </security-provider>
28. -->
29. <!-- 去掉注释,如果你使用resin提供的xml应用
30. -
31. - <system-property javax.xml.parsers.DocumentBuilderFactory
32. - ="com.caucho.xml.parsers.XmlDocumentBuilderFactory"/>
33. - <system-property javax.xml.parsers.SAXParserFactory
34. - ="com.caucho.xml.parsers.XmlSAXParserFactory"/>
35. -->
36. <cluster id="app-tier">
37. <!-- 设置集群上下文的根, 相对于server.root -->
38. <root-directory>.</root-directory>
39. server实例                                           
40. <server-default>
41. <!-- HTTP服务的端口-->                                    
42. <http address="*" port="8080"/>
43. <!--
44. - SSL端口配置:
45. -
46. - <http address="*" port="8443">
47. - <openssl>
48. - <certificate-file>keys/gryffindor.crt</certificate-file>
49. - <certificate-key-file>keys/gryffindor.key</certificate-key-file>
50. - <password>test123</password>
51. - </openssl>
52. - </http>
53. -->
54. <!-- - JVM参数设置 -->
55. <jvm-arg>-Xmx256m</jvm-arg>
56. <jvm-arg>-Xss1m</jvm-arg>
57. <jvm-arg>-Xdebug</jvm-arg>
58. <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
59. <!-- Uncomment to enable admin heap dumps 去掉这个如果你想管理内存堆的倾倒
60. - <jvm-arg>-agentlib:resin</jvm-arg>
61. -->
62. <watchdog-arg>-Dcom.sun.management.jmxremote</watchdog-arg>
63. <!-- 强制resin强制重起时的最小空闲内存 -->
64. <memory-free-min>1M</memory-free-min>
65. <!-- 最大线程数量. -->
66. <thread-max>256</thread-max>
67. <!-- 套接字等待时间 -->
68. <socket-timeout>65s</socket-timeout>
69. <!-- 配置 keepalive -->
70. <keepalive-max>128</keepalive-max>
71. <keepalive-timeout>15s</keepalive-timeout>
72. <!-- - 如果使用的是UNIX,这里是启动的帐号和用户组.
73. - <user-name>resin</user-name>
74. - <group-name>resin</group-name>
75. -->
76. </server-default>
77. 
78. <!-- 定义群集服务器 -->                                     
79. <server id="" address="127.0.0.1" port="6800"/>
80. <!-- Configures the persistent store for single-server or clustered 配置独立服务器或者群集的持久化存储,专业版的功能 -->
81. <resin:if test="${resin.isProfessional()}">
82. <persistent-store type="cluster">
83. <init path="session"/>
84. </persistent-store>
85. </resin:if>
86. <!-- 为了安全, 你可以为SSL会话(SSL sessions)定义一个不同的cookie.
87. - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
88. -->
89. <!-- 缓存启用 (专业版的功能) -->
90. <resin:if test="${isResinProfessional}">
91. <cache path="cache" memory-size="64M">
92. <!-- Vary header rewriting for IE -->
93. <rewrite-vary-as-private/>
94. </cache>
95. </resin:if>
96. <!-- 启用周期性的服务器状态检查和死锁检查,所有的服务器可以添加 <url> 来检查。 -->
97. <resin:if test="${isResinProfessional}">
98. <ping>
99. <!-- <url>http://localhost:8080/test-ping.jsp</url> -->
100. </ping>
101. </resin:if>
102. <!-- 包含web应用的默认行为 -->
103. <resin:import path="${resin.home}/conf/app-default.xml"/>
104. <!-- 每一个web应用的默认参数 -->
105. <web-app-default>
106. <!-- 扩展库的公共jar文件,扩展是安全的即使没有类装载器知道的jars,装载的类将为每个应用分别装载,也就是这些类都是不同的 -->
107. <class-loader>
108. <tree-loader path="${server.root}/ext-webapp"/>
109. </class-loader>
110. <!-- 设置缓存页、静态也的延时值 -->
111. <cache-mapping url-pattern="/" expires="5s"/>
112. <cache-mapping url-pattern="*.gif" expires="60s"/>
113. <cache-mapping url-pattern="*.jpg" expires="60s"/>
114. <cache-mapping url-pattern="*.png" expires="60s"/>
115. <!-- 启用EL表达式 -->
116. <allow-servlet-el/>
117. <!-- 安全原因, 默认禁用了会话的URLs -->
118. <session-config>
119. <enable-url-rewriting>false</enable-url-rewriting>
120. </session-config>
121. <!-- 安全原因, 在cookies中设置HttpOnly标志
122. - <cookie-http-only/>
123. -->
124. <!--一些JSP包有不正确的 .tld文件。可以把validate-taglib-schema设置成false,可能继续正常工作
125. - Some JSP packages have incorrect .tld files. It's possible to set validate-taglib-schema to false to work around these packages.
126. -->
127. <jsp>
128. <validate-taglib-schema>true</validate-taglib-schema>
129. <fast-jstl>true</fast-jstl>
130. <fast-jsf>true</fast-jsf>
131. </jsp>
132. </web-app-default>
133. <!-- 简单的数据池配置
134. - The JDBC name is java:comp/env/jdbc/test
135. <database>
136. <jndi-name>jdbc/mysql</jndi-name>
137. <driver type="org.gjt.mm.mysql.Driver">
138. <url>jdbc:mysql://localhost:3306/test</url>
139. <user></user>
140. <password></password>
141. </driver>
142. <prepared-statement-cache-size>8</prepared-statement-cache-size>
143. <max-connections>20</max-connections>
144. <max-idle-time>30s</max-idle-time>
145. </database>
146. -->
147. <!-- 定义所有虚拟主机的默认配置 -->
148. <host-default>
149. <!-- 如果和别的web服务器整合,这个可以被去掉,因为web服务器也可以记录这些信息。 -->
150. <access-log path="logs/access.log" format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' rollover-period="1W"/>
151. <!-- war 文件的布置目录 -->
152. <web-app-deploy path="webapps"/>
153. <!-- ear文件的布置目录 -->
154. <ear-deploy path="deploy">
155. <ear-default>
156. <ejb-server>
157. <config-directory>WEB-INF</config-directory>
158. <data-source>jdbc/test</data-source>
159. </ejb-server>
160. </ear-default>
161. </ear-deploy>
162. <!-- rar文件的布置目录 -->
163. <resource-deploy path="deploy"/>
164. </host-default>
165. <!-- 虚拟主机的布置目录 -->
166. <host-deploy path="hosts">
167. <host-default>
168. <resin:import path="host.xml" optional="true"/>
169. </host-default>
170. </host-deploy>
171. <!-- 默认的虚拟主机配置 -->                                   
172. <host id="" root-directory=".">
173. <!-- 配置默认的应用 webapp's ROOT -->
174. <web-app id="/" root-directory="webapps/ROOT"/>
175. <web-app id="/resin-admin" root-directory="${resin.home}/php/admin">
176. <!-- - 管理应用程序 /resin-admin
177. - password is the md5 hash of the password。md5码的密码。
178. - localhost is true to limit access to the localhost。localhost设置成true,这样只有localhost才能访问
179. -->
180. <prologue>
181. <resin:set var="resin_admin_user" value=""/>
182. <resin:set var="resin_admin_password" value=""/>
183. <resin:set var="resin_admin_external" value="false"/>
184. </prologue>
185. </web-app>
186. </host>
187. 
188. </cluster>
189. <!-- - Configuration for the web-tier/load-balancer -->
190. <resin:if test="${resin.isProfessional()}">
191. <cluster id="web-tier">
192. <server-default>
193. <!-- The http port -->
194. <http address="*" port="9080"/>
195. </server-default>
196. <server id="web-a" address="127.0.0.1" port="6700"/>
197. <cache path="cache" memory-size="64M"/>
198. <host id="">
199. <web-app id="/">
200. <rewrite-dispatch>
201. <load-balance regexp="" cluster="app-tier"/>
202. </rewrite-dispatch>
203. </web-app>
204. </host>
205. </cluster>
206. </resin:if>
207. </resin>
208. 
关键配置解

释:

    1. 3.1 数据库连接池配置
    2. 如果应用使用数据库连接池,查找<caucho.com>,在其后加入数据库连接池的配置信息如下:
    3. SQL SERVER
    4. ==================================================================
    5. <resource-ref>
    6. <res-ref-name>jdbc/job36_use</res-ref-name>
    7. <res-type>javax.sql.DataSource</res-type>
    8. <init-param driver-name="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
    9. <init-param url="jdbc:microsoft:sqlserver://192.168.3.84:1433;create=true;DatabaseName=CRM"/>
    10. <init-param user="sa"/>
    11. <init-param password="job36"/>
    12. <init-param max-connections="10"/>
    13. <init-param enable-transaction="true"/>
    14. </resource-ref>
    15. 
    16. ORACLE
    17. ==================================================================
    18. <resource-ref>
    19. <res-ref-name>jdbc/job36</res-ref-name>
    20. <res-type>javax.sql.DataSource</res-type>
    21. <init-param driver-name="oracle.jdbc.driver.OracleDriver"/>
    22. <init-param url="jdbc:oracle:thin:@192.168.3.84:1521:CRM"/>
    23. <init-param user="job36"/>
    24. <init-param password="job36"/>
    25. <init-param max-connections="10"/>
    26. <init-param enable-transaction="false"/>
    27. </resource-ref>
    28. 注意:如果要访问数据库,请先确认RESIN安装目录下lib文件夹有相应数据库的JDBC驱动,如mssqlserver.jar或oracle_jdbc.jar等,否则请先将驱动文件拷贝到该目录,不然无法访问数据库。
    29. <res-ref-name>字段为连接池名字,要与业务应用配置相同;
    30. <init-param url>字段为数据库连接字符串,蓝色部分为数据库服务器IP:PORT、数据库名或SID。<init-param user>数据库用户名。
    31. <init-param password>密码。
    32. <init-param max-connections>字段为连接池最大连接个数,这个数据对基于WEB的数据库应用性能有一定影响,建议配置数为10~40(数据库应用较多时配置应偏小,网页应用较多时应偏大)。
    33. 
    34. 3.2 服务端口配置
    35. 查找<http port='8080'/>,蓝色字符串即为端口号,根据实际应用修改。
    36. 如果需要在一台服务器上启动多个resin服务,请按相应规划各应用端口号在每个resin安装目录的配置文件中配置该项,不可重复。
    37. 
    38. 3.3 更新类间隔时间
    39. <class-update-interval>60s</class-update-interval>,蓝色字符为配置项,单位为秒。
    40. Class-update-interval字段对RESIN服务性能影响较大,请根据需求更改,建议配置原则为:在开发环境,设为2或更小,这样有利于 及时反映程序的修改对应用造成的改变;生产环境建议配置最小60,根据生产环境的特点,不可能有频繁的类改动或是JAVA脚本改变,或者根本不会有改动, 所以依据实际情况,设置为60~3600。
    41. 
    42. 3.4 最大进程数
    43. <thread-max>20</thread-max>,蓝色字符为配置项。
    44. Thread-max字段为RESIN服务最大接收处理的进程个数,为了达到较好的性能输出,建议该项配置值为3.1连接池中max-connections参数的1倍。即,如果连接池max-connections设为10,那么就将thread-max设为20。
    45. #resin.3.1版本安装之后默认是1024,我改成了1024*20=20480.(zixun)
    46. 3.5 保持活动进程数
    47. <thread-keepalive id='19'/>,蓝色字符为配置项。
    48. Thread-keepalive字段为RESIN服务保持链接活动性的最大个数,它的值一定要小于3.4节中thread-max的值,否则RESIN无法启动。该项无建议值。
    49. 
    50. 3.6 请求超时时长
    51. <request-timeout id='65s'/>,蓝色字符为配置项,单位为秒。
    52. Request-timeout字段为RESIN服务返回请求链接超时的时间,默认即可。
    53. 
    54. 3.7 接收链接缓冲大小
    55. <accept-buffer-size id='500'/>,蓝色字符为配置项。
    56. Accept-buffer-size id字段为RESIN服务在满进程数下接收等待进程缓冲的个数,根据服务器、网络情况而定,无建议值。
    57. 
    58. 3.8 缓存文件过期时间
    59. <cache-mapping url-pattern='/' expires='2s'/>,蓝色字符为配置项。
    60. RESIN运行中把被访问文件数据进行缓存(默认缓存目录为RESIN安装目录下的cache目录,可在<cache dir='cache' size='1024' entries='8192'/>字段修改为指定路径),以便更加有效率的工作,Cache-mapping url-pattern字段为RESIN服务保持缓存文件有效性的时间,开发环境推荐配置为默认值2,生产环境建议配置较大值,比如15或30。本配置基 于应用,增加缓存有效时间,在有较多相同页面服务时减少了服务器的业务逻辑,转而利用磁盘缓冲文件提供数据;但是如果在固定时间长度里(比如10分钟)相 同页面的请求率很小或甚至没有相同的请求时,会增加一次缓存文件匹配动作,反而降低了服务器效率。因此,在特殊的应用中,可以将本配置项设为2,或注 释<cache dir='cache' size='1024' entries='8192'/>,取消缓存功能。
    61. 
    62. 3.9 虚拟主机设置
    63. 
    64. 3.9.1 默认文档设置
    65. <welcome-file-list>index.xtp, index.jsp, index.html</welcome-file-list>.
    66. Wecome-file-list字段为默认文档的文件列表。默认文档是在客户端访问Web服务器,比如RESIN,时如果没有制定要访问的文件(即输入 URL为目录名而不是具体的文件名,如:http://localhost:8080/),此时RESIN会根据该字段的值来搜索URL访问目录查找匹配 文件,如果找到文件则返回给用户而不需用户输入全部的URL,比如:http://localhost:8080/index.html。
    67. 该配置项一般用来设置默认主页。
    68. 
    69. 3.9.2 主机ID
    70. <host id=''>.
    71. Host id字段在单主机环境、一台服务器需要启动多个不同的RESIN服务时不用配置,请保持默认的空值。只有当与其他web服务器,比如apache等,同时使用时,考虑改配置项。
    72. 
    73. 3.9.3 日志
    74. <!--access-log id='logs/access.log'
    75. format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
    76. rollover-period='1W'/-->
    77. <error-log id='logs/error.log'/>,蓝色字符为配置项。
    78. ? access-log id字段为RESIN记录运行时访问日志,该日志在单独服务器情况下不推荐使用,就算在混合服务器情况下(比如IIS、APACHE等)也不推荐,除非要分析个服务器的访问情况。如果不使用注释该段即可(加入红色部分代码)。
    79. ? error-log id字段为RESIN错误日志,建议使用默认值。日志保存在RESIN安装目录的logs文件夹里。
    80. 
    81. 3.9.4 虚拟目录
    82. 在<host></host>字段中加入<web-app id='/test’ app-dir='C:\webapp'/>,蓝色字符为配置项。
    83. Web-app id字段为RESIN虚拟目录名,app-dir字段为本地路径值。
    84. 例如:上面的配置实现了将http://localhost:8080/test/ 映射到了服务器本地的c:\webapp目录,该目录内容应为web应用的代码或脚本。


    转载于:https://blog.51cto.com/zhongliang/1952575