resin4.0配置运行总结

安装

Install JDK 6 or later and link /usr/java to the Java home or define the environment variable JAVA_HOME.
tar -vzxf resin-4.0.x.tar.gz
cd resin-4.0.x #修改文件名貌似会出问题
./configure --prefix=`pwd`
some details on the ./configure options.
make
sudo make install
Execute sudo resinctl start
or run java -jar lib/resin.jar start
Browse to http://localhost:8080

启动

resinctl

  1. Start resin with resinctl start
  2. Stop resin with resinctl stop
  3. Restart resin with resinctl restar

resin.sh

bin/resin.sh start|restart|stop -server <server-id>

配置

概念和命名约定

  • cluster - a collection of identically-configured servers.
  • environment - isolated class-loader contexts with shared resources: server, host and web-app are the main environments.
  • host - a HTTP virtual host.
  • proxy cache - HTTP proxy cache.
  • resource - drivers or services available to the application though JNDI or CDI like databases, JMS queues, custom CDI-configured service. Resin-specific resources include security, authenticators, health-checks and the rewrite/dispatch system.
  • rewrite/dispatch - the configuration for dispatching HTTP URLs to servlets and response codes like Apache's mod_rewrite.
  • server - a Resin JVM instance. There may be multiple servers on a machine.
  • watchdog - a JVM instance which watches over the Resin server and restarts the server if necessary.
  • web-app - a HTTP web-application which runs servlets.

resin.xml

删除社区版不支持的功能

health

<!--
    - health configuration
-->
<resin:import path="${__DIR__}/health.xml"/>

loadbalance

<web-app id="">
    <resin:LoadBalance regexp="" cluster="app"/>
</web-app>

删除不需要的cluster

<cluster id="proxycache">
    ...
</cluster>
<cluster id="memcached" xmlns:memcache="urn:java:com.caucho.memcached">
    ...
</cluster>
<cluster id="web">
    ...
</cluster>

只保留<cluster id="app">即可

server

端口

resin server涉及的端口

  • WatchDog 的端口,默认6600
  • Server 监控端口,默认6800
  • 应用的HTTP端口,默认8080

单个server

<server id="k12yuwen" address="127.0.0.1" port="6801" > 
    <watchdog-port>6601</watchdog-port> 
    <http address="*" port="31001"/> 
</server>

多个server

<server-multi id-prefix="app-" address-list="127.0.0.1" port="6801">  
    <watchdog-port>6601</watchdog-port>  
    <http address="*" port="8081"/>  
</server-multi>

jvm参数

<cluster id="app">
    <server-default>
        <jvm-arg>-Xms32m</jvm-arg>
        <jvm-arg>-Xmx512m</jvm-arg>
        <jvm-arg>-Xss1m</jvm-arg>
        <jvm-arg>-verbosegc</jvm-arg>
        <jvm-arg>-Dfoo=bar</jvm-arg>
        <jvm-arg>-Dcaucho.smallmem</jvm-arg>
        <jvm-arg>-agentlib:resin</jvm-arg>
        <jvm-arg>-Xdebug</jvm-arg>
            
        <http port="8080"/>
    </server-default>
    <server id="a" address="192.168.2.1" port="6800"/>
    ...
</cluster>

参考

http://www.caucho.com/resin-4.0/admin/starting-resin-command-line.xtp

删除doc

<resin:if test="${resin_doc}">
    <host id="${resin_doc_host}" root-directory="${resin_doc_host}">
        <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
    </host>
</resin:if>

添加自定义应用

<web-app id="/" root-directory="/data/www/cms">  
</web-app> 

应用参数

防止避免hash collision dos攻击、日志

<web-app id="/k12yuwen" root-directory="webapps/k12yuwen-base">
    <form-parameter-max>100</form-parameter-max>
    <stderr-log path="${resin.root}/logs/k12yuwen/stderr.log" timestamp="[%Y-%m-%d %H:%M:%S]" rollover-period="1D"/>  
    <stdout-log path="${resin.root}/logs/k12yuwen/stdout.log" timestamp="[%Y-%m-%d %H:%M:%S]" rollover-period="1D"/>  
</web-app>

host 配置举例

同一个域名下多个子app

<cluster id="app">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="app-" address-list="${app_servers}" port="6801"/>

    <host-default>
      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps"
                      expand-preserve-fileset="WEB-INF/work/**"
                      multiversion-routing="${webapp_multiversion_routing}"
                      path-suffix="${elastic_webapp?resin.id:''}"/>
    </host-default>

    <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>

    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="webapps/ROOT"/>
      <web-app id="/demo" root-directory="webapps/demo"/>
    </host>

 </cluster>


多个域名,虚拟主机(virtual host)

<cluster id="app">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="app-" address-list="${app_servers}" port="6801"/>
    <host-default>
      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps"
                      expand-preserve-fileset="WEB-INF/work/**"
                      multiversion-routing="${webapp_multiversion_routing}"
                      path-suffix="${elastic_webapp?resin.id:''}"/>
    </host-default>

    <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>

    <!--每个host id下也可以包含多个web-app,参考第一种的配置方法-->
    <host id="www.test1.com" root-directory=".">
      <web-app id="/" root-directory="webapps/test1/ROOT"/>
    </host>

    <host id="www.test2.com" root-directory=".">
      <web-app id="/" root-directory="webapps/test2/ROOT"/>
    </host>

 </cluster>

