Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26278048
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: Java

2010-05-20 23:46:07

同一台机启两个RESIN端口

此文档希望能够配置成功在同一台机上面跑两个WEB端口

然后对于一个应用跑两个端口然后前端配置nginx实现负载。

Resin 运行起来后,一般有这么几个端口

1. WatchDog 的端口,默认6600
2. Server
监控端口,默认6800
3.
应用的HTTP端口,默认8080

不管有多少个应用,Resin只会启动一个WatchDog 实例。

配置清单如下:



 

<cluster id="web1">
    <!-- sets the content root for the cluster, relative to resin.root -->
    <root-directory>.</root-directory>

    <!-- enables development error pages -->
    <development-mode-error-page/>

    <server-default>
      <!-- The http port -->
      <http address="*" port="8001"/>

      <!-- SSL port configuration: -->
      <http address="*" port="8443">
        <jsse-ssl self-signed-certificate-name="resin@localhost"/>
      </http>
      <jvm-arg>-Xmx256m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-Xdebug</jvm-arg>
      <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>
      <memory-free-min>1M</memory-free-min>

      <!-- Maximum number of threads. -->
      <thread-max>1024</thread-max>

      <!-- Configures the socket timeout -->
      <socket-timeout>65s</socket-timeout>

      <!-- Configures the keepalive -->
      <keepalive-timeout>120s</keepalive-timeout>
      <resin:if test="${resin.userName == 'root'}">
        <user-name>resin</user-name>
        <group-name>resin</group-name>
      </resin:if>
    </server-default>

    <!-- define the servers in the cluster -->
    <server id="server1" port="6801"/>
    <resin:if test="${resin.professional}">
      <persistent-store type="cluster">
        <init path="session"/>
      </persistent-store>
    </resin:if>
    <resin:if test="${resin.professional}">
      <cache path="cache" memory-size="64M">
        <!-- Vary header rewriting for IE -->
        <rewrite-vary-as-private/>
      </cache>
    </resin:if>
    <resin:if test="${resin.professional}">
      <ping>
        <!-- <url>http://localhost:8080/test-ping.jsp</url> -->
      </ping>
    </resin:if>

    <web-app-default>
      <prologue>
        <!--
           - Enable EL expressions in Servlet and Filter init-param
          -->
        <allow-servlet-el/>
      </prologue>

      <cache-mapping url-pattern="/" expires="0s"/>
      <cache-mapping url-pattern="*.gif" expires="60s"/>
      <cache-mapping url-pattern="*.jpg" expires="10s"/>
      <cache-mapping url-pattern="*.png" expires="60s"/>

      <session-config>
        <enable-url-rewriting>false</enable-url-rewriting>
      </session-config>
      <jsp>
        <validate-taglib-schema>true</validate-taglib-schema>
        <fast-jstl>true</fast-jstl>
      </jsp>
      <jsf fast-jsf='false'/>
    </web-app-default>

    <resin:import path="${__DIR__}/app-default.xml"/>
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>
    <host id="">
        <root-directory>D:\myweb\proj1</root-directory>

        <web-app id="/test" document-directory="app1/">
            <welcome-file-list>login.jsp</welcome-file-list>
            <character-encoding>UTF-8</character-encoding>
            <stderr-log path='D:\myweb\proj1\app1\stderr.log' rollover-size="2mb" />
            <stdout-log path='D:\myweb\proj1\app1\stdout.log' rollover-size='2mb' />
        </web-app>
        <web-app id="/test2" document-directory="app2/">
            <welcome-file-list>login.jsp</welcome-file-list>
            <character-encoding>UTF-8</character-encoding>
            <stderr-log path='D:\myweb\proj1\app2\stderr.log' rollover-size="2mb" />
            <stdout-log path='D:\myweb\proj1\app2\stdout.log' rollover-size='2mb' />
        </web-app>
    </host>
    <host id="">
        <root-directory>D:\myweb\proj2</root-directory>
        <web-app id="/test" document-directory=".">
            <welcome-file-list>login.jsp</welcome-file-list>
            <character-encoding>UTF-8</character-encoding>
            <stderr-log path='D:\myweb\proj2\stderr.log' rollover-size="2mb" />
            <stdout-log path='D:\myweb\proj2\stdout.log' rollover-size='2mb' />
        </web-app>    
    </host>
  </cluster>

  <cluster id="web2">

    <root-directory>.</root-directory>
    <development-mode-error-page/>
    <server-default>
      <!-- The http port -->
      <http address="*" port="8002"/>
      <!-- SSL port configuration: -->
      <http address="*" port="8443">
        <jsse-ssl self-signed-certificate-name="resin@localhost"/>
      </http>

      <jvm-arg>-Xmx256m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-Xdebug</jvm-arg>
      <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>

      <memory-free-min>1M</memory-free-min>

      <!-- Maximum number of threads. -->
      <thread-max>1024</thread-max>

      <!-- Configures the socket timeout -->
      <socket-timeout>65s</socket-timeout>

      <!-- Configures the keepalive -->
      <keepalive-timeout>120s</keepalive-timeout>

      <resin:if test="${resin.userName == 'root'}">
        <user-name>resin</user-name>
        <group-name>resin</group-name>
      </resin:if>
    </server-default>

    <!-- define the servers in the cluster -->
    <server id="server2" port="6802"/>
    <resin:if test="${resin.professional}">
      <persistent-store type="cluster">
        <init path="session"/>
      </persistent-store>
    </resin:if>

   
    <web-app-default>
      <prologue>

        <allow-servlet-el/>
      </prologue>
      <jsp>
        <validate-taglib-schema>true</validate-taglib-schema>
        <fast-jstl>true</fast-jstl>
      </jsp>
      <jsf fast-jsf='false'/>
    </web-app-default>
    <!-- includes the app-default for default web-app behavior -->
    <resin:import path="${__DIR__}/app-default.xml"/>
    <!-- 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>D:\myweb\proj3</root-directory>
        <web-app id="/test" document-directory="app3/">
            <welcome-file-list>login.jsp</welcome-file-list>
            <character-encoding>UTF-8</character-encoding>
            <stderr-log path='D:\myweb\proj3\app3\stderr.log' rollover-size="2mb" />
            <stdout-log path='D:\myweb\proj3\app3\stdout.log' rollover-size='2mb' />
        </web-app>
    </host>
    <host id="">
        <root-directory>D:\myweb\proj4</root-directory>
        <web-app id="/test" document-directory=".">
            <welcome-file-list>login.jsp</welcome-file-list>
            <character-encoding>UTF-8</character-encoding>
            <stderr-log path='D:\myweb\proj4\stderr.log' rollover-size="2mb" />
            <stdout-log path='D:\myweb\proj4\stdout.log' rollover-size='2mb' />
        </web-app>
    </host>
  </cluster>
</resin>

笔记:配置两个cluster 启动两个端口8001 8002 跑了两个实例。现在我们就可以这样访问了http://:8001/test http://:8002/test

两个端口不同的域名 绑定不同的应用!

下一篇来实现nginx负载

启动方式

F:\webapp\resin-3.2.1>resin.exe start -server server2



阅读(941) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~