一機運行多個resin的配置


 對於java應用服務器,常用的一般為tomcat、jboss、resin。

 

一. 概述

 經常會有這種情況:

1、一台服務器上,跑多個java應用

2、網站負載高,需要采用負載均衡(輪詢)的方式來解決

一般用多個java應用服務器軟件,或者用一個采用集群的方式; 

 

二. 跑多個項目,或者做balance的方法

 方法一:再安裝一個resin,指向不同的項目目錄  

在安裝完畢之后:

修改resin.conf里面的http port、cluster port和web-app目錄;啟動,就ok了。

 

方法二:只安裝一個resin,使用不同的配置文件,指向不同的項目目錄。方法二的配置相對復雜些。

1.安裝好一個resin之后,cp resin.conf resin1.conf,分別修改另個resin,找到找到配置文件中的<!-- define the servers in the cluster -->,修改負載均衡配置,需要設置服務的ID、IP和port。 resin.conf修改為:

<server id="yk" address="127.0.0.1" port="6800"/>  

resin1.conf 修改為:

<server id="yk1" address="127.0.0.1" port="6801"/>  

resin2.con修改為:

<server id="yk2" address="127.0.0.1" port="6802"/> 注:其中修改http port,web-app 目錄,jvm參數、最大線程數的修改,根據需要去調整。

2.拿部署的配置跟我的配置對比下:

[yangkai@mp2 conf]$ diff resin.conf webresin

 84c84  

< <cluster id="app-tier">  ---  

> <cluster id="app-1">  

107c107  

< <jvm-arg>-Xmx256m</jvm-arg>  ---  

> <jvm-arg>-Xmx3096m</jvm-arg>  

130c130  

< <thread-max>256</thread-max>  ---  

> <thread-max>20480</thread-max>  

149c149

 < <server id="yk" address="127.0.0.1" port="6800"/>  ---  

> <server id="a" address="127.0.0.1" port="6801"/>  

269a270  >

<stdout-log path="${resin.home}/log/stdout-cms.log" timestamp="[%Y-%m-%d %H:%M:%S.%s]" rollover-period="1D"/>  

300c301  

< <web-app id="/" root-directory="/home/yangkai/dir"/>  ---  

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

 [yangkai@mp2 conf]$ 其中84行的沒必要修改。其中配置文件中,主要修改的,也就這些參數。

3.啟動過程

[yangkai@mp2 conf]$ ../bin/httpd.sh -conf ./webresin.conf -server a stop  Resin/3.1.10 can't stop -server 'a' for watchdog at 127.0.0.1:6600.  java.lang.IllegalStateException: Can't connect to ResinWatchdogManager.  java.net.ConnectException: http://127.0.0.1:6600/watchdog: Connection refused  

[yangkai@mp2 conf]$ vim startallre.sh  "startallre.sh" [New File]~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 0,0-1 All-- INSERT --0,1 All

#!/bin/bash2,1 All  

/opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-cms.conf -server a start  

/opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-zixun.conf -server b start  

/opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-shenghuo.conf -server c  start

/opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-kefu.conf -server d start

6,78 All:6,79 All6,78 All6,77 All:%  :%s  :%s/  :%s//  :%s///  :%s///g  :%s/o//g  :%s/op//g  :%s/opt//g  :%s/opt/h/g  :%s/opt/ho/g  :%s/opt/hom/g  :%s/opt/home/g  :%s/opt/home  8 substitutions on 4 lineshome/resin/bin/httpd.sh -conf /home/resin/conf/resin-cms.conf -server a start  

/home/resin/bin/httpd.sh -conf /home/resin/conf/resin-zixun.conf -server b start  

/home/resin/bin/httpd.sh -conf /home/resin/conf/resin-shenghuo.conf -server c start  

/home/resin/bin/httpd.sh -conf /home/resin/conf/resin-kefu.conf -server d start

6,1 All  8 substitutions on 4 lines6,1 All6,1 All4 changes; before #2 3 seconds ago

opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-cms.conf -server a start

opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-zixun.conf -server b start

opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-shenghuo.conf -server c start

opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-kefu.conf -server d start

