resin.conf配置详解
如下讲的是在 linux上安装resin服务器的配置 ,在window上就安装的时候不用设置 其他都一样1.安装好一个resin不动
2. 安装另外目录一个resin,修改resin.conf的端口(8080和6802的就可以了)、路径
3. 修改另外的resin的httpd.sh,在里面增加:
[*]JAVA_HOME=/opt/jdk1.0.23
[*]RESIN_HOME=/opt/resin2 //第二个resin的目录
[*]JRE_HOME=$JAVA_HOME/jre
[*]Export JAVA_HOME RESIN_HOME JRE_HOME
网上说resin比tomcat的速度快5倍。下面是resin配置文件的详细解释:
[*]<!-- - Resin 3.1 配置文件. -->
[*]<resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core">
[*]<!-- 加载resin/lib下的所有.jar文件-->
[*]<class-loader>
[*]<tree-loader path="${resin.home}/lib"/>
[*]<tree-loader path="${resin.root}/lib"/>
[*]</class-loader>
[*]<!-- - 管理配置 -->
[*]<management path="${resin.root}/admin">
[*]</management>
[*]<!-- -JDK日志接口的配置. -->
[*]<log name="" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
[*]<!-- 日志信息的级别:'info' 生产环境 'fine' 开发环境 'finer' 调试环境 -->
[*]<logger name="com.caucho" level="info"/>
[*]<logger name="com.caucho.java" level="config"/>
[*]<logger name="com.caucho.loader" level="config"/>
[*]<!-- - 环境上下文的检测时间,对于生产站点, 这个要设置长一点,例如600秒,10分钟 -->
[*]<dependency-check-interval>2s</dependency-check-interval>
[*]<!-- - 发送邮件通知的SMTP服务器 -->
[*]<system-property mail.smtp.host="127.0.0.1"/>
[*]<system-property mail.smtp.port="25"/>
[*]<!-- - 你可以把编译器改成 "javac", "eclipse" 或者 "internal". -->
[*]<javac compiler="internal" args="-source 1.5"/>
[*]<!-- Security providers.
[*]- <security-provider>
[*]- com.sun.net.ssl.internal.ssl.Provider
[*]- </security-provider>
[*]-->
[*]<!-- 去掉注释,如果你使用resin提供的xml应用
[*]-
[*]- <system-property javax.xml.parsers.DocumentBuilderFactory
[*]- ="com.caucho.xml.parsers.XmlDocumentBuilderFactory"/>
[*]- <system-property javax.xml.parsers.SAXParserFactory
[*]- ="com.caucho.xml.parsers.XmlSAXParserFactory"/>
[*]-->
[*]<cluster id="app-tier">
[*]<!-- 设置集群上下文的根, 相对于server.root -->
[*]<root-directory>.</root-directory>
[*]<server-default>
[*]<!-- HTTP服务的端口-->
[*]<http address="*" port="8080"/>
[*]<!--
[*]- SSL端口配置:
[*]-
[*]- <http address="*" port="8443">
[*]- <openssl>
[*]- <certificate-file>keys/gryffindor.crt</certificate-file>
[*]- <certificate-key-file>keys/gryffindor.key</certificate-key-file>
[*]- <password>test123</password>
[*]- </openssl>
[*]- </http>
[*]-->
[*]<!-- - JVM参数设置 -->
[*]<jvm-arg>-Xmx256m</jvm-arg>
[*]<jvm-arg>-Xss1m</jvm-arg>
[*]<jvm-arg>-Xdebug</jvm-arg>
[*]<jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
[*]<!-- Uncomment to enable admin heap dumps 去掉这个如果你想管理内存堆的倾倒
[*]- <jvm-arg>-agentlib:resin</jvm-arg>
[*]-->
[*]<watchdog-arg>-Dcom.sun.management.jmxremote</watchdog-arg>
[*]<!-- 强制resin强制重起时的最小空闲内存 -->
[*]<memory-free-min>1M</memory-free-min>
[*]<!-- 最大线程数量. -->
[*]<thread-max>256</thread-max>
[*]<!-- 套接字等待时间 -->
[*]<socket-timeout>65s</socket-timeout>
[*]<!-- 配置 keepalive -->
[*]<keepalive-max>128</keepalive-max>
[*]<keepalive-timeout>15s</keepalive-timeout>
[*]<!-- - 如果使用的是UNIX,这里是启动的帐号和用户组.
[*]- <user-name>resin</user-name>
[*]- <group-name>resin</group-name>
[*]-->
[*]</server-default>
[*]<!-- 定义群集服务器 -->
[*]<server id="" address="127.0.0.1" port="6800"/>
[*]<!-- Configures the persistent store for single-server or clustered 配置独立服务器或者群集的持久化存储,专业版的功能 -->
[*]<resin:if test="${resin.isProfessional()}">
[*]<persistent-store type="cluster">
[*]<init path="session"/>
[*]</persistent-store>
[*]</resin:if>
[*]<!-- 为了安全, 你可以为SSL会话(SSL sessions)定义一个不同的cookie.
[*]- <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
[*]-->
[*]<!-- 缓存启用 (专业版的功能) -->
[*]<resin:if test="${isResinProfessional}">
[*]<cache path="cache" memory-size="64M">
[*]<!-- Vary header rewriting for IE -->
[*]<rewrite-vary-as-private/>
[*]</cache>
[*]</resin:if>
[*]<!-- 启用周期性的服务器状态检查和死锁检查,所有的服务器可以添加 <url> 来检查。 -->
[*]<resin:if test="${isResinProfessional}">
[*]<ping>
[*]<!-- <url>http://localhost:8080/test-ping.jsp</url> -->
[*]</ping>
[*]</resin:if>
[*]<!-- 包含web应用的默认行为 -->
[*]<resin:import path="${resin.home}/conf/app-default.xml"/>
[*]<!-- 每一个web应用的默认参数 -->
[*]<web-app-default>
[*]<!-- 扩展库的公共jar文件,扩展是安全的即使没有类装载器知道的jars,装载的类将为每个应用分别装载,也就是这些类都是不同的 -->
[*]<class-loader>
[*]<tree-loader path="${server.root}/ext-webapp"/>
[*]</class-loader>
[*]<!-- 设置缓存页、静态也的延时值 -->
[*]<cache-mapping url-pattern="/" expires="5s"/>
[*]<cache-mapping url-pattern="*.gif" expires="60s"/>
[*]<cache-mapping url-pattern="*.jpg" expires="60s"/>
[*]<cache-mapping url-pattern="*.png" expires="60s"/>
[*]<!-- 启用EL表达式 -->
[*]<allow-servlet-el/>
[*]<!-- 安全原因, 默认禁用了会话的URLs -->
[*]<session-config>
[*]<enable-url-rewriting>false</enable-url-rewriting>
[*]</session-config>
[*]<!-- 安全原因, 在cookies中设置HttpOnly标志
[*]- <cookie-http-only/>
[*]-->
[*]<!--一些JSP包有不正确的 .tld文件。可以把validate-taglib-schema设置成false,可能继续正常工作
[*]- Some JSP packages have incorrect .tld files. It's possible to set validate-taglib-schema to false to work around these packages.
[*]-->
[*]<jsp>
[*]<validate-taglib-schema>true</validate-taglib-schema>
[*]<fast-jstl>true</fast-jstl>
[*]<fast-jsf>true</fast-jsf>
[*]</jsp>
[*]</web-app-default>
[*]<!-- 简单的数据池配置
[*]- The JDBC name is java:comp/env/jdbc/test
[*]<database>
[*]<jndi-name>jdbc/mysql</jndi-name>
[*]<driver type="org.gjt.mm.mysql.Driver">
[*]<url>jdbc:mysql://localhost:3306/test</url>
[*]<user></user>
[*]<password></password>
[*]</driver>
[*]<prepared-statement-cache-size>8</prepared-statement-cache-size>
[*]<max-connections>20</max-connections>
[*]<max-idle-time>30s</max-idle-time>
[*]</database>
[*]-->
[*]<!-- 定义所有虚拟主机的默认配置 -->
[*]<host-default>
[*]<!-- 如果和别的web服务器整合,这个可以被去掉,因为web服务器也可以记录这些信息。 -->
[*]<access-log path="logs/access.log" format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' rollover-period="1W"/>
[*]<!-- war 文件的布置目录 -->
[*]<web-app-deploy path="webapps"/>
[*]<!-- ear文件的布置目录 -->
[*]<ear-deploy path="deploy">
[*]<ear-default>
[*]<ejb-server>
[*]<config-directory>WEB-INF</config-directory>
[*]<data-source>jdbc/test</data-source>
[*]</ejb-server>
[*]</ear-default>
[*]</ear-deploy>
[*]<!-- rar文件的布置目录 -->
[*]<resource-deploy path="deploy"/>
[*]</host-default>
[*]<!-- 虚拟主机的布置目录 -->
[*]<host-deploy path="hosts">
[*]<host-default>
[*]<resin:import path="host.xml" optional="true"/>
[*]</host-default>
[*]</host-deploy>
[*]<!-- 默认的虚拟主机配置 -->
[*]<host id="" root-directory=".">
[*]<!-- 配置默认的应用 webapp's ROOT -->
[*]<web-app id="/" root-directory="webapps/ROOT"/>
[*]<web-app id="/resin-admin" root-directory="${resin.home}/php/admin">
[*]<!-- - 管理应用程序 /resin-admin
[*]- password is the md5 hash of the password。md5码的密码。
[*]- localhost is true to limit access to the localhost。localhost设置成true,这样只有localhost才能访问
[*]-->
[*]<prologue>
[*]<resin:set var="resin_admin_user" value=""/>
[*]<resin:set var="resin_admin_password" value=""/>
[*]<resin:set var="resin_admin_external" value="false"/>
[*]</prologue>
[*]</web-app>
[*]</host>
[*]</cluster>
[*]<!-- - Configuration for the web-tier/load-balancer -->
[*]<resin:if test="${resin.isProfessional()}">
[*]<cluster id="web-tier">
[*]<server-default>
[*]<!-- The http port -->
[*]<http address="*" port="9080"/>
[*]</server-default>
[*]<server id="web-a" address="127.0.0.1" port="6700"/>
[*]<cache path="cache" memory-size="64M"/>
[*]<host id="">
[*]<web-app id="/">
[*]<rewrite-dispatch>
[*]<load-balance regexp="" cluster="app-tier"/>
[*]</rewrite-dispatch>
[*]</web-app>
[*]</host>
[*]</cluster>
[*]</resin:if>
[*]</resin>
关键配置解释:
[*]http://hi.baidu.com/athlonzeng/blog/item/eaea0b3ffa5b32eb55e7232c.html
[*]3.1 数据库连接池配置
[*]如果应用使用数据库连接池,查找<caucho.com>,在其后加入数据库连接池的配置信息如下:
[*]SQL SERVER
[*]==================================================================
[*]<resource-ref>
[*]<res-ref-name>jdbc/job36_use</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.3.84:1433;create=true;DatabaseName=CRM"/>
[*]<init-param user="sa"/>
[*]<init-param password="job36"/>
[*]<init-param max-connections="10"/>
[*]<init-param enable-transaction="true"/>
[*]</resource-ref>
[*]
[*]ORACLE
[*]==================================================================
[*]<resource-ref>
[*]<res-ref-name>jdbc/job36</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.3.84:1521:CRM"/>
[*]<init-param user="job36"/>
[*]<init-param password="job36"/>
[*]<init-param max-connections="10"/>
[*]<init-param enable-transaction="false"/>
[*]</resource-ref>
[*]注意:如果要访问数据库,请先确认RESIN安装目录下lib文件夹有相应数据库的JDBC驱动,如mssqlserver.jar或oracle_jdbc.jar等,否则请先将驱动文件拷贝到该目录,不然无法访问数据库。
[*]<res-ref-name>字段为连接池名字,要与业务应用配置相同;
[*]<init-param url>字段为数据库连接字符串,蓝色部分为数据库服务器IP:PORT、数据库名或SID。<init-param user>数据库用户名。
[*]<init-param password>密码。
[*]<init-param max-connections>字段为连接池最大连接个数,这个数据对基于WEB的数据库应用性能有一定影响,建议配置数为10~40(数据库应用较多时配置应偏小,网页应用较多时应偏大)。
[*]
[*]3.2 服务端口配置
[*]查找<http port='8080'/>,蓝色字符串即为端口号,根据实际应用修改。
[*]如果需要在一台服务器上启动多个resin服务,请按相应规划各应用端口号在每个resin安装目录的配置文件中配置该项,不可重复。
[*]
[*]3.3 更新类间隔时间
[*]<class-update-interval>60s</class-update-interval>,蓝色字符为配置项,单位为秒。
[*]Class-update-interval字段对RESIN服务性能影响较大,请根据需求更改,建议配置原则为:在开发环境,设为2或更小,这样有利于 及时反映程序的修改对应用造成的改变;生产环境建议配置最小60,根据生产环境的特点,不可能有频繁的类改动或是JAVA脚本改变,或者根本不会有改动, 所以依据实际情况,设置为60~3600。
[*]
[*]3.4 最大进程数
[*]<thread-max>20</thread-max>,蓝色字符为配置项。
[*]Thread-max字段为RESIN服务最大接收处理的进程个数,为了达到较好的性能输出,建议该项配置值为3.1连接池中max-connections参数的1倍。即,如果连接池max-connections设为10,那么就将thread-max设为20。
[*]#resin.3.1版本安装之后默认是1024,我改成了1024*20=20480.(zixun)
[*]3.5 保持活动进程数
[*]<thread-keepalive id='19'/>,蓝色字符为配置项。
[*]Thread-keepalive字段为RESIN服务保持链接活动性的最大个数,它的值一定要小于3.4节中thread-max的值,否则RESIN无法启动。该项无建议值。
[*]
[*]3.6 请求超时时长
[*]<request-timeout id='65s'/>,蓝色字符为配置项,单位为秒。
[*]Request-timeout字段为RESIN服务返回请求链接超时的时间,默认即可。
[*]
[*]3.7 接收链接缓冲大小
[*]<accept-buffer-size id='500'/>,蓝色字符为配置项。
[*]Accept-buffer-size id字段为RESIN服务在满进程数下接收等待进程缓冲的个数,根据服务器、网络情况而定,无建议值。
[*]
[*]3.8 缓存文件过期时间
[*]<cache-mapping url-pattern='/' expires='2s'/>,蓝色字符为配置项。
[*]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'/>,取消缓存功能。
[*]
[*]3.9 虚拟主机设置
[*]
[*]3.9.1 默认文档设置
[*]<welcome-file-list>index.xtp, index.jsp, index.html</welcome-file-list>.
[*]Wecome-file-list字段为默认文档的文件列表。默认文档是在客户端访问Web服务器,比如RESIN,时如果没有制定要访问的文件(即输入 URL为目录名而不是具体的文件名,如:http://localhost:8080/),此时RESIN会根据该字段的值来搜索URL访问目录查找匹配 文件,如果找到文件则返回给用户而不需用户输入全部的URL,比如:http://localhost:8080/index.html。
[*]该配置项一般用来设置默认主页。
[*]
[*]3.9.2 主机ID
[*]<host id=''>.
[*]Host id字段在单主机环境、一台服务器需要启动多个不同的RESIN服务时不用配置,请保持默认的空值。只有当与其他web服务器,比如apache等,同时使用时,考虑改配置项。
[*]
[*]3.9.3 日志
[*]<!--access-log id='logs/access.log'
[*]format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
[*]rollover-period='1W'/-->
[*]<error-log id='logs/error.log'/>,蓝色字符为配置项。
[*]? access-log id字段为RESIN记录运行时访问日志,该日志在单独服务器情况下不推荐使用,就算在混合服务器情况下(比如IIS、APACHE等)也不推荐,除非要分析个服务器的访问情况。如果不使用注释该段即可(加入红色部分代码)。
[*]? error-log id字段为RESIN错误日志,建议使用默认值。日志保存在RESIN安装目录的logs文件夹里。
[*]
[*]3.9.4 虚拟目录
[*]在<host></host>字段中加入<web-app id='/test’ app-dir='C:\webapp'/>,蓝色字符为配置项。
[*]Web-app id字段为RESIN虚拟目录名,app-dir字段为本地路径值。
[*]例如:上面的配置实现了将http://localhost:8080/test/ 映射到了服务器本地的c:\webapp目录,该目录内容应为web应用的代码或脚本。
页:
[1]