resin.xml举例

<!--
   - Resin 4.0 configuration file.
  -->
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin">

  <!-- property-based Resin configuration -->
  <resin:properties path="${__DIR__}/resin.properties" optional="true"/>

  <resin:if test="${properties_import_url}">
     <resin:properties path="${properties_import_url}"
                    optional="true" recover="true"/>
  </resin:if>


  <!-- Logging configuration for the JDK logging API -->
  <log-handler name="" level="all" path="stdout:"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>
               
  <!-- 
     - Alternative pseudo-TTCC log format
     -
     - <log-handler name="" level="all" path="stdout:"
     -           timestamp="%y-%m-%d %H:%M:%S.%s"
     -           format=" [${thread}] ${log.level} ${log.shortName} - ${log.message}"/>
    -->
   
  <!--
     - level='info' for production
     - 'fine' or 'finer' for development and troubleshooting
    -->
  <logger name="" level="${log_level?:'info'}"/>

  <logger name="com.caucho.java" level="config"/>
  <logger name="com.caucho.loader" level="config"/>

  <!--
     - Default configuration applied to all clusters, including
     - HTTP, HTTPS, and /resin-admin configuration.
    -->
  <resin:import path="${__DIR__}/cluster-default.xml"/>
  
  <!--
     - Remote management requires at least one enabled admin user.
    -->
  <resin:AdminAuthenticator>
    <user name="${admin_user}" password="${admin_password}"/>
    
    <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
  </resin:AdminAuthenticator>

  <!--
     - For clustered systems, create a password in as cluster_system_key
    -->
  <cluster-system-key>${cluster_system_key}</cluster-system-key>

  <!--
     - For production sites, change dependency-check-interval to something
     - like 600s, so it only checks for updates every 10 minutes.
    -->
  <dependency-check-interval>${dependency_check_interval?:'2s'}</dependency-check-interval>

  <!-- For resin.properties dynamic cluster joining -->
  <home-cluster>${home_cluster}</home-cluster>
  <home-server>${home_server}</home-server>
  <elastic-server>${elastic_server}</elastic-server>
  <elastic-dns>${elastic_dns}</elastic-dns>

  <!--
     - Configures the main application cluster.  Load-balancing configurations
     - will also have a web cluster.
    -->
  <cluster id="app">
    <!-- define the servers in the cluster -->
    <!-- <server-multi id-prefix="app-" address-list="${app_servers}" port="6800"/> -->
    <server id="k12yuwen" address="127.0.0.1" port="6801" > 
        <watchdog-port>6601</watchdog-port> 
        <http address="*" port="31001"/> 
    </server>

    <host-default>
      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps"
                      expand-preserve-fileset="WEB-INF/work/**"
                      multiversion-routing="${webapp_multiversion_routing}"
                      path-suffix="${elastic_webapp?resin.id:''}"/>
    </host-default>

    <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>

    <host id="" root-directory=".">  
      <web-app id="/k12yuwen" root-directory="webapps/k12yuwen-base">
        <form-parameter-max>100</form-parameter-max>
        <stderr-log path="${resin.root}/logs/k12yuwen/stderr.log" timestamp="[%Y-%m-%d %H:%M:%S]" rollover-period="1D"/>  
        <stdout-log path="${resin.root}/logs/k12yuwen/stdout.log" timestamp="[%Y-%m-%d %H:%M:%S]" rollover-period="1D"/>  
      </web-app>
      <web-app id="/k12yuwen-ocr" root-directory="webapps/k12yuwen-ocr">
        <form-parameter-max>100</form-parameter-max>
        <stderr-log path="${resin.root}/logs/k12yuwen-ocr/stderr.log" timestamp="[%Y-%m-%d %H:%M:%S]" rollover-period="1D"/>  
        <stdout-log path="${resin.root}/logs/k12yuwen-ocr/stdout.log" timestamp="[%Y-%m-%d %H:%M:%S]" rollover-period="1D"/>  
      </web-app>
    </host>
  </cluster>


</resin>

resin.properties

web_admin_enable : false  
session_store : false  
resin_doc : false  
dev_mode:false
# 集群端口
app.http: 8080
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,390评论 19 139
  • 乌鸦有一头不算黑的短发 穿着粉红色的袈裟 她喜欢说话 张嘴吐出一口花 她教我们画过几幅画 拿笔的时候像个哑巴 乌鸦...
    晓晓博士阅读 3,342评论 0 0
  • 三月份一过,各大地方教育局和学校就着手准备招聘教师行动了,有甚者去年底就有先下手早的,抢购优秀的老师,往往都是一些...
    Ruru凤阅读 4,189评论 0 11
  • 看了电影《从你的全世界路过》,忽然想去重庆逛逛,那就走吧 热辣辣的 名不虚传 聚众围观 在一个连GPS都要认输的城...
    陆小九儿阅读 1,852评论 0 0