ITPub博客

首页 > 数据库 > > Resin服务器简介、Resin服务器配置说明、Resin配置连接池

Resin服务器简介、Resin服务器配置说明、Resin配置连接池

作者:LCR_ 时间:2022-04-12 17:43:07 0 删除 编辑

一.Resin服务器简介

稍后补:

1、稍后补;

2、稍后补; 

二.Resin服务器配置说明(resin.conf配置详解)

  1. <!--
  2. - Resin 3.1 configuration file.
  3. - Resin 3.1 配置文件
  4. -->
  5. <resin xmlns="http://caucho.com/ns/resin"
  6. xmlns:resin="http://caucho.com/ns/resin/core">
  7. <!-- adds all .jar files under the resin/lib directory -->
  8. <!-- 加载resin/lib下的所有.jar文件 -->
  9. <class-loader>
  10. <tree-loader path="${resin.home}/ext-lib"/>
  11. <tree-loader path="${resin.root}/ext-lib"/>
  12. <tree-loader path="${resin.home}/lib"/>
  13. <tree-loader path="${resin.root}/lib"/>
  14. </class-loader>
  15. <!--
  16. - Management configuration
  17. - 管理配置
  18. -
  19. - Remote management requires at least one enabled admin user.
  20. -->
  21. <management path="${resin.root}/admin">
  22. <user name="admin" password="password" disable="true"/>
  23. <resin:if test="${resin.professional}">
  24. <deploy-service/>
  25. <jmx-service/>
  26. <log-service/>
  27. <xa-log-service/>
  28. </resin:if>
  29. </management>
  30. <!--
  31. - Logging configuration for the JDK logging API.
  32. - JDK日志接口的配置
  33. -->
  34. <log name="" level="info" path="stdout:"
  35. timestamp="[%H:%M:%S.%s] {%{thread}} "/>
  36. <!--
  37. - 'info' for production
  38. - 'fine' or 'finer' for development and troubleshooting
  39. - 日志信息的级别:'info' 生产环境 'fine' 开发环境 'finer' 调试环境
  40. -->
  41. <logger name="com.caucho" level="info"/>
  42. <logger name="com.caucho.java" level="config"/>
  43. <logger name="com.caucho.loader" level="config"/>
  44. <!--
  45. - For production sites, change dependency-check-interval to something
  46. - like 600s, so it only checks for updates every 10 minutes.
  47. - 环境上下文的检测时间,对于生产站点, 这个要设置长一点,例如600秒,10分钟
  48. -->
  49. <dependency-check-interval>2s</dependency-check-interval>
  50. <!--
  51. - SMTP server for sending mail notifications
  52. - 发送邮件通知的SMTP服务器
  53. -->
  54. <system-property mail.smtp.host="127.0.0.1"/>
  55. <system-property mail.smtp.port="25"/>
  56. <!--
  57. - Sets the default character encoding to utf-8
  58. -
  59. - <character-encoding>utf-8</character-encoding>
  60. -->
  61. <!--
  62. - You can change the compiler to "javac", "eclipse" or "internal".
  63. - 你可以把编译器改成 "javac", "eclipse" 或者 "internal"
  64. -->
  65. <javac compiler="internal" args="-source 1.5"/>
  66. <!-- Security providers.
  67. - <security-provider>
  68. - com.sun.net.ssl.internal.ssl.Provider
  69. - </security-provider>
  70. -->
  71. <!-- Uncomment to use Resin's XML implementations
  72. - 去掉注释,如果你使用resin提供的xml应用
  73. -
  74. - <system-property javax.xml.parsers.DocumentBuilderFactory
  75. - ="com.caucho.xml.parsers.XmlDocumentBuilderFactory"/>
  76. - <system-property javax.xml.parsers.SAXParserFactory
  77. - ="com.caucho.xml.parsers.XmlSAXParserFactory"/>
  78. -->
  79. <cluster id="app-tier">
  80. <!-- sets the content root for the cluster, relative to server.root -->
  81. <!-- 设置集群上下文的根, 相对于server.root -->
  82. <root-directory>.</root-directory>
  83. <server-default>
  84. <!-- The http port -->
  85. <!-- HTTP服务的端口 -->
  86. <http address="*" port="8080"/>
  87. <!--
  88. - SSL port configuration:
  89. - SSL端口配置
  90. -
  91. - <http address="*" port="8443">
  92. - <openssl>
  93. - <certificate-file>keys/gryffindor.crt</certificate-file>
  94. - <certificate-key-file>keys/gryffindor.key</certificate-key-file>
  95. - <password>test123</password>
  96. - </openssl>
  97. - </http>
  98. -->
  99. <!--
  100. - The JVM arguments
  101. - JVM参数设置
  102. -->
  103. <jvm-arg>-Xmx256m</jvm-arg>
  104. <jvm-arg>-Xss1m</jvm-arg>
  105. <jvm-arg>-Xdebug</jvm-arg>
  106. <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
  107. <!--
  108. - Uncomment to enable admin heap dumps
  109. - 去掉这个如果你想管理内存堆的倾倒
  110. - <jvm-arg>-agentlib:resin</jvm-arg>
  111. -->
  112. <!--
  113. - arguments for the watchdog process
  114. -->
  115. <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>
  116. <watchdog-port>6600</watchdog-port>
  117. <!--
  118. - Configures the minimum free memory allowed before Resin
  119. - will force a restart.
  120. - 强制resin强制重起时的最小空闲内存
  121. -->
  122. <memory-free-min>1M</memory-free-min>
  123. <!-- Maximum number of threads. -->
  124. <!-- 最大线程数量 -->
  125. <thread-max>256</thread-max>
  126. <!-- Configures the socket timeout -->
  127. <!-- 套接字等待时间 -->
  128. <socket-timeout>65s</socket-timeout>
  129. <!-- Configures the keepalive -->
  130. <!-- 配置 keepalive -->
  131. <keepalive-max>128</keepalive-max>
  132. <keepalive-timeout>15s</keepalive-timeout>
  133. <!--
  134. - If starting bin/resin as root on Unix, specify the user name
  135. - and group name for the web server user.
  136. - 如果使用的是UNIX,这里是启动的帐号和用户组
  137. -
  138. - <user-name>resin</user-name>
  139. - <group-name>resin</group-name>
  140. -->
  141. </server-default>
  142. <!-- define the servers in the cluster -->
  143. <!-- 定义群集服务器 -->
  144. <server id="" address="127.0.0.1" port="6800"/>
  145. <!--
  146. - Configures the persistent store for single-server or clustered
  147. - in Resin professional.
  148. - 配置独立服务器或者群集的持久化存储,专业版的功能
  149. -->
  150. <resin:if test="${resin.professional}">
  151. <persistent-store type="cluster">
  152. <init path="session"/>
  153. </persistent-store>
  154. </resin:if>
  155. <!--
  156. - For security, use a different cookie for SSL sessions.
  157. - 为了安全, 你可以为SSL会话(SSL sessions)定义一个不同的cookie
  158. - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
  159. -->
  160. <!--
  161. - Enables the cache (available in Resin Professional)
  162. - 缓存启用 (专业版的功能)
  163. -->
  164. <resin:if test="${resin.professional}">
  165. <cache path="cache" memory-size="64M">
  166. <!-- Vary header rewriting for IE -->
  167. <rewrite-vary-as-private/>
  168. </cache>
  169. </resin:if>
  170. <!--
  171. - Enables periodic checking of the server status and
  172. - check for deadlocks..
  173. -
  174. - All servers can add <url>s to be checked.
  175. - 启用周期性的服务器状态检查和死锁检查,所有的服务器可以添加 <url> 来检查
  176. -->
  177. <resin:if test="${resin.professional}">
  178. <ping>
  179. <!-- <url>http://localhost:8080/test-ping.jsp</url> -->
  180. </ping>
  181. </resin:if>
  182. <!--
  183. - Defaults applied to each web-app.
  184. - 每一个web应用的默认参数
  185. -->
  186. <web-app-default>
  187. <prologue>
  188. <!--
  189. - Extension library for common jar files. The ext is safe
  190. - even for non-classloader aware jars. The loaded classes
  191. - will be loaded separately for each web-app, i.e. the class
  192. - itself will be distinct.
  193. - 扩展库的公共jar文件,扩展是安全的即使没有类装载器知道的jars,装载的类将为每个应用分别装载,也就是这些类都是不同的
  194. -->
  195. <class-loader>
  196. <tree-loader path="${resin.root}/ext-webapp-lib"/>
  197. </class-loader>
  198. <!--
  199. - Enable EL expressions in Servlet and Filter init-param
  200. - 启用EL表达式
  201. -->
  202. <allow-servlet-el/>
  203. </prologue>
  204. <!--
  205. - Sets timeout values for cacheable pages, e.g. static pages.
  206. - 设置缓存页、静态也的延时值
  207. -->
  208. <cache-mapping url-pattern="/" expires="5s"/>
  209. <cache-mapping url-pattern="*.gif" expires="60s"/>
  210. <cache-mapping url-pattern="*.jpg" expires="60s"/>
  211. <cache-mapping url-pattern="*.png" expires="60s"/>
  212. <!--
  213. - for security, disable session URLs by default.
  214. - 安全原因, 默认禁用了会话的URLs
  215. -->
  216. <session-config>
  217. <enable-url-rewriting>false</enable-url-rewriting>
  218. </session-config>
  219. <!--
  220. - For security, set the HttpOnly flag in cookies.
  221. - 安全原因, 在cookies中设置HttpOnly标志
  222. - <cookie-http-only/>
  223. -->
  224. <!--
  225. - Some JSP packages have incorrect .tld files. It's possible to
  226. - set validate-taglib-schema to false to work around these packages.
  227. - 一些JSP包有不正确的 .tld文件。可以把validate-taglib-schema设置成false,可能继续正常工作
  228. -->
  229. <jsp>
  230. <validate-taglib-schema>true</validate-taglib-schema>
  231. <fast-jstl>true</fast-jstl>
  232. </jsp>
  233. </web-app-default>
  234. <!-- includes the app-default for default web-app behavior -->
  235. <!-- 包含web应用的默认行为 -->
  236. <resin:import path="${resin.home}/conf/app-default.xml"/>
  237. <!--
  238. - Sample database pool configuration
  239. -
  240. - The JDBC name is java:comp/env/jdbc/test
  241. - 简单的数据池配置
  242. <database>
  243. <jndi-name>jdbc/mysql</jndi-name>
  244. <driver type="org.gjt.mm.mysql.Driver">
  245. <url>jdbc:mysql://localhost:3306/test</url>
  246. <user></user>
  247. <password></password>
  248. </driver>
  249. <prepared-statement-cache-size>8</prepared-statement-cache-size>
  250. <max-connections>20</max-connections>
  251. <max-idle-time>30s</max-idle-time>
  252. </database>
  253. -->
  254. <!--
  255. - Default host configuration applied to all virtual hosts.
  256. - 定义所有虚拟主机的默认配置
  257. -->
  258. <host-default>
  259. <!--
  260. - With another web server, like Apache, this can be commented out
  261. - because the web server will log this information.
  262. - 如果和别的web服务器整合,这个可以被去掉,因为web服务器也可以记录这些信息
  263. -->
  264. <access-log path="logs/access.log"
  265. format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
  266. rollover-period="1W"/>
  267. <!-- creates the webapps directory for .war expansion -->
  268. <!-- war 文件的布置目录 -->
  269. <web-app-deploy path="webapps"/>
  270. <!-- creates the deploy directory for .ear expansion -->
  271. <!-- ear文件的布置目录 -->
  272. <ear-deploy path="deploy">
  273. <ear-default>
  274. <ejb-server>
  275. <config-directory>WEB-INF</config-directory>
  276. </ejb-server>
  277. </ear-default>
  278. </ear-deploy>
  279. <!-- creates the deploy directory for .rar expansion -->
  280. <!-- rar文件的布置目录 -->
  281. <resource-deploy path="deploy"/>
  282. </host-default>
  283. <!-- configures a deployment directory for virtual hosts -->
  284. <!-- 虚拟主机的布置目录 -->
  285. <host-deploy path="hosts">
  286. <host-default>
  287. <resin:import path="host.xml" optional="true"/>
  288. </host-default>
  289. </host-deploy>
  290. <!-- configures the default host, matching any host name -->
  291. <!-- 默认的虚拟主机配置 -->
  292. <host id="" root-directory=".">
  293. <!--
  294. - configures an explicit root web-app matching the
  295. - webapp's ROOT
  296. - 配置默认的应用 webapp's ROOT
  297. -->
  298. <web-app id="/" root-directory="webapps/ROOT"/>
  299. <web-app id="/resin-admin" root-directory="${resin.home}/php/admin">
  300. <!--
  301. - Administration application /resin-admin
  302. - 管理应用程序 /resin-admin
  303. -->
  304. <prologue>
  305. <resin:set var="resin_admin_external" value="false"/>
  306. <resin:set var="resin_admin_insecure" value="true"/>
  307. </prologue>
  308. </web-app>
  309. </host>
  310. </cluster>
  311. <!--
  312. - Configuration for the web-tier/load-balancer
  313. -->
  314. <resin:if test="${resin.professional}">
  315. <cluster id="web-tier">
  316. <server-default>
  317. <!-- The http port -->
  318. <http address="*" port="9080"/>
  319. </server-default>
  320. <server id="web-a" address="127.0.0.1" port="6700"/>
  321. <cache path="cache" memory-size="64M"/>
  322. <host id="">
  323. <web-app id="/">
  324. <rewrite-dispatch>
  325. <load-balance regexp="" cluster="app-tier"/>
  326. </rewrite-dispatch>
  327. </web-app>
  328. </host>
  329. </cluster>
  330. </resin:if>
  331. </resin>

 

