resin服务器配置

来源:互联网 发布:手机能注册淘宝邮箱吗 编辑:程序博客网 时间:2024/06/12 07:40

一、resin配置文件说明

<!--   - Resin 3.1 configuration file.   - Resin 3.1 配置文件  --><resin xmlns="http://caucho.com/ns/resin"       xmlns:resin="http://caucho.com/ns/resin/core">  <!-- adds all .jar files under the resin/lib directory -->  <!-- 加载resin/lib下的所有.jar文件 -->  <class-loader>    <tree-loader path="${resin.home}/ext-lib"/>    <tree-loader path="${resin.root}/ext-lib"/>    <tree-loader path="${resin.home}/lib"/>    <tree-loader path="${resin.root}/lib"/>  </class-loader>  <!--     - Management configuration     - 管理配置     -     - Remote management requires at least one enabled admin user.    -->  <management path="${resin.root}/admin">    <user name="admin" password="password" disable="true"/>    <resin:if test="${resin.professional}">      <deploy-service/>      <jmx-service/>      <log-service/>      <xa-log-service/>    </resin:if>  </management>  <!--     - Logging configuration for the JDK logging API.     - JDK日志接口的配置    -->  <log name="" level="info" path="stdout:"       timestamp="[%H:%M:%S.%s] {%{thread}} "/>  <!--     - 'info' for production     - 'fine' or 'finer' for development and troubleshooting     - 日志信息的级别:'info' 生产环境 'fine' 开发环境 'finer' 调试环境    -->  <logger name="com.caucho" level="info"/>  <logger name="com.caucho.java" level="config"/>  <logger name="com.caucho.loader" level="config"/>  <!--     - For production sites, change dependency-check-interval to something     - like 600s, so it only checks for updates every 10 minutes.     - 环境上下文的检测时间,对于生产站点, 这个要设置长一点,例如600秒,10分钟    -->  <dependency-check-interval>2s</dependency-check-interval>  <!--     - SMTP server for sending mail notifications     - 发送邮件通知的SMTP服务器    -->  <system-property mail.smtp.host="127.0.0.1"/>  <system-property mail.smtp.port="25"/>  <!--     - Sets the default character encoding to utf-8     -     - <character-encoding>utf-8</character-encoding>    -->  <!--     - You can change the compiler to "javac", "eclipse" or "internal".     - 你可以把编译器改成 "javac", "eclipse" 或者 "internal"    -->  <javac compiler="internal" args="-source 1.5"/>  <!-- Security providers.     - <security-provider>     -    com.sun.net.ssl.internal.ssl.Provider     - </security-provider>    -->  <!-- Uncomment to use Resin's XML implementations     - 去掉注释,如果你使用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">    <!-- sets the content root for the cluster, relative to server.root -->    <!-- 设置集群上下文的根, 相对于server.root -->    <root-directory>.</root-directory>    <server-default>      <!-- The http port -->      <!-- HTTP服务的端口 -->      <http address="*" port="8080"/>      <!--         - SSL port configuration:         - 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>        -->      <!--         - The JVM arguments         - 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>        -->      <!--         - arguments for the watchdog process        -->      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>      <watchdog-port>6600</watchdog-port>      <!--         - Configures the minimum free memory allowed before Resin         - will force a restart.         - 强制resin强制重起时的最小空闲内存        -->      <memory-free-min>1M</memory-free-min>      <!-- Maximum number of threads. -->      <!-- 最大线程数量 -->      <thread-max>256</thread-max>      <!-- Configures the socket timeout -->      <!-- 套接字等待时间 -->      <socket-timeout>65s</socket-timeout>      <!-- Configures the keepalive -->      <!-- 配置 keepalive -->      <keepalive-max>128</keepalive-max>      <keepalive-timeout>15s</keepalive-timeout>      <!--         - If starting bin/resin as root on Unix, specify the user name         - and group name for the web server user.         - 如果使用的是UNIX,这里是启动的帐号和用户组         -         - <user-name>resin</user-name>         - <group-name>resin</group-name>        -->    </server-default>    <!-- define the servers in the cluster -->    <!-- 定义群集服务器 -->    <server id="" address="127.0.0.1" port="6800"/>    <!--       - Configures the persistent store for single-server or clustered       - in Resin professional.       - 配置独立服务器或者群集的持久化存储,专业版的功能      -->    <resin:if test="${resin.professional}">      <persistent-store type="cluster">        <init path="session"/>      </persistent-store>    </resin:if>    <!--       - For security, use a different cookie for SSL sessions.       - 为了安全, 你可以为SSL会话(SSL sessions)定义一个不同的cookie       - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>      -->    <!--       - Enables the cache (available in Resin Professional)        - 缓存启用 (专业版的功能)      -->    <resin:if test="${resin.professional}">      <cache path="cache" memory-size="64M">        <!-- Vary header rewriting for IE -->        <rewrite-vary-as-private/>      </cache>    </resin:if>    <!--       - Enables periodic checking of the server status and       - check for deadlocks..       -       - All servers can add <url>s to be checked.       - 启用周期性的服务器状态检查和死锁检查,所有的服务器可以添加 <url> 来检查      -->    <resin:if test="${resin.professional}">      <ping>        <!-- <url>http://localhost:8080/test-ping.jsp</url> -->      </ping>    </resin:if>    <!--       - Defaults applied to each web-app.       - 每一个web应用的默认参数      -->    <web-app-default>      <prologue>        <!--           - Extension library for common jar files.  The ext is safe           - even for non-classloader aware jars.  The loaded classes           - will be loaded separately for each web-app, i.e. the class           - itself will be distinct.           - 扩展库的公共jar文件,扩展是安全的即使没有类装载器知道的jars,装载的类将为每个应用分别装           - 载,也就是这些类都是不同的          -->        <class-loader>          <tree-loader path="${resin.root}/ext-webapp-lib"/>        </class-loader>        <!--           - Enable EL expressions in Servlet and Filter init-param           - 启用EL表达式          -->        <allow-servlet-el/>      </prologue>      <!--         - Sets timeout values for cacheable pages, e.g. static pages.         - 设置缓存页、静态也的延时值        -->      <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"/>      <!--         - for security, disable session URLs by default.         - 安全原因, 默认禁用了会话的URLs        -->      <session-config>        <enable-url-rewriting>false</enable-url-rewriting>      </session-config>      <!--         - For security, set the HttpOnly flag in cookies.         - 安全原因, 在cookies中设置HttpOnly标志         - <cookie-http-only/>        -->      <!--         - Some JSP packages have incorrect .tld files.  It's possible to         - set validate-taglib-schema to false to work around these packages.         - 一些JSP包有不正确的 .tld文件。可以把validate-taglib-schema设置成false,可能继续正常工作        -->        <jsp>          <validate-taglib-schema>true</validate-taglib-schema>          <fast-jstl>true</fast-jstl>        </jsp>    </web-app-default>    <!-- includes the app-default for default web-app behavior -->    <!-- 包含web应用的默认行为 -->    <resin:import path="${resin.home}/conf/app-default.xml"/>    <!--       - Sample database pool configuration       -       - 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>      -->    <!--       - Default host configuration applied to all virtual hosts.       - 定义所有虚拟主机的默认配置      -->    <host-default>      <!--         - With another web server, like Apache, this can be commented out         - because the web server will log this information.         - 如果和别的web服务器整合,这个可以被去掉,因为web服务器也可以记录这些信息        -->      <access-log path="logs/access.log"             format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'            rollover-period="1W"/>      <!-- creates the webapps directory for .war expansion -->      <!-- war 文件的布置目录 -->      <web-app-deploy path="webapps"/>      <!-- creates the deploy directory for .ear expansion -->      <!-- ear文件的布置目录 -->      <ear-deploy path="deploy">        <ear-default>          <ejb-server>            <config-directory>WEB-INF</config-directory>          </ejb-server>        </ear-default>      </ear-deploy>      <!-- creates the deploy directory for .rar expansion -->      <!-- rar文件的布置目录 -->      <resource-deploy path="deploy"/>    </host-default>    <!-- configures a deployment directory for virtual hosts -->    <!-- 虚拟主机的布置目录 -->    <host-deploy path="hosts">      <host-default>        <resin:import path="host.xml" optional="true"/>      </host-default>    </host-deploy>    <!-- configures the default host, matching any host name -->    <!-- 默认的虚拟主机配置 -->    <host id="" root-directory=".">      <!--         - configures an explicit root web-app matching the         - webapp's ROOT         - 配置默认的应用 webapp's ROOT        -->         <!-- 一般修改此文件就 root-directory的值  举例:E:\gitDown\xsbsite\web(该项目在你本地的      WEB-INF所在的目录) -->      <web-app id="/" root-directory="webapps/ROOT"/>        <web-app id="/resin-admin" root-directory="${resin.home}/php/admin">        <!--           - Administration application /resin-admin           - 管理应用程序 /resin-admin          -->        <prologue>          <resin:set var="resin_admin_external" value="false"/>          <resin:set var="resin_admin_insecure" value="true"/>        </prologue>      </web-app>    </host>  </cluster>  <!--     - Configuration for the web-tier/load-balancer    -->  <resin:if test="${resin.professional}">    <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>