3,1 All:%  :%s  :%s/  :%s//  :%s///  :%s///g  :%s/o//g  :%s/op//g  :%s/opt//g  :%s/opt/&/g  :%s/opt/&\/g  :%s/opt/&\//g  :%s/opt/&\/h/g  :%s/opt/&\/ho/g  :%s/opt/&\/hom/g  :%s/opt/&\/home/g  :%s/opt/&\/home  8 substitutions on 4 lineshome/resin/bin/httpd.sh -conf /opt/home/resin/conf/resin-cms.conf -server a starthome/resin/bin/httpd.sh -conf /opt/home/resin/conf/resin-zixun.conf -server b starthome/resin/bin/httpd.sh -conf /opt/home/resin/conf/resin-shenghuo.conf -server c starthome/resin/bin/httpd.sh -conf /opt/home/resin/conf/resin-kefu.conf -server d start6,1 All  8 substitutions on 4 lines6,1 All6,1 All4 changes; before #3 8 seconds agoresin/bin/httpd.sh -conf /opt/resin/conf/resin-cms.conf -server a startresin/bin/httpd.sh -conf /opt/resin/conf/resin-zixun.conf -server b startresin/bin/httpd.sh -conf /opt/resin/conf/resin-shenghuo.conf -server c startresin/bin/httpd.sh -conf /opt/resin/conf/resin-kefu.conf -server d start3,1 All:%  :%s  :%s/  :%s//  :%s///  :%s///g  :%s/o//g  :%s/op//g  :%s/opt//g  :%s/opt/h/g  :%s/opt/ho/g  :%s/opt/hom/g  :%s/opt/home/g  :%s/opt/home\/g  :%s/opt/home\//g  :%s/opt/home\/y/g  :%s/opt/home\/ya/g  :%s/opt/home\/yan/g  :%s/opt/home\/yang/g  :%s/opt/home\/yangk/g  :%s/opt/home\/yangka/g  :%s/opt/home\/yangkai/g  :%s/opt/home\/yangkai  8 substitutions on 4 lineshome/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin-cms.conf -server a start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin-zixun.conf -server b start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin-shenghuo.conf -server c start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin-kefu.conf -server d start6,1 All  8 substitutions on 4 lines6,1 All6,1 All~ 5,1 All4,1 All4,2 All4,3 All4,4 All4,5 All4,6 All4,7 All4,8 All4,9 All4,10 All4,11 All4,12 All4,13 All4,14 All4,15 All4,16 All4,17 All4,18 All4,19 All4,20 All4,21 All4,22 All4,23 All4,24 All4,25 All4,26 All4,27 All4,28 All4,29 All4,30 All4,31 All4,32 All4,33 All4,34 All4,35 All4,36 All4,37 All4,38 All4,39 All4,40 All4,41 All4,42 All4,43 All4,44 All4,45 All4,46 All4,47 All4,48 All3,48 All3,49 All3,50 All3,51 All3,52 All3,53 All3,54 All3,55 All3,56 All3,57 All3,58 All3,59 All3,60 All3,61 All3,62 All3,63 All3,64 All3,65 All3,66 All3,67 All3,68 All3,69 All3,70 Allcms.conf -server a startms.conf -server a starts.conf -server a start.conf -server a start4,70 Allzixun.conf -server b startixun.conf -server b startxun.conf -server b startun.conf -server b startn.conf -server b start.conf -server b start-- INSERT --4,70 All1.conf -server b start4,71 All5,71 All5,70 Allx-shenghuo.conf -server c start5,71 Allx-shenghuo.conf -server c start5,72 All5,73 All5,74 All5,75 All5,76 All5,77 All5,78 All5,79 All5,80 All5,81 Al.conf -server c start5,80 Al.conf -server c start5,79 Al.conf -server c start5,78 Al.conf -server c start5,77 Al.conf -server c start5,76 Al.conf -server c start5,75 Al.conf -server c start5,74 Al.conf -server c start5,73 Al.conf -server c start5,72 Al.conf -server c start5,71 Al.conf -server c start5,70 All2.conf -server c start5,71 All4,71 All3,71 All3,72 All3,73 All3,74 All3,75 All3,76 All3,77 All3,78 All3,79 All3,80 All3,81 All3,82 All3,83 All3,84 All3,85 Al start3,84 Ally start3,85 Alll start3,86 Al start3,85 Allk start3,86 All4,86 Al start4,85 Ally start4,86 Allk start4,87 All1 start4,88 All5,88 All5,87 All5,86 Al start5,85 Ally start5,86 Allk start5,87 All2 start5,88 All5,87 All:w  :wq  :wq  "startallre.sh"  "startallre.sh" [New] 5L, 293C written  [yangkai@mp2 conf]$ cp startallre.sh stopallre.sh  [yangkai@mp2 conf]$ vim stopallre.sh  "stopallre.sh"  "stopallre.sh" 5L, 293C#!/bin/bash

 /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin.conf -server yk start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin1.conf -server yk1 start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin2.conf -server yk2 start  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 1,1 All:%  :%s  :%s/  :%s//  :%s///  :%s///g  :%s/s//g  :%s/st//g  :%s/str//g  :%s/str  :%s/st//g:%s/sta//g  :%s/star//g  :%s/start//g  :%s/start/s/g  :%s/start/st/g  :%s/start/sto/g  :%s/start/stop/g  :%s/start/stop  3 substitutions on 3 linesopopop5,1 All  3 substitutions on 3 lines5,1 All5,1 All:w  :wq  :wq  "stopallre.sh"  "stopallre.sh" 5L, 290C written  [yangkai@mp2 conf]$ chmod +x *sh  [yangkai@mp2 conf]$ ./stopallre.sh  Resin/3.1.10 can't stop -server 'yk' for watchdog at 127.0.0.1:6600.  java.lang.IllegalStateException: Can't connect to ResinWatchdogManager.  java.net.ConnectException: http://127.0.0.1:6600/watchdog: Connection refused  Resin/3.1.10 can't stop -server 'yk1' for watchdog at 127.0.0.1:6600.  java.lang.IllegalStateException: Can't connect to ResinWatchdogManager.  java.net.ConnectException: http://127.0.0.1:6600/watchdog: Connection refused  Resin/3.1.10 can't stop -server 'yk2' for watchdog at 127.0.0.1:6600.  java.lang.IllegalStateException: Can't connect to ResinWatchdogManager.  java.net.ConnectException: http://127.0.0.1:6600/watchdog: Connection refused  [yangkai@mp2 conf]$ ./startallre.sh  Resin/3.1.10 started -server 'yk' for watchdog at 127.0.0.1:6600  Resin/3.1.10 started -server 'yk1' for watchdog at 127.0.0.1:6600  Resin/3.1.10 started -server 'yk2' for watchdog at 127.0.0.1:6600  [yangkai@mp2 conf]$ netstat -tnl  Active Internet connections (only servers)  Proto Recv-Q Send-Q Local Address Foreign Address State  tcp 0 0 0.0.0.0:29472 0.0.0.0:* LISTEN  tcp 0 0 0.0.0.0:14538 0.0.0.0:* LISTEN  tcp 0 0 192.168.61.68:1521 0.0.0.0:* LISTEN  tcp 0 0 0.0.0.0:37494 0.0.0.0:* LISTEN  tcp 0 0 0.0.0.0:49400 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6013 0.0.0.0:* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6600 :::* LISTEN  tcp 0 0 :::29518 :::* LISTEN  tcp 0 0 :::8080 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6800 :::* LISTEN  tcp 0 0 :::8081 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6801 :::* LISTEN  tcp 0 0 :::8082 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6802 :::* LISTEN  tcp 0 0 :::26645 :::* LISTEN  tcp 0 0 :::22 :::* LISTEN  tcp 0 0 ::1:6012 :::* LISTEN  tcp 0 0 ::1:6013 :::* LISTEN  tcp 0 0 :::23070 :::* LISTEN  tcp 0 0 :::9758 :::* LISTEN  [yangkai@mp2 conf]$ ./stopallre.sh  Resin/3.1.10 stopped -server 'yk' for watchdog at 127.0.0.1:6600  Resin/3.1.10 stopped -server 'yk1' for watchdog at 127.0.0.1:6600  Resin/3.1.10 stopped -server 'yk2' for watchdog at 127.0.0.1:6600  [yangkai@mp2 conf]$ netstat -tnl  Active Internet connections (only servers)  Proto Recv-Q Send-Q Local Address Foreign Address State  tcp 0 0 0.0.0.0:14538 0.0.0.0:* LISTEN  tcp 0 0 192.168.61.68:1521 0.0.0.0:* LISTEN  tcp 0 0 0.0.0.0:20370 0.0.0.0:* LISTEN  tcp 0 0 0.0.0.0:6999 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6013 0.0.0.0:* LISTEN  tcp 0 0 0.0.0.0:43583 0.0.0.0:* LISTEN  tcp 0 0 :::22 :::* LISTEN  tcp 0 0 ::1:6012 :::* LISTEN  tcp 0 0 ::1:6013 :::* LISTEN  [yangkai@mp2 conf]$ cat startallre.sh  #!/bin/bash

 /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin.conf -server yk start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin1.conf -server yk1 start  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin2.conf -server yk2 start  [yangkai@mp2 conf]$ cat stopallre.sh  #!/bin/bash

 /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin.conf -server yk stop  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin1.conf -server yk1 stop  /home/yangkai/resin/bin/httpd.sh -conf /home/yangkai/resin/conf/resin2.conf -server yk2 stop  [yangkai@mp2 conf]$ echo "i will go to sleep,bye.  i will go to sleep,bye.  [yangkai@mp2 conf]$

 ### END LOG - DATE: 120429, TIME: 004713 ###

 

 