三.Resin配置连接池

连接池的概念:

        在动态web站点设计中,数据库已成为必不可少的一部分,但数据库连接和释放开销很大,对于一个访问量少的网站可能没有什么影响,但同时有很多用户来网站查询资料时,就会导致服务器响应慢甚至死机。连接池就是针对这个问题提出的。
        数据库连接池负责分配、管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而再不是重新建立一个;释放空闲时间超过最大空闲时间的数据库连接来避免因为没有释放数据库连接而引起的数据库连接遗漏。这项技术能明显提高对数据库操作的性能。
        数据库连接池在初始化时将创建一定数量的数据库连接放到连接池中,这些数据库连接的数量是由最小数据库连接数来设定的。无论这些数据库连接是否被使用,连接池都将一直保证至少拥有这么多的连接数量。连接池的最大数据库连接数量限定了这个连接池能占有的最大连接数,当应用程序向连接池请求的连接数超过最大连接数量时,这些请求将被加入到等待队列中。

resin中相关配置:        

        Resin提供了一个良好的连接池来供开发人员来实现数据库连接,具体配置如下,在/conf/resin.conf中<resin></resin>标签中有以下内容:

  1. <!--
  2. - Sample database pool configuration
  3. -
  4. - The JDBC name is java:comp/env/jdbc/test
  5. <database>
  6. <jndi-name>jdbc/mysql</jndi-name>
  7. <driver type="org.gjt.mm.mysql.Driver">
  8. <url>jdbc:mysql://localhost:3306/test</url>
  9. <user></user>
  10. <password></password>
  11. </driver>
  12. <prepared-statement-cache-size>8</prepared-statement-cache-size>
  13. <max-connections>20</max-connections>
  14. <max-idle-time>30s</max-idle-time>
  15. </database>
  16. -->

