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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容

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