二、resin关键配置详解

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(数据库应用较多时配置应偏小,网页应用较多时应偏大)。2 服务端口配置查找<http port='8080'/>,蓝色字符串即为端口号,根据实际应用修改。如果需要在一台服务器上启动多个resin服务,请按相应规划各应用端口号在每个resin安装目录的配置文件中配置该项,不可重复。3 更新类间隔时间<class-update-interval>60s</class-update-interval>,蓝色字符为配置项,单位为秒。Class-update-interval字段对RESIN服务性能影响较大,请根据需求更改,建议配置原则为:在开发环境,设为2或更小,这样有利于 及时反映程序的修改对应用造成的改变;生产环境建议配置最小60,根据生产环境的特点,不可能有频繁的类改动或是JAVA脚本改变,或者根本不会有改动, 所以依据实际情况,设置为60~36004 最大进程数<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)5 保持活动进程数<thread-keepalive id='19'/>,蓝色字符为配置项。Thread-keepalive字段为RESIN服务保持链接活动性的最大个数,它的值一定要小于3.4节中thread-max的值,否则RESIN无法启动。该项无建议值。6 请求超时时长<request-timeout id='65s'/>,蓝色字符为配置项,单位为秒。Request-timeout字段为RESIN服务返回请求链接超时的时间,默认即可。7 接收链接缓冲大小<accept-buffer-size id='500'/>,蓝色字符为配置项。Accept-buffer-size id字段为RESIN服务在满进程数下接收等待进程缓冲的个数,根据服务器、网络情况而定,无建议值。8 缓存文件过期时间<cache-mapping url-pattern='/' expires='2s'/>,蓝色字符为配置项。RESIN运行中把被访问文件数据进行缓存(默认缓存目录为RESIN安装目录下的cache目录,可在<cache dir='cache' size='1024' entries='8192'/>字段修改为指定路径),以便更加有效率的工作,Cache-mapping url-pattern字段为RESIN服务保持缓存文件有效性的时间,开发环境推荐配置为默认值2,生产环境建议配置较大值,比如1530。本配置基 于应用,增加缓存有效时间,在有较多相同页面服务时减少了服务器的业务逻辑,转而利用磁盘缓冲文件提供数据;但是如果在固定时间长度里(比如10分钟)相 同页面的请求率很小或甚至没有相同的请求时,会增加一次缓存文件匹配动作,反而降低了服务器效率。因此,在特殊的应用中,可以将本配置项设为2,或注 释<cache dir='cache' size='1024' entries='8192'/>,取消缓存功能。9 虚拟主机设置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。该配置项一般用来设置默认主页。9.2 主机ID<host id=''>.Host id字段在单主机环境、一台服务器需要启动多个不同的RESIN服务时不用配置,请保持默认的空值。只有当与其他web服务器,比如apache等,同时使用时,考虑改配置项。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文件夹里。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应用的代码或脚本。
原创粉丝点击