[yangkai@mp2 dir1]$ cd WEB-INF/  [yangkai@mp2 WEB-INF]$ ls  classes tmp work  [yangkai@mp2 WEB-INF]$ file work/_jsp/_index__jsp.  _index__jsp.class _index__jsp.java _index__jsp.java.smap  [yangkai@mp2 WEB-INF]$ file work/_jsp/_index__jsp.java  work/_jsp/_index__jsp.java: ASCII C program text  [yangkai@mp2 WEB-INF]$ file work/_jsp/_index__jsp.jav work/_jsp/_index__jsp.java work/_jsp/_index__jsp.java work/_jsp/_index__jsp.java  l work/_jsp/_index__jsp.java  l work/_jsp/_index__jsp.java-rwxr-xr-x 1 root root 5611 Apr 28 19:35 work/_jsp/_index__jsp.java  [yangkai@mp2 WEB-INF]$ ;s  -bash: syntax error near unexpected token `;'  [yangkai@mp2 WEB-INF]$ cd ..  [yangkai@mp2 dir1]$ sudo chmod -R 777 /home/yangkai/*

 [sudo] password for yangkai:  [yangkai@mp2 dir1]$ echo "ok  ok  [yangkai@mp2 dir1]$

 4.64上查看:

61.64  [root@mp2 conf]# netstat -tnl  Active Internet connections (only servers)  Proto Recv-Q Send-Q Local Address Foreign Address State  tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN  tcp 0 0 :::8096 :::* LISTEN  tcp 0 0 :::2499 :::* LISTEN  tcp 0 0 :::50790 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6600 :::* LISTEN  tcp 0 0 :::5001 :::* LISTEN  tcp 0 0 :::42985 :::* LISTEN  tcp 0 0 :::8080 :::* LISTEN  tcp 0 0 :::80 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6801 :::* LISTEN  tcp 0 0 :::8081 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6802 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6803 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6804 :::* LISTEN  tcp 0 0 :::12470 :::* LISTEN  tcp 0 0 :::22 :::* LISTEN  tcp 0 0 ::1:6011 :::* LISTEN  tcp 0 0 :::6972 :::* LISTEN  tcp 0 0 :::8095 :::* LISTEN  [root@mp2 conf]# ../bin/httpd.sh -conf ./resin-kefu.conf -server d stop  Resin/3.1.10 stopped -server 'd' for watchdog at 127.0.0.1:6600  [root@mp2 conf]# ../bin/httpd.sh -conf ./resin-kefu.conf -server d start  Resin/3.1.10 can't start -server 'd' for watchdog at 127.0.0.1:6600.  com.caucho.config.ConfigException: Resin/3.1.10 can't find configuration file '/opt/resin/resin-kefu.conf'  [root@mp2 conf]# netstat -tnl  Active Internet connections (only servers)  Proto Recv-Q Send-Q Local Address Foreign Address State  tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN  tcp 0 0 :::2499 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6600 :::* LISTEN  tcp 0 0 :::5001 :::* LISTEN  tcp 0 0 :::42985 :::* LISTEN  tcp 0 0 :::8080 :::* LISTEN  tcp 0 0 :::80 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6801 :::* LISTEN  tcp 0 0 :::8081 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6802 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6803 :::* LISTEN  tcp 0 0 :::12470 :::* LISTEN  tcp 0 0 :::22 :::* LISTEN  tcp 0 0 ::1:6010 :::* LISTEN  tcp 0 0 ::1:6011 :::* LISTEN  tcp 0 0 :::6972 :::* LISTEN  tcp 0 0 :::8095 :::* LISTEN  [root@mp2 conf]#  [root@mp2 conf]# cat /opt/resin/startall.sh  #!/bin/bash

 /opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-cms.conf -server a start  /opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-zixun.conf -server b start  /opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-shenghuo.conf -server c start  /opt/resin/bin/httpd.sh -conf /opt/resin/conf/resin-kefu.conf -server d start

 [root@mp2 conf]# . /opt/resin/stopall.sh  Resin/3.1.10 stopped -server 'a' for watchdog at 127.0.0.1:6600  Resin/3.1.10 stopped -server 'b' for watchdog at 127.0.0.1:6600  Resin/3.1.10 stopped -server 'c' for watchdog at 127.0.0.1:6600  Resin/3.1.10 can't stop -server 'd' for watchdog at 127.0.0.1:6600.  java.lang.IllegalStateException: Can't connect to ResinWatchdogManager.  java.net.ConnectException: http://127.0.0.1:6600/watchdog: Connection refused  [root@mp2 conf]# . /opt/resin/startall.sh  Resin/3.1.10 started -server 'a' for watchdog at 127.0.0.1:6600  Resin/3.1.10 started -server 'b' for watchdog at 127.0.0.1:6600  Resin/3.1.10 started -server 'c' for watchdog at 127.0.0.1:6600  Resin/3.1.10 started -server 'd' for watchdog at 127.0.0.1:6600  [root@mp2 conf]#netstat -tnl  Active Internet connections (only servers)  Proto Recv-Q Send-Q Local Address Foreign Address State  tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN  tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN  tcp 0 0 :::8096 :::* LISTEN  tcp 0 0 :::2499 :::* LISTEN  tcp 0 0 :::50790 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6600 :::* LISTEN  tcp 0 0 :::5001 :::* LISTEN  tcp 0 0 :::42985 :::* LISTEN  tcp 0 0 :::8080 :::* LISTEN  tcp 0 0 :::80 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6801 :::* LISTEN  tcp 0 0 :::8081 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6802 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6803 :::* LISTEN  tcp 0 0 ::ffff:127.0.0.1:6804 :::* LISTEN  tcp 0 0 :::12470 :::* LISTEN  tcp 0 0 :::22 :::* LISTEN  tcp 0 0 ::1:6011 :::* LISTEN  tcp 0 0 :::6972 :::* LISTEN  tcp 0 0 :::8095 :::* LISTEN

[root@mp2 conf]#

 

三、小結

1.使用resin版本很重要,上面是使用resin3.1.8測試的結果,使用reisn3.0.*就不行,前者的http.sh是40行,后者是84行;前者的resin.conf是正常的,后者里面找不到:

<cluster id="app-tier">  <!-- 設置集群上下文的根, 相對於server.root -->  <root-directory>.</root-directory> 也沒有:

<!-- define the servers in the cluster --> 配置起來很麻煩。。。

2.其中如果對於方法的操作,resin的其啟動與關閉,必須全部一起操作,否則就不會成功。這個是我測試的結果,開始我也以為不影響,調試了幾個小時,最后發現是這個問題。也許是因為我某個地方配置不正確,誰知道請告訴我下,謝謝。

 四、問題

 關於性能上的問題,是使用一個resin使用不同的配置文件做集群性能好,還是安裝多個resin性能好?如網站執行效率,服務器資源消耗等方面。

 

 

 

 

http://www.programgo.com/article/64642736946/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM