zoukankan      html  css  js  c++  java
  • Resin介绍及其使用配置

    1. Resin介绍及其使用配置

      Resin是一个提供高性能的,支持 Java/PHP 的应用服务器。目前有两个版本:一个是GPL下的开源版本,提供给一些爱好者、开发人员和低流量网站使用;一种是收费的专业版本,增加了一些更加适用于生产环境的特性。

      Resin的一些特性:

      可靠性:Resin包含了很多可靠的特性,包括服务器自动重启、检测并重启死锁的服务器、管理JVM内存以防止内存泄露等。

      集群:Resin可以将多个服务器作为一个服务器来对客户进行响应,从而增强服务器的扩展能力。

      持久和分布的sessions:持久的session能够在服务器重启的时候保持现有的Http会话,分布式的session可以在多个服务器之间共享Http会话的状态。

      增强的本地代码:同时为Windows和Linux系统提供了本地的代码增强支持。能够改善Socket链接、持久链接和文件读写方面的性能。

      OpenSSL:提供原生的OpenSSL库支持,比JSSE提供的方案要好很多。

      HTTP代理缓存:能够通过内存和磁盘缓存系统提高服务器的性能表现,将动态页面的速度提高到接近静态页面。

      Gzip过滤器:通过gzip来减少带宽。

       

      Resin服务器的安装(Windows - 独立版)

      1、安装JDK1.5或更高

      2、确保JDK的安装以及正确设置了环境变量JAVA_HOME

      3、解压Resin文件

      4、执行 java –jar resin-3.1.8/lib/resin.jar

      5、或者运行 http.exe

      6、在浏览器地址栏中输入 http://localhost:8080 即可进行访问

       

      我们也可以将Resin设置为系统服务。

       

      虚拟机的配置

      Resin的配置文件位于 ./conf/ 下,默认的配置文件为 resin.conf。

      配置简单的虚拟机,我们只要加入

        <host host-name="test.heep.com" root-directory="D:workspacesjava estsys"> 
          <access-log path="logs/test.access.log" 
                format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' 
                rollover-period="1W"/>

          <web-app id="/" root-directory="WebRoot/">

          </web-app> 
        </host> 
      </cluster>

      另外在host文件中加入对应的记录,这样,我们就可以访问 http://test.heep.com 了


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

    resin配置介绍二

    Resin是一个Servlet容器.使用Resin开发Java Web项目时,需要建立自己的WebApp。
    Resin中的应用可以有2种方式发布:
      是在Resin的目录下发布;
      是打包成War发布
    一、resin.conf配置文件说明[Resin3.1下的]

    1.<http host='localhost' port='80'/>
       host参数指定的是服务器,port指定的是http端口,默认是localhost和8080。
    2. <web-app>标签
       该标签表示一个web应用,标签中,id属性表示该应用的Web路径。
        如<web-app id='/test'>,表示该应用在Web上访问的时候应该用http://hostname/test/来访问。
        app-dir属性表示该应用的实际路径。如
        <app-dir>d:resindoctest</app-dir>表示该应用在d:resin doctest目录下面。默认值为根下面的和id同名的目录。
    3.Resin可以配置3种error-page:
        404错误也就是文件找不到错误页;
        Exception违例页;
        不能连接java引擎页。

        他们分别可以这样子设置:
     
        404文件找不到页
        <web-app id='/app1'>
         <error-page error-code='404' location='/file_not_found.jsp'/>
        </web-app>
     
        Exception 违例页
        <web-app id='/foo'>
         <error-page exception-type='java.lang.NullPointerException' location='/nullpointer.jsp'/>
        </web-app>
     
        不能连接到srun Servlet引擎错误页
     
        该页设置和应用无关,属于服务器的设置。
        <http-server>
         <error-page exception-type='connection' location='/missing_file.html'/>
        </http-server>
     
        参见下面的语句:
        <classpath id='WEB-INF/classes' source='WEB-INF/src' compile='true'/>
     
        id参数的值表示classpath中编译后的class的存放路径;
          source参数的值表示classpath中java源代码的存放路径;
          compile中的值可能是true或者false,表示是否由Resin的srun自动编译java源代码。
          Classpath的设置一般和javaBean或者Servlet的使用有关。
          id的值表示javaBean的编译好的包存放的根,
          source的值表示javaBean的java源代码存放的根。
          Servlet相同。
    6.  Servlet的设置
          <servlet-mapping url-pattern='*.xtp' servlet-name='xtp'/>
        <servlet-mapping url-pattern='*.jsp' servlet-name='jsp'/>
        <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
        一般就是指定那些需要通过srun的解析。比如在这里,把*.jsp改成*.jss,其他不变,那么只要在访问时遇到*.jss的文件就和原来遇到*.jsp一样处理。通过这个可以指定解析的引擎,
        如以下的配置:
        <servlet-mapping url-pattern='*.xtp' servlet-name='com.caucho.jsp.XtpServlet'/>
        在Servlet中,也可以指定servlet。如
        <servlet servlet-name='hello' servlet-class='test.HelloWorld'/>
        <servlet-mapping url-pattern='/hello.html' servlet-name='hello'/>
        在servlet-mapping中有个重要的参数case-sensitive 如果在windows上,最好配置成false,忽略大小写,从而和windows的约定一致。
    7.  Session的配置
          <session-config>
        <session-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 :最大 session数量
        session-timeout :session过期时间,以分钟为单位。
         是否允许cookie :指session是否采用cookies。如果采用cookies,浏览器必须支持session才能使用,发布时建议改成false。enable- url-rewriting和enable-cookies一般配合使用。如果enable-cookies是false,
        enable-url-rewriting应该设成true比较合适。
         file-store :该配置指示服务器是否把session作为文件存放在服务器上。如果把该项注释掉,则在你的web-app目录下的WEB-Inf/sessions目录不保存序列化后的session对象。Session还有jdbc-store配置,对应着把session通过jdbc永久保存在数据库中。其实也就是会话变量的序列化后的保存和重新载入的物理实现。

    resin3.1.6配置文件resin.conf如下:
    <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日志接口的配置. 日志信息的级别:'info' 生产环境 'fine' 开发环境 'finer' 调试环境 -->
    <log name="" level="fine" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
    <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>
    <memory-free-min>1M</memory-free-min><!-- 强制resin重起时的最小空闲内存 -->
    <thread-max>256</thread-max><!-- 最大线程数量. -->
    <socket-timeout>65s</socket-timeout><!-- 套接字等待时间 -->
    <keepalive-max>128</keepalive-max><!-- 配置 keepalive -->
    <keepalive-timeout>15s</keepalive-timeout>
    </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应用的默认参数 -->
    <<SPAN class=hilite1>web-app-default</SPAN>>
    <!-- 扩展库的公共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>
    </<SPAN class=hilite1>web-app-default</SPAN>>

    <!-- 简单的数据池配置[The JDBC name is java:comp/env/jdbc/mysql]-->
    <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="/justoneweb" root-directory="D:workjustonewebjavaweb"/>
    <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>
    <host id="woke.tool.com" >
        <web-app id="/" root-directory="E:resin-3.1.6deployWokeTool1.0" />
      </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>


    二、Resin 的 watchdog(看门狗)介绍
     
    为了稳定和安全,Resin使用一个独立的watchdog进程来启动和监视Resin服务器。
    watchdog连续你检测Resin服务器的状态,如果其没有反应或者迟钝,将会重启Resin服务器进程。
    大多数情况下,watchdog从resin.xml中读取配置信息,而不需要其它的附加配置。
    某些ISP服务商可能使用特别的配置,为了安全他们会配置watchdog来隔离JVM(Java虚拟主机)。

    概述
    因为watchdog作为一个服务运行,大多数情况下你根本不需要注意它。
    标准的配置下,一个机器上的watchdog可以监视这个机器上所有JVM,因此大部分情况下你不需要修改watchdog的配置。
    需要你管理watchdog的任务就是,如果机器发生了问题,停止watchdog,并检查 watchdog日志中Resin服务器的重启事件。
    watchdog自动重启崩溃和退出的Resin服务。因此如果你想停止Resin,你需要告诉watchdog来停止Resin实例,或者完全停止watchdog。
    使用resin.jar中的主程序(main)来控制watchdog,有用来启动、停止、重启Resin实例的命令,同样还有报告watchdog状态的命令。
    大多数用户不需要特别的配置watchdog,但是ISP和大的站点可能创建特殊的watchdog.xml(包含<watchdog- manager>标签)来控制watchdog。
    <watchdog-manager>允许ISP控制watchdog,为他们用户的 Resin实例指定附加的命令行参数,包括为他们的用户创建安全的chroot环境的能力。
    典型地,watchdog以root帐号运行,然而用户实例使用他们各自的用户id。

    命令行
      resin.jar中的主类ResinBoot的命令行用来控制watchdog。主要的操作包括:start、stop、restart、shutdown和status。

    start
    "start"命令使用给定的server id启动一个新的Resin实例。ResinBoot首先会尝试在当前机器上的watchdog,在需要时会启动一个新的watchdog。
     在resin.xml中定义的server id必须是惟一的。

    例如: watchdog启动
    resin-3.2.x> java -jar lib/resin.jar -conf conf/test.conf -server a start
    Resin/3.2.x started -server 'a' for watchdog at 127.0.0.1:6700

    stop
    "stop"命令使用给定的server id停止Resin实例。如果停止的实例是watchdog管理的最后一个Resin实例,watchdog也会自动退出。
    如果没有指定 -server 参数,watchdog使用默认的 -server "" 。

    例子: watchdog停止

    resin-3.2.x> java -jar lib/resin.jar stop
    Resin/3.2.x started -server '' for watchdog at 127.0.0.1:6600

    status
    "status"命令统计被watchdog服务管理的Resin实例的状态。
    例子: watchdog状态

    resin-3.2.x> java -jar lib/resin.jar status
    Resin/3.2.x status for watchdog at 127.0.0.1:6600

    server '' : active
      password: missing
      user: ferg
      root: /home/test/resin/
      conf: /etc/resin/resin.xml

    单一Resin实例
      这个例子显示了一个单一服务器站点,其监听标准的HTTP端口80,并以resin这个用户身份运行。在这个例子中watchdog是以root用户身份运行的,
    因此其能够绑定到特殊的端口80上,但是Resin实例是以resin身份运行的。


    因为使用了默认的配置,watchdog监听6600端口来获取命令。
    例子: /etc/resin/resin.xml

    <resin xmlns="http://caucho.com/ns/resin">
    <cluster id="">

      <server id="app-a" address="127.0.0.1">
        <user-name>resin</user-name>
        <group-name>resin</group-name>

        <http port="80" />
      </server>

      <resin:import path="${resin.home}/conf/app-default.xml" />

      <host id="">
        <web-app id="" path="/var/www/htdocs" />
      </host>

    </cluster>
    </resin>


    在一个机器上使用共享的watchdog实现负载平衡
      当在一个机器上运行多个Resin实例的时候,一个watchdog-manager就能管理所有的Resin实例。
    指定server id用来决定那个Resin实例是start或者stop。
    在这个例子中,有一个web-tier服务器做为负载平衡器,两个app-tier服务器处理后台数据,它们都在一个机器上。
    为了维护和升级方便,一个站点可能需要多个app-rier服务器。当一个停机的时候,第二个服务器可以继续服务。
    这个例子使用默认的watchdog配置,其读取的是标准的resin.xml文件。
    watchdog进程和ResinBoot都读取resin.xml 配置文件,因此不需要特别的watchdog配置。
    watchdog能够自动发现运行在这个机器上的多个Resin实例并管理它们。


    例子: /etc/resin/resin.xml

    <resin xmlns="http://caucho.com/ns/resin">

    <cluster id="app-tier">

      <server-default>
        <user-name>resin</user-name>
        <group-name>resin</group-name>
      </server-default>

      <server id="app-a" address="192.168.1.10" port="6810" />
      <server id="app-b" address="192.168.1.10" port="6811" />

      <host id="">
        <web-app id="" path="/var/www/htdocs" />
      </host>

    </cluster>

    <cluster id="web-tier">

      <server-default>
        <user-name>resin</user-name>
        <group-name>resin</group-name>
      </server-default>

      <server id="web-a" address="192.168.1.10" port="6800">
        <http port="80" />
      </server>

      <host id="">
        <web-app id="">
          <rewrite-redirect>
            <load-balance regexp="" cluster="app-tier" />
          </rewrite-redirect>
        </web-app>
      </host>

    </cluster>

    </resin>

    同一机器使用不同的watchdog来实现负载平衡
    在某些情况下,最好让每个Resin实例有其自己的watchdog,例如当多个用户在使用相同的机器。每个<server>块配置一个<watchdog-port>。
    因为watchdog将读取resin.xml使用<server>块匹配命令行参数中的 -server id,每个watchdog将启动期自己的端口。

    例子: /etc/resin/resin.xml

    <resin xmlns="http://caucho.com/ns/resin">

    <cluster id="app-tier">

      <server-default>
        <user-name>resin</user-name>
        <group-name>resin</group-name>
      </server-default>

      <server id="app-a" address="192.168.1.10" port="6810">
        <watchdog-port>6700</watchdog-port>

        <http port="8080" />
      </server>

      <server id="app-b" address="192.168.1.10" port="6811">
        <watchdog-port>6701</watchdog-port>

        <http port="8081" />
      </server>

      <host id="">
        <web-app id="" path="/var/www/htdocs" />
      </host>

    </cluster>

    </resin>

      在上面的例子中,启动Resin, 使用 -server app-a参数将启动一个在端口6700上的watchdog,使用 -server app-b参数将启动一个在端口6701上的watchdog。

    例子: starting app-b with watchdog-port=6701

    resin-3.2.x> java -jar lib/resin.jar -server app-b start

    ISP watchdog管理
      在ISP的环境中,你可能需要为watchdog使用一个隔离的配置文件,它为不同的用户启动Resin实例。在这个情况下,你要确保watchdog.xml不能被这些普通用户读取,要创建一个管理用户来读取这个文件。

    ●启动和重启用户的Resin JVM
    ●设置JVM参数和Java可执行性
    ●设置Resin实例的root-directory
    ●setuid user-name 和 group-name
    ●设置resin.xml配置
    ●打开受保护的端口,例如80
    ●可选的chroot设置

    watchdog将使用给定的帐号作为setuid来启动Resin实例。它也能打开任何需要的保护端口,例如80。
    例子: /etc/resin/watchdog.xml

    <resin xmlns="http://caucho.com/ns/resin">

    <management>
      <user name="harry" password="MD5HASH==" />
    </management>

    <watchdog-manager>

      <watchdog-default>
        <jvm-arg>-Xmx256m</jvm-arg>
      </watchdog-default>

      <watchdog id="user_1">
        <user-name>user_1</user-name>
        <group-name>group_1</group-name>

        <resin-xml>/home/user_1/conf/resin.xml</resin-conf>
        <resin-root>/home/user_1/www</resin-root>

        <open-port address="192.168.1.10" port="80" />
      </watchdog>

      ...

      <watchdog id="user_n">
        <user-name>user_n</user-name>
        <group-name>group_n</group-name>

        <resin-conf>/home/user_n/conf/resin.xml</resin-conf>
        <resin-root>/home/user_n/www</resin-root>

        <open-port address="192.168.1.240" port="80" />
      </watchdog>

    </watchdog-manager>

    </resin>


  • 相关阅读:
    python下编译py成pyc和pyo
    session_id小问题大影响
    python get,post提交表单
    vmstat命令列出的属性详解
    SGU 223 Little Kings
    POJ 3233 Matrix Power Series
    HDU 2604 Queuing
    HDU 2256 Problem of Precision
    SGU 224 Little Queens
    HDU 2276 Kiki & Little Kiki 2
  • 原文地址:https://www.cnblogs.com/yangkai-cn/p/4016581.html
Copyright © 2011-2022 走看看