resin对具体参数的解析:

结合案例分析上述参数,稍后补;

 

四.与tomcat服务器性能比

1、移植性

    tomcat是参照标准J2EE实现,移植性会更好(对于老手来说tomcat和resin都一样,当然不把EJB那包括进来)

2、速度

    resin的速度要比tomcat快*3倍,官方的测试报告是针对resin-2.x与tomat4.x版本以前的比较了。

    resin的 启动与关闭机制感觉要比tomcat好很多,首先,tomcat在windows下启动,双击完startup.bat后总要等几秒钟才会启动服务,并且 关闭的时候也是一样的,有的时候甚至双击了shutdown.bat后startup.bat的窗口还总是在那好长时间,并且如果你哪一次不小心直接关闭 了dos窗口而没有运行shutdown,那下一次肯定要出问题,在linux下启动速度还是很不错的,但如果启动错误报错真是很郁闷。而相 反,resin的启动就十分人性化了,运行httpd后会出来个窗口,其中有start和stop,你可以随时方便的启动和关闭服务,并且速度也十分的 快,并且如果你的配置文件如果有改动的话,启动程序会自动监测并自动重启的,这样在配置环境的时候就不需要像tomcat那样需要反复人工关闭再启动,这 点tomcat真是差的很远。

3、报错机制

    resin更好的支持中文,更好的报错机制。

     resin对于中文的支持要比 tomcat好很多,各种编码和转码很多都是对tomcat设计的,因为在resin平台下根本就不需要,这点对于开发也是很重要的,特别要提的一点就 是,用tomcat写的面页很多时候如果只在面页加上contentType="text/html; charset=gb2312"还是不能完成编码的还必须要加入一条看起来像是画蛇添足的一条语句 request.setCharacterEncoding("gb2312"),这一点真实让人不能忍受。

     tomcat的报错机制,哪怕仅仅只是个小错误,tomcat都会用整页的篇幅来描述,如果时间长了还好,但新手肯定会望而生畏的,相反,resin的报错是十分简洁 而明确的,可以让你一眼就可以看出程序错误的类型和位置,这点对于刚开始学习的人来说无疑是很有帮助的。

4、方便性

    resin支持自动编译 Servlet和Bean;

    tomcat还不支持j2ee,至少在5以前还是这样的;

5、成本

    个人认为,对于企业来说,效率高和成本低的开发,才符合创造最大经济消息的原则,用resin开发,一般的应用完全能胜任。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70000523/viewspace-3125169/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2022-02-22

  • 博文量
    1402
  • 访问量
    15038