??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品无码久久久,亚洲乱码一二三四五六区,亚洲国产一区二区视频网站http://www.tkk7.com/jelver/category/19887.htmlhttp://www.gaolucha.com上线了,嘿嘿zh-cnWed, 26 Dec 2012 12:26:51 GMTWed, 26 Dec 2012 12:26:51 GMT60NginxҎ(gu)UA区分PC或手问不同网?/title><link>http://www.tkk7.com/jelver/articles/392971.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Fri, 14 Dec 2012 02:44:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/392971.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/392971.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/392971.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/392971.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/392971.html</trackback:ping><description><![CDATA[Ҏ(gu)览器的UA可以判断Q当然不是完全准,但是可以匚w大部分的讉KQ关键的Nginx配置如下Q?br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000; ">#默认的root为webQ符合手机后则到wap目录?br />        location  </span><span style="color: #808080; ">/</span><span style="color: #000000; "> {<br />                       root </span><span style="color: #808080; ">/</span><span style="color: #000000; ">usr</span><span style="color: #808080; ">/</span><span style="color: #000000; ">local</span><span style="color: #808080; ">/</span><span style="color: #000000; ">website</span><span style="color: #808080; ">/</span><span style="color: #000000; ">web;<br />                        </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> ( $http_user_agent </span><span style="color: #808080; ">~</span><span style="color: #000000; "> "(MIDP)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(WAP)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(UP.Browser)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Smartphone)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Obigo)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Mobile)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(AU.Browser)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(wxd.Mms)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(WxdB.Browser)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(CLDC)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(UP.Link)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(KM.Browser)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(UCWEB)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SEMC\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">Browser)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Mini)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Symbian)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Palm)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Nokia)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Panasonic)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(MOT\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SonyEricsson)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(NEC\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Alcatel)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Ericsson)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(BENQ)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(BenQ)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Amoisonic)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Amoi\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Capitel)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(PHILIPS)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SAMSUNG)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Lenovo)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Mitsu)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Motorola)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SHARP)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(WAPPER)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(LG\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(LG</span><span style="color: #808080; ">/</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(EG900)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(CECT)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Compal)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(kejian)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Bird)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(BIRD)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(G900</span><span style="color: #808080; ">/</span><span style="color: #000000; ">V1.</span><span style="color: #800000; font-weight: bold; ">0</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Arima)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(CTL)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(TDG)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Daxian)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(DAXIAN)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(DBTEL)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Eastcom)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(EASTCOM)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(PANTECH)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Dopod)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Haier)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(HAIER)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(KONKA)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(KEJIAN)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(LENOVO)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Soutec)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SOUTEC)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SAGEM)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SEC\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(SED\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(EMOL\</span><span style="color: #808080; ">-</span><span style="color: #000000; ">)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(INNO55)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(ZTE)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(iPhone)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Android)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Windows CE)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Wget)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Java)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(curl)</span><span style="color: #808080; ">|</span><span style="color: #000000; ">(Opera)" ){<br />                               root </span><span style="color: #808080; ">/</span><span style="color: #000000; ">usr</span><span style="color: #808080; ">/</span><span style="color: #000000; ">local</span><span style="color: #808080; ">/</span><span style="color: #000000; ">website</span><span style="color: #808080; ">/</span><span style="color: #808080; "></span><span style="color: #000000; ">wap;  <br />                        }<br />                       </span><span style="color: #0000FF; ">index</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">index</span><span style="color: #000000; ">.html </span><span style="color: #0000FF; ">index</span><span style="color: #000000; ">.htm;<br />        }<br /></span></div><br /><img src ="http://www.tkk7.com/jelver/aggbug/392971.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2012-12-14 10:44 <a href="http://www.tkk7.com/jelver/articles/392971.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat6.0q程调试【{?/title><link>http://www.tkk7.com/jelver/articles/371062.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Thu, 01 Mar 2012 03:11:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/371062.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/371062.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/371062.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/371062.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/371062.html</trackback:ping><description><![CDATA[<div><p>U薯“http://www.oschina.net/question/12_8196”<br /></p><p>有些时候,调试不得不用外网Q比如说做支付宝的支付接口,服务器后台?知就不得不用外网的ip。无奈,只能扔到服务器远E调试了?/p> <p>|上讲关于远E调试tomcat的倒是蛮多Q基本都是将改啥catalina.sh,startup.sh的,操作q是复杂炏V下面这就只针对于 linux下的tomcatq程调试Q不用改啥文Ӟ单而又没啥副作用。本人在tomcat6 的情况下q程调试成功?/p> <p>怿? 多J2EE的开发者都是在Windows上面开发程序,然后把程序上传到Linux下运行的吧。可是有时候在自己机器上运行的好好的程序,攑ֈ服务器下? 出错了。单单看出错信息也推断不出是哪里的问题。这时候试试用Java的JPDAq程调试E序Q一定可以让你很满意?/p> <p>tomcat服务器已l内|了JPDA支持Q只要用:</p> <p>catalina.sh jpda start</p> <p>q条命o启动tomcatQ它?yu)׃监?000端口Q等待调试器的连接。要注意?span style="font-size: 1em;">能</span>?startup.sh脚本。tomcat会?JPDA_ADDRESSq个环境变量的倹{比如想监听8017端口Q?/p> <p>export  JPDA_ADDRESS=8017 <br />catalina.sh jpda start</p> <p>接着Q选一个自己喜Ƣ的调试器,基本上现在主的如Eclipse、NetBean都可以。我主要使用EclipseQ操作只要三步:</p> <p>1.选择“Run”菜单里的“Open Debug Dialog”?/p> <p>2.在对话框里找?#8220;Remote Java Application”?右键菜单选择“New”创徏一个配|?/p> <p>3.新创建的配置的Project选择服务器上的工E。Host和Port分别填写你服务器的IP和JPDA的端口,默认?000Q或 ?JPDA_ADDRESS?/p> <p>现在可以像本机调试一P 讄断点和跟t调试了?/p></div><img src ="http://www.tkk7.com/jelver/aggbug/371062.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2012-03-01 11:11 <a href="http://www.tkk7.com/jelver/articles/371062.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Resin 跨服务器的session传递[zhuan]http://www.tkk7.com/jelver/articles/289502.html都市淘沙?/dc:creator>都市淘沙?/author>Sun, 02 Aug 2009 13:50:00 GMThttp://www.tkk7.com/jelver/articles/289502.htmlhttp://www.tkk7.com/jelver/comments/289502.htmlhttp://www.tkk7.com/jelver/articles/289502.html#Feedback0http://www.tkk7.com/jelver/comments/commentRss/289502.htmlhttp://www.tkk7.com/jelver/services/trackbacks/289502.htmlResin 跨服务器的session传?/p>

--By oldjavaman

 http://blog.csdn.net/oldjavaman/archive/2009/07/10/4338315.aspx

1.   Z文g的session持久化技?/p>

Seesion能够被跨服务器持久化Q?包含我们的web应用的Class发生变化Q?譬如在开发期_使用Z文g的持久化Seesion技术是非常便捷的, 其是我们在开发时Q?当Servlet会发生经常变?/p>

在resin.conf中配|如?/p>

<web-app xmlns="http://caucho.com/ns/resin">  <session-config>    <file-store>WEB-INF/sessions</file-store>  </session-config></web-app>

q样的配|是Session写在一个在<file-store>中定义的文g目录中,当Session发生变化Ӟ会把session写入一个文Ӟ 当web应用被加载时Q?resin会从文g里面加蝲session

但是Q基于文件的session技术在做跨服务器的session传递时是没有作用的Q有人提Z用NFS技术, 在多个服务器之间׃nq个session持久文gQ?但是NFS往往会从本地调用~存Q?q样一来, 实际存放session的文件发生变化时Q不能及时在另一台服务器上得C?/p>

2.   分布式session
分布式session比文件持久session复杂得多Q?文g持久session是一个简单的Z内存的session理Q?但是分布式session必须事先在多台服务器之间实现session变化的传?/p>

多台机器的负载均衡, 使用的session技术不外乎sticky sessions Q粘性sessionQ或者symmetrical sessionsQ对UsessionQ。前者关注的是负载均衡技术, 后者是xJVM的技术。用何U技术依赖于你有什么样的硬Ӟ多少台机器,你要如何理session.

2.1.      对称session
对称session技术多用于负蝲均衡Q一个session可以从A机器中取出,存放在B机器里面Q采用JDBC session技术的对称session ,需要描qresin.conf中的“always-load-session”属性?每个h都获得最新状态的session

对于对称的session来说Q?一个完全一致的服务器环境是他可以工作的基础Q所以较_性session来说Q?׃它每ơwebh都需要更新session信息Q?所以比较低效?/p>

2.2.      _性session
_性的session依赖JVM来实玎ͼ 只要session开始工作,那么负蝲均衡永q把相同的session存放于同一个机器上Q?举个例子来说,有一个ID为aaaXXX的session永远攑֜A机器的JVM-A上, 而bbbXXX的session用于攑֜B机器的JVM-B上?/p>

使用q种技术的是比较可靠的Q?如果A机器宕机Q?则可以从B机器上取得我们需要的sessionQ?而用者ƈ无从查觉Q另外用粘性session是高效率的,只有session发生变更时才需要重写到服务器?/p>

2.3.      always-load-session
正如上文提及的对U式的session技术需要?lt;always-load-session>属性来标识是否每个h都要从服务器更新sessionQ?如果使用的是jdbc-session技术, 那么q个标识是一定要在配|文件中加上的, 但是如果是基于tcp-session技术的话, 可以不用标识Q?因ؓtcp-session的技术更练一些?/p>

always-save-session属性强制了客户的每ơwebh需要从服务器的session存储中获得更斎ͼ默认情况Q用户只有在创徏session才从服务器持久层取得sessionQ但是用了多个服务器的话, 需要标识来强制每个h都从服务器持久层取得session来保证每个服务器的session是一致的?/p>

2.4.      always-save-session
默认情况, 当session发生变化时Resin会将session写入到服务器Q?如:你在E序中调用了setAttribute()Ҏ(gu)Q但是假设你仅仅是更Csession中的对象的一个属性, 譬如存放的是一个用户对象, 你改变了q个用户对象的年U, q个时候resinq不能侦到session的变化,也不会保存这个变化?/p>

使用<always-save-session >属性, 可以保在客户么个请求结束后Q?都会在服务器保存session的变化, 管低效Q?但是非常可靠?/p>

 

3.   Z数据库的session同步技?br /> Z数据库的session技术非常容易理解, resin把session写入到数据库中, 每次hsession从数据库中来获得?/p>

Z效率的考虑Q?jvm所在机器必M存session的缓存,只有当session发生变化Ӟq个机器才会向数据库重新查询Q如果另一个jvm里面的代码改变了sessionQ将会通知q个机器向数据库h获得更新?/p>

q样的数据库同步技术会D向一个已l存在session的机器分发变更了的session数据Q这h据库可能会成为瓶颈, Z解决q样的问题, 采用便捷dy的mysql来存储sessionQ用Oracle来存放业务数据是一个不错的L?/p>

使用数据库技?lt;database>属性是必须的, 加上q个属性,resin会自动在制定数据库上创徏session存储的表

<resin xmlns="http://caucho.com/ns/resin"><server>  <http id='a' port='80'/>  <http id='b' port='80'/>   <database jndi-name="jdbc/session">    ...  </database>   <cluster>    <srun id='a' host='host-a' port='6802'/>    <srun id='b' host='host-b' port='6802'/>  </cluster>   <persistent-store type="jdbc">    <init>      <data-source>jdbc/session<data-source>    </init>  </persistent-store>  ...   <web-app-default>    <session-config>      <use-persistent-store/>    </session-config>  </web-app-default>
 

持久化的session必须在上文的<sever>中?lt;persistent-store>来定义。而每一个web-app应用必须使用<use-persistent-store/>来表C需要分布式session技?/p>

ata-source
 数据?br />  
table-name
 存放session数据的表?
 
blob-type
  Blobcd
 
max-idle-time
  释放旉
 

 

 

CREATE TABLE persistent_session (

  id VARCHAR(64) NOT NULL,

  data BLOB,

  access_time int(11),

  expire_interval int(11),

  PRIMARY KEY(id)

)
 

下面是一个用持久层session的web-app定义CZQ?/p>

<web-app xmlns="http://caucho.com/ns/resin">  <session-config>    <use-persistent-store/>    <always-save-session/>  </session-config></web-app>

4.   Z集群session技?br /> Z集群的session技术应用在服务器集领域, 在一些案例中采用数据库的session分布技术是高效的, 有些场合Q采用集的session是高效的?/p>

在集的session每一个服务器拥有一个jvm和一个备份j(lu)vmQ?session同时保存在自qjvm和备份j(lu)vm里面?/p>

同样圎ͼ 你必M?lt;sever>中的<cluster>下面?lt;srun>属性来辑ֈ集群session的效果, 在web-app中?lt;use-persistent-store>属性来标识q个应用采用session持久化技?/p>

配置如下Q?/p>

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

  ...

 

<server>

  <cluster>

    <srun id="a" host="192.168.0.1" port="6802" index="1"/>

    <srun id="b" host="192.168.0.2" port="6802" index="2"/>

  </cluster>

 

  <persistent-store type="cluster">

    <init path="cluster"/>

  </persistent-store>

  ...
 

 

<web-app xmlns="http://caucho.com/ns/resin">  <session-config>    <use-persistent-store="true"/>  </session-config></web-app>
 

<srun>?lt;srun-backup>都被视ؓ一个集服务器Q?当一个服务器上的session发生变化Ӟ 它会自动L其他的备份服务器Q?q把备䆾服务器上的session更新Q?当这个服务器重新启动Ӟ 他会向备份服务器hsessionQƈ获得备䆾?/p>

<resin xmlns="http://caucho.com/ns/resin"><server>  <http id='a' port='80'/>  <http id='b' port='80'/>   <cluster>    <srun id='a' host='host-a' port='6802'/>    <srun id='b' host='host-b' port='6802'/>  </cluster>   <persistent-store type="cluster">    <init path="cluster"/>  </persistent-store>   <host id=''>  <web-app id=''>   <session-config>    <use-persistent-store="true"/>  </session-config>   </web-app>  </host></server></resin>
 

 

 

 

 

 
 
5. 关于作?
OldJavaManQ长期致力于Java相关领域的技术工作, 主要参与J2EE相关E序的设计, 目前在南京的一家Y件企业就职,他希望和q大的Java爱好者结交朋友。大家可以通过 mail 联系??/p>

本文来自CSDN博客Q{载请标明出处Qhttp://blog.csdn.net/oldjavaman/archive/2009/07/10/4338315.aspx



]]>
Resin集群及双机备份方案【{?/title><link>http://www.tkk7.com/jelver/articles/285406.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Fri, 03 Jul 2009 12:15:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/285406.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/285406.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/285406.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/285406.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/285406.html</trackback:ping><description><![CDATA[<p style="text-indent: 2em">Resin集群及双机备份方案(resin集群Q冷备)</p> <p style="text-indent: 2em">作者:darkblue</p> <p style="text-indent: 2em">有两台服务器</p> <p style="text-indent: 2em">L名:web-srv</p> <p style="text-indent: 2em">内网IPQ?0.199.55.1</p> <p style="text-indent: 2em">外网IPQ?21.183.173.225</p> <p style="text-indent: 2em">域名Qweb.xxxx.com</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">L名:wap-srv</p> <p style="text-indent: 2em">内网IPQ?0.199.55.3</p> <p style="text-indent: 2em">外网IPQ?21.183.173.226</p> <p style="text-indent: 2em">域名Qwap.xxxx.com</p> <p style="text-indent: 2em">防火墙:PIX525Q服务器OS:RedHat ES4U2</p> <p style="text-indent: 2em">需求:</p> <p style="text-indent: 2em">web-srv和wap-srv均用apache2+resin3.1.2提供http服务Q监听端口都?0?/p> <p style="text-indent: 2em">1、当两台L都正常运作的时候,通过resin来实现负载均衡,web-srv?0端口提供web服务Qwap-srv?0端口提供wap服务Q?/p> <p style="text-indent: 2em">2、当web-srv宕机后,手工启用wap-srv上面的另一个apacheq程Q监?080端口Q提供web服务Q这个时候两个公|IP同时指向一个私|IP10.199.55.3Q结果是Q?0端口提供的是wap服务Q?080端口提供的是web服务Q?/p> <p style="text-indent: 2em">3、当wap-srv宕机后,手工启用web-srv上面的另一个apacheq程Q监?080端口Q提供wap服务Q这个时候两个公|IP同时指向一个私|IP10.199.55.1Q结果是Q?0端口提供的是web服务Q?080端口提供的是wap服务Q?/p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">配置Q?/p> <p style="text-indent: 2em">一、DNS</p> <p style="text-indent: 2em">增加两条U录Q分别是121.183.173.225 <---> web.xxxx.comQ?21.183.173.226 <---> wap.xxxx.com?/p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">二、web-srv</p> <p style="text-indent: 2em">2.1 安装apache2、resin-3.1.0</p> <p style="text-indent: 2em">安装apache2?/p> <p style="text-indent: 2em">安装resin-3.1.0</p> <p style="text-indent: 2em">Wget “http://www.caucho.com/download/resin-3.1.0.tar.gz”</p> <p style="text-indent: 2em">Cp resin-3.1.0.tar.gz /usr/local/</p> <p style="text-indent: 2em">Tar –xzvf resin-3.1.0.tar.gz</p> <p style="text-indent: 2em">cd resin-3.1.0</p> <p style="text-indent: 2em">./ configure --with-apache=/usr/local/apache2</p> <p style="text-indent: 2em">Make</p> <p style="text-indent: 2em">Make install</p> <p style="text-indent: 2em">2.2 准备配置文g和目?/p> <p style="text-indent: 2em">copy /usr/local/apache2/conf/httpd.conf httpdweb.conf</p> <p style="text-indent: 2em">copy /usr/local/apache2/conf/httpd.conf httpdwap.conf</p> <p style="text-indent: 2em">mkdir /usr/local/apache2/htdocs/web</p> <p style="text-indent: 2em">mkdir /usr/local/apache2/htdocs/wap</p> <p style="text-indent: 2em">cp -r /usr/local/resin-3.1.0 /usr/local/resin-web</p> <p style="text-indent: 2em">cp -r /usr/local/resin-3.1.0 /usr/local/resin-wap</p> <p style="text-indent: 2em">2.3 修改httpdweb.conf的监听端?80)和web的\?/p> <p style="text-indent: 2em">file: /usr/local/apache2/conf/httpdweb.conf</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.3 6802</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.1 6802</p> <p style="text-indent: 2em">CauchoConfigCacheDirectory /tmp</p> <p style="text-indent: 2em">CauchoStatus yes</p> <p style="text-indent: 2em">2.4 修改httpdwap.conf的监听端?8080)和wap的\?/p> <p style="text-indent: 2em">file: /usr/local/apache2/conf/httpdweb.conf</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.3 6803</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.1 6803</p> <p style="text-indent: 2em">CauchoConfigCacheDirectory /tmp</p> <p style="text-indent: 2em">CauchoStatus yes</p> <p style="text-indent: 2em">2.5 修改resin3.1.2的集和相关的java配置</p> <p style="text-indent: 2em">file: /usr/local/resin-web/conf/resin.conf</p> <p style="text-indent: 2em"><cluster> </p> <p style="text-indent: 2em">  <server id="10.199.55.1" address="10.199.55.1" port="6802"></p> <p style="text-indent: 2em"> ………………</p> <p style="text-indent: 2em"></cluster></p> <p style="text-indent: 2em">file: /usr/local/resin-wap/conf/resin.conf</p> <p style="text-indent: 2em"><cluster> </p> <p style="text-indent: 2em">  <server id="10.199.55.1" address="10.199.55.1" port="6803"></p> <p style="text-indent: 2em"> ………………</p> <p style="text-indent: 2em"></cluster></p> <p style="text-indent: 2em">2.6 启动apache和resin</p> <p style="text-indent: 2em">apache2</p> <p style="text-indent: 2em">/usr/local/apache2/bin/httpd -f ./conf/httpdweb.conf</p> <p style="text-indent: 2em">/usr/local/apache2/bin/httpd -f ./conf/httpdwap.conf</p> <p style="text-indent: 2em">resin</p> <p style="text-indent: 2em">/usr/local/resin-web/bin/httpd.sh -server 10.199.55.1 start</p> <p style="text-indent: 2em">/usr/local/resin-wap/bin/httpd.sh -server 10.199.55.1 start</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">三、wap-srv</p> <p style="text-indent: 2em">3.1 安装apache2、resin-3.1.0</p> <p style="text-indent: 2em">安装apache2?/p> <p style="text-indent: 2em">安装resin-3.1.0</p> <p style="text-indent: 2em">Wget “http://www.caucho.com/download/resin-3.1.0.tar.gz”</p> <p style="text-indent: 2em">Cp resin-3.1.0.tar.gz /usr/local/</p> <p style="text-indent: 2em">Tar –xzvf resin-3.1.0.tar.gz</p> <p style="text-indent: 2em">cd resin-3.1.0</p> <p style="text-indent: 2em">./ configure --with-apache=/usr/local/apache2</p> <p style="text-indent: 2em">Make</p> <p style="text-indent: 2em">Make install</p> <p style="text-indent: 2em">3.2 准备配置文g和目?/p> <p style="text-indent: 2em">copy /usr/local/apache2/conf/httpd.conf httpdweb.conf</p> <p style="text-indent: 2em">copy /usr/local/apache2/conf/httpd.conf httpdwap.conf</p> <p style="text-indent: 2em">mkdir /usr/local/apache2/htdocs/web</p> <p style="text-indent: 2em">mkdir /usr/local/apache2/htdocs/wap</p> <p style="text-indent: 2em">cp -r /usr/local/resin-3.1.0 /usr/local/resin-web</p> <p style="text-indent: 2em">cp -r /usr/local/resin-3.1.0 /usr/local/resin-wap</p> <p style="text-indent: 2em">3.3 修改httpdweb.conf的监听端?8080)和web的\?/p> <p style="text-indent: 2em">file: /usr/local/apache2/conf/httpdweb.conf</p> <p style="text-indent: 2em">端口和目录略</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.3 6802</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.1 6802</p> <p style="text-indent: 2em">CauchoConfigCacheDirectory /tmp</p> <p style="text-indent: 2em">CauchoStatus yes</p> <p style="text-indent: 2em">3.4 修改httpdwap.conf的监听端?80)和wap的\?/p> <p style="text-indent: 2em">file: /usr/local/apache2/conf/httpdweb.conf</p> <p style="text-indent: 2em">端口和目录略</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.3 6803</p> <p style="text-indent: 2em">ResinConfigServer 10.199.55.1 6803</p> <p style="text-indent: 2em">CauchoConfigCacheDirectory /tmp</p> <p style="text-indent: 2em">CauchoStatus yes</p> <p style="text-indent: 2em">3.5 修改resin3.1.2的集和相关的java配置</p> <p style="text-indent: 2em">file: /usr/local/resin-web/conf/resin.conf</p> <p style="text-indent: 2em"><cluster> </p> <p style="text-indent: 2em">  <server id="10.199.55.3" address="10.199.55.3" port="6802"></p> <p style="text-indent: 2em"> ………………</p> <p style="text-indent: 2em"></cluster></p> <p style="text-indent: 2em">file: /usr/local/resin-wap/conf/resin.conf</p> <p style="text-indent: 2em"><cluster> </p> <p style="text-indent: 2em">  <server id="10.199.55.3" address="10.199.55.3" port="6803"></p> <p style="text-indent: 2em"> ………………</p> <p style="text-indent: 2em"></cluster></p> <p style="text-indent: 2em">3.6 启动apache和resin</p> <p style="text-indent: 2em">apache2</p> <p style="text-indent: 2em">/usr/local/apache2/bin/httpd -f ./conf/httpdweb.conf</p> <p style="text-indent: 2em">/usr/local/apache2/bin/httpd -f ./conf/httpdwap.conf</p> <p style="text-indent: 2em">resin</p> <p style="text-indent: 2em">/usr/local/resin-web/bin/httpd.sh -server 10.199.55.3 start</p> <p style="text-indent: 2em">/usr/local/resin-wap/bin/httpd.sh -server 10.199.55.3 start</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">四、防火墙的配|?/p> <p style="text-indent: 2em">因ؓweb-srv和wap-srv只提供www服务Q所以只需要对q两个内外网的IP地址对做端口映射?/p> <p style="text-indent: 2em">static (dmz,outside) tcp 121.183.173.225 www 10.199.55.1 www netmask 255.255.255.255</p> <p style="text-indent: 2em">static (dmz,outside) tcp 121.183.173.226 www 10.199.55.3 www netmask 255.255.255.255</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">五、冷备的实现 </p> <p style="text-indent: 2em">5.1 当web-srv宕机后:</p> <p style="text-indent: 2em">5.1.1 修改防火墙配|?/p> <p style="text-indent: 2em">no static (dmz,outside) tcp 121.183.173.225 www 10.199.55.1 www netmask 255.255.255.255</p> <p style="text-indent: 2em">static (dmz,outside) tcp 121.183.173.225 www 10.199.55.3 8080 netmask 255.255.255.255</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">5.1.2 启动wap-srv的第二个apacheq程Q监?080端口Q提供web服务</p> <p style="text-indent: 2em">/usr/local/apache2/bin/httpd -f ./conf/httpdweb.conf</p> <p style="text-indent: 2em">用户讉K<a ><font color="#000000">http://web.xxxx.com</font></a>指?0.199.55.3:8080</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">5.2 当wap-srv宕机后:</p> <p style="text-indent: 2em"> </p> <p style="text-indent: 2em">5.2.1 修改防火墙配|?/p> <p style="text-indent: 2em">no static (dmz,outside) tcp 121.183.173.226 www 10.199.55.3 www netmask 255.255.255.255</p> <p style="text-indent: 2em">static (dmz,outside) tcp 121.183.173.226 www 10.199.55.1 8080 netmask 255.255.255.255</p> <p style="text-indent: 2em">5.2.2 启动web-srv的第二个apacheq程Q监?080端口Q提供wap服务</p> <p style="text-indent: 2em">/usr/local/apache2/bin/httpd -f ./conf/httpdwap.conf</p> <p style="text-indent: 2em">用户讉K<a ><font color="#000000">http://wap.xxxx.com</font></a>指?0.199.55.1:8080</p> <img src ="http://www.tkk7.com/jelver/aggbug/285406.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2009-07-03 20:15 <a href="http://www.tkk7.com/jelver/articles/285406.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>apache2与resin 3.1.6 在linux下的整合与负载均衡【{?/title><link>http://www.tkk7.com/jelver/articles/285358.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Fri, 03 Jul 2009 07:37:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/285358.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/285358.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/285358.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/285358.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/285358.html</trackback:ping><description><![CDATA[<div class="hqhsjne" id="art" style="margin: 15px"><1> 安装apache <br /> <br /> ./configure --prefix=/opt/apache2 --enable-so  --enable-dav --enable-dav-fs --enable-mods-shared=most  <br /> make <br /> make install<br /> 安装resin :<br /> ./configure --prefix=/opt/resin3.1.6 --with-apxs=/opt/apache2/bin/apxs  --with-apache=/opt/apache2<br /> make <br /> make install<br /> 上述操作~译安装完后Q会自动修改apacheQ包括:<br /> 1. copy mod_caucho.so到apache目录Q就是前面指定的--with-apache=/data/aoxj/artest/apacheQ的modules<br /> 2. 修改apache的配|文件conf/httpd.confQ自动增加以下内?br /> LoadModule caucho_module ***/modules/mod_caucho.so<br /> ResinConfigServer localhost 6800<br /> CauchoConfigCacheDirectory /tmp<br /> CauchoStatus yes <br /> 如果没有自动修改Q请自己手动dQ或者检查,是否配置正确?br /> <br /> 1Qlinux下用resin的单服务器配|?br /> <br /> 使用单服务器Ҏ(gu)Q只要安装完毕,配置一下Resin的resin.conf文g和app_default.xml文g可以了Qresin.conf文g中需要配|两处,<br /> 一是端口号Q另一处是WebE序存放目录Qapp_default.xml内可配置默认首页的搜索顺序?br /> ׃原网站用多个端口配|,所以单服务器只能用于做单个站点的测试用?br /> 配置如下Q?br /> 修改resin/conf/resin.conf <br />  <server id="a" address="192.168.1.116" port="6800"/><br /> 启动 /opt/resin/bin/httpd -server a start<br /> 如果使用如下命o默认启动,<br /> /opt/resin/bin/httpd start<br /> 必须如下配置.默认 是id 为空<br /> <server id="" address="192.168.1.116" port="6800"/><br /> 启动 /opt/apache2/bin/apachectl start<br /> 讉K http://localost/caucho-status 看是否成?<br /> ==========================================================================================================<br /> 2Qlinux下用resin的多服务器配|?br /> <br />  有时候需要运行多个服务器以在同一个テQC监听多个端口Q这时候就需要用单独的Resin服务器运行多个实例,以监听多个端口来部v多个Web站点?br /> q种Ҏ(gu)为多ơ用httpd.sh的参数指定配|文件和q行时的pid文gQ实现多个实例的q行?br /> 使用的命令行如下所C:<br /> $RESIN_HOME/bin/httpd.sh -conf conf/resin2.conf -server b start/stop<br /> 解释Q?br />  -conf 选项为选择此服务器实例所用的配置文gQ在q个文g里面配置不同的端口和ȝ录?br /> 具体配置如下:<br /> 配置一:<br /> copy 一份resin.confQ命名ؓresin2.conf,扑ֈ   <http address="*" port="8080"/><br /> 其注释掉。修改ؓQ?<!--http address="*" port="8080"/-->.<br /> d<server id="b" address="192.168.1.166" port="6801"/>?br /> 修改apache配置文g Q?br /> LoadModule caucho_module modules/mod_caucho.so<br /> ResinConfigServer 192.168.1.166 6800<br /> ResinConfigServer 192.168.1.166 6801<br /> CauchoConfigCacheDirectory /tmp<br /> CauchoStatus yes<br /> 然后用如下命令启动:<br /> /opt/resin3.1.6/bin/httpd.sh -conf /opt/resin3.1.6/conf/resin2.conf -server b start<br /> 讉K http://localost/caucho-status 看是否成?<br /> <br /> 配置?<br /> copy 一份resin.confQ命名ؓresin3.conf,扑ֈ   <http address="*" port="8080"/><br /> 其注释掉。修改ؓQ?<!--http address="*" port="8080"/-->.<br /> d <br /> <server id='b' address='192.168.1.166' port='6802' watchdog-port="6602"><br />   <http port="8081"/><br /> </server><br /> q样配置Q即启动了两套resin服务。优Ҏ(gu)比较安全。缺Ҏ(gu) 比较费pȝ资源?br /> 修改apache配置文g Q?br /> LoadModule caucho_module modules/mod_caucho.so<br /> ResinConfigServer 192.168.1.166 6800<br /> ResinConfigServer 192.168.1.166 6802<br /> CauchoConfigCacheDirectory /tmp<br /> CauchoStatus yes<br /> 然后用如下命令启动:<br /> /opt/resin3.1.6/bin/httpd.sh -conf /opt/resin3.1.6/conf/resin3.conf -server b start<br /> 讉K http://localost/caucho-status 看是否成?<br /> 如果讉K不了。接着d如下配置到httpd.conf中?br /> <Location /caucho-status><br />         SetHandler caucho-status<br /> </Location><br /> ============================================================================================================<br /> <2> apache,resin与虚拟主?br /> 上面只是配好apache与resin的整合,其它很多企业应用中还涉及到配|a(chn)pache与resin的虚拟主机的配置Q?br /> 接着来说说如何利用apache与resin配置虚拟L了,注意以下介绍的都是基于一个IP多个域名的虚拟主机的配法Q?br /> 配置a(chn)pache2:<br /> NameVirtualHost *:80<br /> <VirtualHost *:80><br />     DocumentRoot "/www/test1"<br />     ServerName www.test1.com<br />     ServerAlias www.test1.com<br />     ErrorLog "logs/test1_err.log"<br />     CustomLog "logs/test1_access.log" common<br />     ResinConfigServer 192.168.1.166 6800<br /> </VirtualHost><br /> <VirtualHost *:80><br />     DocumentRoot "/www/test2"<br />     ServerName www.test2.com<br />     ServerAlias www.test2.com<br />     ErrorLog "logs/test2_error.log"<br />     CustomLog "logs/test2_access.log" common<br />     ResinConfigServer 192.168.1.166 6801<br /> </VirtualHost><br /> 修改apache 配置文g如下Q?br /> <br /> LoadModule caucho_module modules/mod_caucho.so<br /> ResinConfigServer 192.168.1.166 6800<br /> ResinConfigServer 192.168.1.166 6801<br /> CauchoConfigCacheDirectory /tmp<br /> CauchoStatus yes<br /> <Location /caucho-status><br />         SetHandler caucho-status<br /> </Location><br /> 也可以将 W二行和W三行注释掉?br /> <br /> d目录讉K权限Q?br /> <Directory "/www"><br />     Options Indexes FollowSymLinks<br />     Order allow,deny<br />     Allow from all<br /> </Directory><br /> 配置resin.conf ,d如下Q?br /> <host id="www.test1.com" root-directory=".">  <br />     <host-alias>www.test1.com</host-alias>  <br />     <web-app id="/" root-directory="/www/test1/"></web-app>  <br /> </host> <br /> 配置resin2.conf d如下内容Q?br /> <host id="www.tet2.com" root-directory=".">  <br />     <host-alias>www.test2.com</host-alias>  <br />     <web-app id="/" root-directory="/www/test2/"></web-app>  <br /> </host> <br /> 注意Q?lt;host-alias>一定要和apache中的ServerAlias相对应?<br /> 分别启动resinQ?br /> /opt/resin3.1.6/bin/httpd.sh -server a start<br /> /opt/resin3.1.6/bin/httpd.sh -conf /opt/resin3.1.6/conf/resin2.conf -server b start<br /> 分别?www/test1?/www/test2/目录下徏立test1.jsp 和test2.jsp试Q是否成功。如果访问成功?br /> 说明配置成功?br /> <br /> 以上是不同主机用不同的JVMQ如果你只有一个虚拟host的话<br /> 可以在Apache的httpd.conf中这么这栯|?br /> <Location /applicationA/*><br /> ResinConfigServer 192.168.1.166 6800<br /> </Location><br /> <Location /applicationB/*><br /> ResinConfigServer 192.168.1.166 6801<br /> </Location><br /> 不同的模块,使用不同的jvm </div> <img src ="http://www.tkk7.com/jelver/aggbug/285358.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2009-07-03 15:37 <a href="http://www.tkk7.com/jelver/articles/285358.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用apache+resin实现负蝲均衡讄【{载?/title><link>http://www.tkk7.com/jelver/articles/285351.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Fri, 03 Jul 2009 06:48:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/285351.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/285351.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/285351.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/285351.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/285351.html</trackback:ping><description><![CDATA[<p>原文Q?a >http://liujintao.blog.51cto.com/413051/86242</a><br /> 上周六参加了51CTO的负载均衡的技术沙?主要是基于LVS的负载均?受益匪浅,开阔了思\,回去要好好研I一?<br />      其实使用web服务器自w的讄也能辑ֈ负蝲均衡的目?我们公司使用的web服务器是resin,resin自生可以进行负载均衡设|?但是只有professional版本才支?q个东西的license一个CPU?500,所以实际用的apache+resin的组?免费?)),׃公司的系l只有运营商和CP会登录访?q发压力q不?使用负蝲均衡主要是ؓ了防止系l死掉后无法dQ所以这L设计基本够用了。如果ƈ发访问量很大的话,应该考虑在apache前面加squid做cache、通过dns轮寻{方案了?</p> <div>    虽然|上也有<font size="2">apache+resinq行负蝲均衡讄的例?但是׃apach和resin不同版本的配|的配置文g有一定的差距,按照|上的资料不一定能讄成功,下面的例子是在linux环境下用httpd-2.0.59和Resin-3.1.6q行负蝲均衡讄?如果使用其他版本请参考apache和resin官方|站的配|说?/font></div> <div><font size="2">    需要准?台l(f)inux机器(如果是在没有,可以先用一台机器熟(zhn)一?,每台机器都要安装apache和resin(其实1台装apach,另外2台装resin够用了,,之所以要全装是ؓ了以后的扩展考虑),其中一C为前端服务器(apache),另外2C为后台服务器(resin)</font></div> <div><font size="2"></font> </div> <h4>1 演示环境</h4> <div>192.168.11.5:<font size="2">前端服务?/font></div> <div><font size="2">192.168.11.111:后台服务?/font></div> <div><font size="2">192.168.11.11:后台服务?/font></div> <div><font size="2"></font> </div> <h3>2 安装Apache</h3> <div><br /> 到Apache的官方网?<a >[url]http://www.Apache.org[/url]</a>可以下蝲?br /> 演示时用的是httpd-2.0.59版本<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">[root@yf3 liujt]# tar –xzvf httpd-2.0.59.tar.gz     //解压~安装文?<br /> [root@yf3 liujt]# cd httpd-2.0.59               //q入解压~的文g <br /> [root@yf3 httpd-2.0.59] # ./configure --prefix /usr/local/Apache2 -–enable-rewrite=shared --enable-speling=shared <br /> [root@yf3 httpd-2.0.59] # make <br /> [root@yf3 httpd-2.0.59] # make install </div> </div> <div><br /> 完成以上操作?q入/usr/local/Apache2,发现Apache已经安装完成.</div> <h4><br /> 3 安装Resin</h4> <div><br /> 到Resin的官方网站可以下?br /> 演示时用的是Resin-3.1.6版本<br /> 和普通安装Resin的方式有一点区别,Resin要联合Apache安装,也就是用参?-with-Apache=/usr/local/Apache2<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">[root@yf3 liujt]# tar –xzvf Resin-3.1.6.tar.gz     //解压~安装文?<br /> [root@yf3 liujt]# cd Resin-3.1.6                    //q入解压~的文g <br /> [root@yf3 Resin-3.1.6] # ./configure --prefix=/usr/local/Resin --withapxs=/usr/local/ <br /> Apache2/bin/apxs  <br /> [root@yf3 Resin-3.1.6] # make <br /> [root@yf3 Resin-3.1.6] # make install</div> </div> <div> </div> <div> </div> <h4>3  配置Resin</h4> <div><br /> 需要修?台后服务器的Resin的配|文件Resin.confQ\?usr/local/Resin/conf/Resin.conf,如果有多个Resin,均按此方式配|?br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">[root@yf3 Resin-3.1.6] # vi /usr/local/Resin/conf/Resin.conf</div> </div> <h5><br /> 3.1 配置默认的负责均?/h5> <div><br /> 扑ֈ配置文g中的<!-- define the servers in the cluster -->,修改负蝲均衡配置,需要设|服务的ID、IP和portQ例?92.168.11.11的设|如?br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><server id="a" address="127.0.0.1" port="6805"/></div> </div> <div><br /> 如果同一个项目要启动多个服务,可以配置多项,但是要用不同的id名称和port,例如:<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><server id="a" address="127.0.0.1" port="6805"/> <br /> <server id="b" address="127.0.0.1" port="6806/></div> </div> <div> </div> <div>如果要在同一个resin中部|多个项?可以讄不同的配|文?指向不同的虚拟目录来实现,启动resin时启动不同的配置文g卛_.</div> <div> </div> <div> </div> <h4><br /> 4 配置Apache</h4> <div><br /> 需要对前端E序(192.168.11.5)的apach的配|文件httpd.confq行修改Q\?/usr/local/Apache2/conf/httpd.conf</div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">[root@yf3 Resin-3.1.6] # vi /usr/local/Apache2/conf/httpd.conf</div> </div> <div> </div> <h5>4.1 修改监听接口</h5> <div><br /> 扑ֈ配置文g中的Listen 80Q此端口是在web面讉K时用的端口,例如安装apache的服务器IP?92.168.11.5,如果web的需要将web讉K地址设ؓ<a >[url]http://192.168.11.5:8080[/url]</a>,需要如下配|?/div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">Listen 8080</div> </div> <div> </div> <h5>4.2 修改DocumentRoot</h5> <div><br /> 扑ֈ配置文g中的DocumentRoot配置<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">DocumentRoot "/usr/local/Apache2/htdocs"</div> </div> <div><br /> 修改为实际需要的路径,例如改ؓ实际的发布\径ؓ/usr/local/Apache2/htdocs/testQ就需要改成以下Ş?br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">DocumentRoot "/usr/local/Apache2/htdocs/test"</div> </div> <h5><br /> 4.3 Directory</h5> <div><br /> 扑ֈ配置文g中的Directory配置<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><Directory "/usr/local/Apache2/htdocs"></div> </div> <div><br /> 修改为实际需要的路径,例如改ؓ实际的发布\径ؓ/usr/local/Apache2/htdocs/testQ就需要改成以下Ş?br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><Directory "/usr/local/Apache2/htdocs/test">; <br /> </div> </div> <h5><br /> 4.4 修改DirectoryIndex</h5> <div><br /> 扑ֈ配置文g中的DirectoryIndex配置<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">DirectoryIndex index.html index.html.var</div> </div> <div><br /> 增加index.jsp。修改ؓQ?br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">DirectoryIndex index.jsp index.html index.html.var</div> </div> <h5><br /> 4.5  修改Rensin相关配置</h5> <div><br /> 在apache的配|文件httpd.conf最后增加以下内?br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">LoadModule caucho_module /usr/local/Apache2/modules/mod_caucho.so <br /> ResinConfigServer 192.168.11.11 6805<br /> ResinConfigServer 192.168.11.111 6806 <br /> CauchoConfigCacheDirectory /tmp <br /> CauchoStatus yes</div> </div> <div><br /> 其中ResinConfigServer配置的是调用的Resin的设|的负蝲均衡器的IP地址和端口号<br /> 11.5的apach分别调用?1.11?1.111的两个Resin<br /> 11.11的Resin的负载生成器的配|ؓ<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><server id="a" address="192.168.11.11" port="6805"/></div> </div> <div><br /> 11.111的Resin的负载生成器的配|ؓ<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><server id="a" address="192.168.11.111" port="6806"/></div> </div> <h4><br /> 5 讉K试</h4> <h5><br /> 5.1. ~写试面</h5> <div><br /> Z查负载均衡是否生?需要编写测试页面a.jsp,通过在web面和各Resin的日志中昄的内容进行L?下面11.11的其中一个ResinZ说明<br /> </div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><%System.out.println("server 192.168.11.11");%>          //在Resin日志中显C?<br /> server 192.168.11.11                                //在web面昄</div> </div> <div><br /> 其他Resin的a.jsp参照上面的例?只需要将其中的内Ҏ(gu)换掉,例如11.111的a.jsp文g可以写成</div> <div> <div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><%System.out.println("server 192.168.11.111");%>          //在Resin日志中显C?<br /> server 192.168.11.111                                  //在web面昄</div> </div> <h5><br /> 5.2 发布目</h5> <div><br /> <strong>1. Apche目发布</strong><br /> a.jsp文g攑ֈ讄的apche的虚拟目录中,演示的设|的虚拟目录?br /> DocumentRoot "/usr/local/Apache2/test"<br /> 因此需要将a.jsp攑ֈ/usr/local/Apache2/test目录?br /> <strong>2. Resin目发布</strong><br /> 分别来两个a.jsp文g攑ֈ192.168.11.11?92.168.11.111讄的Resin的虚拟目录中,如果某Resin的虚拟目录是<br /> <web-app id="/" root-directory="webapps/ROOT"/><br /> 则需要将a.jsp攑ֈResin的webapps/ROOT目录?/div> <h5><br /> 5.3. 启动服务</h5> <div><br /> <strong>1. 启动Apache</strong><br /> [root@yf3 httpd-2.0.59] # /usr/local/Apache2/bin/httpd -f ./conf/httpd.conf<br /> <strong>2. 分别启动调用的Resin</strong></div> <p><strong></strong></p> <div><br /> 例如启动11.11的Resin-3.1.6中id?a"的服?需要在11.11服务器执行如下命?br /> [root@ yf3 Resin-3.1.6] # / usr/local/Resin-web/bin/httpd.sh -server a start<br /> 启动11.111的Resin-3.1.6中id?a"的服?需要在11.111服务器执行如下命?br /> [root@ localhost Resin-3.1.6] # / usr/local/Resin-web/bin/httpd.sh -server a start</div> <h5><br /> 5.4. 验证a.jsp</h5> <div><br /> 使用IE多次讉Kweb发布面,通过面昄的内容和Resin日志打印的内?查是否随用各Resin的a.jsp文g?br /> Web面的访问地址如下<br /> <a >[url]http://192.168.11.5:8080/a.jsp[/url]</a><br /> 查看rensin的方法如下,如果要看查看11.111的Resin-3.1.6中id?a"服务的日志,需要在11.111服务器执行如下命?br /> [root@ localhost Resin-3.1.6] # tail –f / usr/local/Resin-3.16 /log/a.log</div> <div>多次讉K<a >[url]http://192.168.11.5:8080/a.jsp[/url]</a>,如果每次会随机显C其中一个Resin的a.jsp文g的内?之后关闭其中个几个ResinQ不是全部关闭)Q?a >[url]http://192.168.11.5:8080/a.jsp[/url]</a>仍能正常讉KQ至此就完成了负载均衡的试。证明配|成功。之后就可以正是发布目?/div> <p> </p> <img src ="http://www.tkk7.com/jelver/aggbug/285351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2009-07-03 14:48 <a href="http://www.tkk7.com/jelver/articles/285351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Resin 3.1 配置文g详细说明http://www.tkk7.com/jelver/articles/183638.html都市淘沙?/dc:creator>都市淘沙?/author>Tue, 04 Mar 2008 03:10:00 GMThttp://www.tkk7.com/jelver/articles/183638.htmlhttp://www.tkk7.com/jelver/comments/183638.htmlhttp://www.tkk7.com/jelver/articles/183638.html#Feedback2http://www.tkk7.com/jelver/comments/commentRss/183638.htmlhttp://www.tkk7.com/jelver/services/trackbacks/183638.html <resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core">  
  <!-- 加蝲resin/lib下的所?jar文g-->  
  <class-loader>  
    <tree-loader path="${resin.home}/lib"/>  
    <tree-loader path="${resin.root}/lib"/>  
  </class-loader>  
  <!--  理配置 -->  
  <management path="${resin.root}/admin">  
  </management>  
  <!--   JDK日志接口的配|?   -->  
  <log name="" path="stdout:" timestamp="[%H:%M:%S.%s] "/>  
  <!-- 日志信息的别:'info' 生环境  'fine' 开发环?'finer' 调试环境 -->  
  <logger name="com.caucho" level="info"/>  
  <logger name="com.caucho.java" level="config"/>  
  <logger name="com.caucho.loader" level="config"/>  
  <!--  环境上下文的时_对于生站点, q个要设|长一点,例如600U,10分钟  -->  
  <dependency-check-interval>2s</dependency-check-interval>  
  <!--      发送邮仉知的SMTP服务?nbsp;    -->  
  <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>  
  
  <!-- L注释Q如果你使用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 Lq个如果你想理内存堆的們ր?-->  
          <jvm-arg>-agentlib:resin</jvm-arg>  
  
      <watchdog-arg>-Dcom.sun.management.jmxremote</watchdog-arg>  
      <!--   强制resin强制重v时的最空闲内?nbsp;   -->  
      <memory-free-min>1M</memory-free-min>  
      <!-- 最大线E数? -->  
      <thread-max>256</thread-max>  
      <!--  套接字等待时?-->  
      <socket-timeout>65s</socket-timeout>  
      <!-- 配置 keepalive -->  
      <keepalive-max>128</keepalive-max>  
      <keepalive-timeout>15s</keepalive-timeout>  
      <!--          如果使用的是UNIX,q里是启动的帐号和用L. -->  
          <user-name>resin</user-name>  
          <group-name>resin</group-name>  
        
    </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>  
    <!--   Z安全, 你可以ؓ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> 来检查?nbsp; -->  
    <resin:if test="${isResinProfessional}">  
      <ping>  
        <!-- <url>http://localhost:8080/test-ping.jsp</url> -->  
      </ping>  
    </resin:if>  
    <!-- 包含web应用的默认行?nbsp; -->  
    <resin:import path="${resin.home}/conf/app-default.xml"/>  
    <!-- 每一个web应用的默认参?nbsp; -->  
    <web-app-default>  
      <!-- 扩展库的公共jar文gQ扩展是安全的即使没有类装蝲器知道的jarsQ?br /> 装蝲的类ؓ每个应用分别装蝲Q也是q些c都是不同的 -->  
      <class-loader>  
        <tree-loader path="${server.root}/ext-webapp"/>  
      </class-loader>  
      <!--  讄~存c静态也的g时?nbsp; -->  
      <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文g。可以把validate-taglib-schema讄成false,可能l箋正常工作
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>  
    </web-app-default>  
    <!-- 单的数据池配|?-->  
        The JDBC name is java:comp/env/jdbc/test  
         <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服务器整合,q个可以被去掉,因ؓweb服务器也可以记录q些信息?nbsp; -->  
      <access-log path="logs/access.log" format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' rollover-period="1W"/>  
      <!-- war 文g的布|目?nbsp; -->  
      <web-app-deploy path="webapps"/>  
      <!-- ear文g的布|目?-->  
      <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文g的布|目?-->  
      <resource-deploy path="deploy"/>  
    </host-default>  
    <!-- 虚拟L的布|目?-->  
    <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="/resin-admin" root-directory="${resin.home}/php/admin">  
        <!--  理应用E序 /resin-admin password is the md5 hash of the password。md5码的密码?
localhost is true to limit access to the localhost。localhost讄成true,q样只有localhost才能讉K -->  
        <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>  
  </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 3.1 pro版本中集与负蝲均衡的实?/title><link>http://www.tkk7.com/jelver/articles/183449.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Mon, 03 Mar 2008 06:11:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/183449.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/183449.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/183449.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/183449.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/183449.html</trackback:ping><description><![CDATA[<table cellspacing="0" cellpadding="3" width="100%" border="0"> <tbody> <tr> <td align="left"><a ><img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=application%2Foctet-stream&attachment=1857" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >resin1.conf</a>(9.3 K)</td> </tr> <tr> <td align="left"><a ><img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=application%2Foctet-stream&attachment=1858" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >resin-web.conf</a>(8.8 K)</td> </tr> <tr> <td align="left"><a ><img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=image%2Fgif&attachment=1859" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >resin-313-cluster-app-1.gif</a>(6.8 K)</td> </tr> <tr> <td align="left"><a ><img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=image%2Fgif&attachment=1860" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >resin-313-cluster-app-2.gif</a>(6.8 K)</td> </tr> <tr> <td align="left"><a ><img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=image%2Fgif&attachment=1861" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >resin-313-cluster-web-1.gif</a>(6.3 K)</td> </tr> <tr> <td style="border-top: #ccc 1px solid" colspan="2"> </td> </tr> </tbody> </table> <a >切换到灯片模式</a><br /> <br /> <!--attachment end-->需要配|前端web层和后端应用层: <br /> <br /> 1.web层配|: <br /> <br /> <!--<br />             - Configuration <font color="navy"><strong>for</strong></font> the web-tier/load-balancer<br />             --><br />             <cluster id=<font color="red">"web-tier"</font>><br />             <server-default><br />             <!-- The http port --><br />             <http address=<font color="red">"*"</font> port=<font color="red">"80"</font>/><br />             </server-default><br />              <br />             <server id=<font color="red">"web-a"</font> address=<font color="red">"127.0.0.1"</font> port=<font color="red">"6700"</font>/><br />              <br />             <cache path=<font color="red">"cache"</font> memory-size=<font color="red">"64M"</font>/><br />              <br />             <host id=<font color="red">""</font>><br />             <web-app id=<font color="red">"/"</font>><br />              <br />             <rewrite-dispatch><br />             <load-balance regexp=<font color="red">""</font> cluster=<font color="red">"app-tier"</font>/><br />             </rewrite-dispatch><br />              <br />             </web-app><br />             </host><br />             </cluster><br />              <br />             <cluster id=<font color="red">"app-tier"</font>><br />             <server id=<font color="red">"a"</font> address=<font color="red">"127.0.0.1"</font> port=<font color="red">"6800"</font>/><br />             <server id=<font color="red">"b"</font> address=<font color="red">"127.0.0.1"</font> port=<font color="red">"6801"</font>/><br />              <br />             <persistent-store type=<font color="red">"cluster"</font>><br />             <init path=<font color="red">"cluster"</font>/><br />             </persistent-store><br />              <br />             <web-app-default><br />             <session-config><br />             <use-persistent-store/><br />             </session-config><br />             </web-app-default><br />              <br />             <host id=<font color="red">""</font>><br />             ...<br />             </host><br />             </cluster><br />            <br /> <br /> 以上配置来?0的请求分发给app-tier应用层集处理?<br /> <br /> 2.应用层集配|: <br /> <pre> <!-- define the servers in the cluster --> <server id=<font color="red">"a"</font> address=<font color="red">"127.0.0.1"</font> port=<font color="red">"6800"</font>/> <server id=<font color="red">"b"</font> address=<font color="red">"127.0.0.1"</font> port=<font color="red">"6801"</font>/> </pre> <br /> <br /> 3.启动应用层服务器Q?<br /> D:\resin-pro-3.1.3\httpd.exe -conf conf/resin1.conf -server a<br />  D:\resin-pro-3.1.3\httpd.exe -conf conf/resin1.conf -server b<br /> <br /> 以上启动了两个应用服务器a和b. <br /> <br /> 4.启动前端WEB服务器: <br /> <table cellspacing="1" cellpadding="3" bgcolor="#999999" border="0"> <tbody> <tr> <td valign="top" align="left" width="1" bgcolor="#dddddd"><font color="#555555"> <pre>1<br /> </pre> </font></td> <td valign="top" align="left" bgcolor="#ffffff"> <pre>> D:\resin-pro-3.1.3\httpd.exe -conf conf/resin-web.conf -server web-a </pre> </td> </tr> </tbody> </table> <br /> <br /> 5.写测试JSP a.jspQ?<br /> <table cellspacing="1" cellpadding="3" bgcolor="#999999" border="0"> <tbody> <tr> <td valign="top" align="left" width="1" bgcolor="#dddddd"><font color="#555555"> <pre>1<br /> </pre> </font></td> <td valign="top" align="left" bgcolor="#ffffff"> <pre><%System.out.println(<font color="red">"aaaaaaaaaaaa"</font>);%> </pre> </td> </tr> </tbody> </table> <br /> <br /> 6.在浏览器中访问: <br /> <br /> http://localhost/a.jsp <br /> <br /> 观察一下控制台Q会在两个窗口控制台轮流打印?aaaaaaaaaaaaQ说明负载均衡Servlet工作正常?<br /> <br /> x一个应用服务器Q再ơ访问,会发现访问正常?<br /> <img src ="http://www.tkk7.com/jelver/aggbug/183449.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2008-03-03 14:11 <a href="http://www.tkk7.com/jelver/articles/183449.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Resin3.1 优化Q{Q?/title><link>http://www.tkk7.com/jelver/articles/183376.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Mon, 03 Mar 2008 01:51:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/183376.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/183376.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/183376.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/183376.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/183376.html</trackback:ping><description><![CDATA[<p>使用resin已经有四、五q了Q但以前都是做一些小pȝQresin的压力ƈ不大Q近D|间做一个大pȝQ日q_ip?0万,resin的压力非常的大,除了对程序做优化以外Qresin 的优化也不了?br />  <br />  <br /> 一、优化配|?br />   修改 conf/resin.conf 文章中的 Q)Q参?br />  <br /> <jvm-arg>-Xms512m</jvm-arg><br /> <jvm-arg>-Xss128k</jvm-arg><br /> <jvm-arg>-Xmn184m</jvm-arg><br /> <jvm-arg>-XX:ParallelGCThreads=20</jvm-arg><br /> <jvm-arg>-XX:+UseConcMarkSweepGC</jvm-arg><br /> <jvm-arg>-XX:+UseParNewGC</jvm-arg><br /> <jvm-arg>-Xdebug</jvm-arg><br /> <jvm-arg>-Xloggc:gc.log</jvm-arg><br />  <br />   修改 最大thread-max?500<br />       <!-- Maximum number of threads. --><br />       <thread-max>2500</thread-max><br />       <!-- Configures the socket timeout --><br />       <socket-timeout>65s</socket-timeout><br />          <br />       <!-- Configures the keepalive --><br />       <keepalive-max>10240</keepalive-max><br />       <keepalive-timeout>30s</keepalive-timeout><br />  <br /> 二、利用resin-admin监控resinq行情况?/p> <p> </p> <div><img alt="" src="http://www.strongd.net/images/b.jpg" /><br /> W一行是Thread pool情况Q如果发现Peak大于thread maxQ就应该修改conf/resin.conf 中的thread-maxQ相应的增大thread-max?br /> W二行是ThreadsQ如果长期出现在q里而又不是QIQ的Ҏ(gu)Q或者resin的方法的话,p对这些方法进行测试、优化?br /> <br /> <br /> <br /> <div>以下内容都是自己不断实验ȝ的,而非resin官方的徏议,可能不适合你的情况Q我的经验仅做ؓ参考。)<br /> 最q发现有人用黑客cdh意点ȝ站,或发送大量垃圑֌Q具体是什么不清楚Q但是很明显是故意的Q造成80端口无法正常讉KQ或讉K速度极慢?br /> 用netstat -an >>c:\temp\aaa.txt 命o查看了当时情况,发现某几个ip的连接数量巨大,是不正常的?br /> 不管是访问量大,q是有黑客骚扎ͼ我想q是试试看把resin优化一下?br /> 首先要在讉K量巨大的时候进行观察?br /> 先将resin.conf文g中的thread-minQthread-maxQthread-keepalive三个参数讄的比较大Q分别写上,1000Q?000Q?000Q当然这是根据你的机器情况和可能同时讉K的数量决定的Q如果你的网站访问量很大的,应该再适当攑֤?br /> 然后观察d理器中的javaU程变化情况Q看看到底是U程辑ֈ多大的时候,javaq程当掉的。我的是?79左右当掉?br /> 然后thread-minQthread-maxQthread-keepalive分别写ؓ150Q?00Q?00Q,也就是将当掉的时候的最大值稍微放大点Q作为thread-max的|因ؓ该系l一般不会超q这个倹{然后其他两个参数根据情况设|一下?br /> q只是我的估计|Ҏ(gu)机器性能和访问量不同Q应该有所不同?br /> 然后accept-buffer-sizeD|的较大Q我讄?0000以上Q这样可以让java能用到更多的内存资源?br /> q样的设|基本上能够满resin的正常运行,当掉resin服务的情况大大减,本设|适合于中型|站?nbsp;</div> <div> <table cellspacing="0" cellpadding="5" width="100%" border="0"> <tbody> <tr class="section"> <td><font color="#336699" size="+2"><strong><a name="Resin-Threads">Resin Threads</a></strong></font></td> </tr> </tbody> </table> <p>Resin will automatically allocate and free threads as the load requires. Since the threads are pooled, Resin can reuse old threads without the performance penalty of creating and destroying the threads. When the load drops, Resin will slowly decrease the number of threads in the pool until is matches the load.</p> <p>Most users can set <span id="nzpmoee" class="meta">thread-max</span> to something large (200 or greater) and then forget about the threading. Some ISPs dedicate a JVM per user and have many JVMs on the same machine. In that case, it may make sense to reduce the <span id="ovvpgke" class="meta">thread-max</span> to throttle the requests.</p> <p>Since each servlet request gets its own thread, <span id="ywntzfl" class="meta">thread-max</span> determines the maximum number of concurrent users. So if you have a peak of 100 users with slow modems downloading a large file, you'll need a <span id="psqdcpw" class="meta">thread-max</span> of at least 100. The number of concurrent users is unrelated to the number of active sessions. Unless the user is actively downloading, he doesn't need a thread (except for "keepalives"). </p> <p> <table cellspacing="0" cellpadding="5" width="100%" border="0"> <tbody> <tr class="section"> <td><font color="#336699" size="+2"><strong><a name="Keepalives">Keepalives</a></strong></font></td> </tr> </tbody> </table> <p>Keepalives make HTTP and srun requests more efficient. Connecting to a TCP server is relatively expensive. The client and server need to send several packets back and forth to establish the connection before the first data can go through. HTTP/1.1 introduced a protocol to keep the connection open for more requests. The srun protocol between Resin and the web server plugin also uses keepalives. By keeping the connection open for following requests, Resin can improve performance. </p> <p> <table class="egpad" cellspacing="0" width="90%"> <caption><font size="+1">resin.conf for thread-keepalive</font> </caption> <tbody> <tr> <td class="example" bgcolor="#ffeecc"> <pre><resin ...> <thread-pool> <thread-max>250</thread-max> </thread-pool> <server> <keepalive-max>500</keepalive-max> <keepalive-timeout>120s</keepalive-timeout> ... </pre> </td> </tr> </tbody> </table> <h3><a name="Timeouts"><font color="#336699">Timeouts</font></a></h3> <p>Requests and keepalive connections can only be idle for a limited time before Resin closes them. Each connection has a read timeout, <span id="drfpdcn" class="meta">request-timeout</span>. If the client doesn't send a request within the timeout, Resin will close the TCP socket. The timeout prevents idle clients from hogging Resin resources.</p> <p> <table class="egpad" cellspacing="0" width="90%"> <tbody> <tr> <td class="example" bgcolor="#ffeecc"> <pre>... <thread-pool> <thread-max>250</thread-max> </thread-pool> <server> <http port="8080" read-timeout="30s" write-timeout="30s"/> ... </pre> </td> </tr> </tbody> </table> <p> <table class="egpad" cellspacing="0" width="90%"> <tbody> <tr> <td class="example" bgcolor="#ffeecc"> <pre>... <thread-max>250</thread-max> <server> <cluster> <client-live-time>20s</client-live-time> <srun id="a" port="6802" read-timeout="30s"/> </cluster> ... </pre> </td> </tr> </tbody> </table> <p>In general, the read-timeout and keepalives are less important for Resin standalone configurations than Apache/IIS/srun configurations. Very heavy traffic sites may want to reduce the timeout for Resin standalone.</p> <p>Since <span id="lctsuth" class="meta">read-timeout</span> will close srun connections, its setting needs to take into consideration the <span id="navrorj" class="meta">client-live-time</span> setting for mod_caucho or isapi_srun. <span id="myijtld" class="meta">client-live-time</span> is the time the plugin will keep a connection open. <span id="knezjxs" class="meta">read-timeout</span> must always be larger than <span id="admvidv" class="meta">client-live-time</span>, otherwise the plugin will try to reuse a closed socket.</p> <h3><a name="Plugin-keepalives-(mod_caucho/isapi_srun)"><font color="#336699">Plugin keepalives (mod_caucho/isapi_srun)</font></a></h3> <p>The web server plugin, mod_caucho, needs configuration for its keepalive handling because requests are handled differently in the web server. Until the web server sends a request to Resin, it can't tell if Resin has closed the other end of the socket. If the JVM has restarted or if closed the socket because of <span id="xqhntzy" class="meta">read-timeout</span>, mod_caucho will not know about the closed socket. So mod_caucho needs to know how long to consider a connection reusable before closing it. <span id="yidfvfh" class="meta">client-live-time</span> tells the plugin how long it should consider a socket usable.</p> <p>Because the plugin isn't signalled when Resin closes the socket, the socket will remain half-closed until the next web server request. A <span id="iojwcql" class="meta">netstat</span> will show that as a bunch of sockets in the FIN_WAIT_2 state. With Apache, there doesn't appear to be a good way around this. If these become a problem, you can increase <span id="lkbgmsy" class="meta">read-timeout</span> and <span id="plrqkjs" class="meta">client-live-time</span> so the JVM won't close the keepalive connections as fast.</p> <p> <table class="egpad" cellspacing="0" width="90%"> <tbody> <tr> <td class="example" bgcolor="#ffeecc"> <pre>unix> netstat ... localhost.32823 localhost.6802 32768 0 32768 0 CLOSE_WAIT localhost.6802 localhost.32823 32768 0 32768 0 FIN_WAIT_2 localhost.32824 localhost.6802 32768 0 32768 0 CLOSE_WAIT localhost.6802 localhost.32824 32768 0 32768 0 FIN_WAIT_2 ... </pre> </td> </tr> </tbody> </table> <h3><a name="TCP-limits-(TIME_WAIT)"><font color="#336699">TCP limits (TIME_WAIT)</font></a></h3> <p>A client and a server that open a large number of TCP connections can run into operating system/TCP limits. If mod_caucho isn't configured properly, it can use too many connections to Resin. When the limit is reached, mod_caucho will report "can't connect" errors until a timeout is reached. Load testing or benchmarking can run into the same limits, causing apparent connection failures even though the Resin process is running fine.</p> <p>The TCP limit is the TIME_WAIT timeout. When the TCP socket closes, the side starting the close puts the socket into the TIME_WAIT state. A <span id="hdcmhrq" class="meta">netstat</span> will short the sockets in the TIME_WAIT state. The following shows an example of the TIME_WAIT sockets generated while benchmarking. Each client connection has a unique ephemeral port and the server always uses its public port:</p> <p> <table class="egpad" cellspacing="0" width="90%"> <caption><font size="+1">Typical Benchmarking Netstat</font> </caption> <tbody> <tr> <td class="example" bgcolor="#ffeecc"> <pre>unix> netstat ... tcp 0 0 localhost:25033 localhost:8080 TIME_WAIT tcp 0 0 localhost:25032 localhost:8080 TIME_WAIT tcp 0 0 localhost:25031 localhost:8080 TIME_WAIT tcp 0 0 localhost:25030 localhost:8080 TIME_WAIT tcp 0 0 localhost:25029 localhost:8080 TIME_WAIT tcp 0 0 localhost:25028 localhost:8080 TIME_WAIT ... </pre> </td> </tr> </tbody> </table> <p>The socket will remain in the TIME_WAIT state for a system-dependent time, generally 120 seconds, but usually configurable. Since there are less than 32k ephemeral socket available to the client, the client will eventually run out and start seeing connection failures. On some operating systems, including RedHat Linux, the default limit is only 4k sockets. The full 32k sockets with a 120 second timeout limits the number of connections to about 250 connections per second.</p> <p>If mod_caucho or isapi_srun are misconfigured, they can use too many connections and run into the TIME_WAIT limits. Using keepalives effectively avoids this problem. Since keepalive connections are reused, they won't go into the TIME_WAIT state until they're finally closed. A site can maximize the keepalives by setting <span id="tlnpjij" class="meta">thread-keepalive</span> large and setting <span id="cbpvfez" class="meta">live-time</span> and <span id="cbscxsk" class="meta">request-timeout</span> to large values. <span id="dnxdcdr" class="meta">thread-keepalive</span> limits the maximum number of keepalive connections. <span id="vjivbwg" class="meta">live-time</span> and <span id="qihyeog" class="meta">request-timeout</span> will configure how long the connection will be reused.</p> <p> <table class="egpad" cellspacing="0" width="90%"> <caption><font size="+1">Configuration for a medium-loaded Apache</font> </caption> <tbody> <tr> <td class="example" bgcolor="#ffeecc"> <pre>... <thread-pool> <thread-max>250</thread-max> </thread-pool> <server> <keepalive-max>250</keepalive-max> <keepalive-timeout>120s</keepalive-timeout> <cluster> <client-live-time>120s</client-live-time> <srun id="a" port="6802" read-timeout="120s"/> </cluster> ... </pre> </td> </tr> </tbody> </table> <p><span id="zbwctdf" class="meta">read-timeout</span> must always be larger than <span id="zyvurqd" class="meta">client-live-time</span>. In addition, <span id="gfdyofo" class="meta">keepalive-max</span> should be larger than the maximum number of Apache processes.</p> <h3><a name="Apache-1.3-issues"><font color="#336699">Apache 1.3 issues</font></a></h3> <p>Using Apache as a web server on Unix introduces a number of issues because Apache uses a process model instead of a threading model. The Apache processes don't share the keepalive srun connections. Each process has its own connection to Resin. In contrast, IIS uses a threaded model so it can share Resin connections between the threads. The Apache process model means Apache needs more connections to Resin than a threaded model would.</p> <p>In other words, the keepalive and TIME_WAIT issues mentioned above are particularly important for Apache web servers. It's a good idea to use <span id="pwzullb" class="meta">netstat</span> to check that a loaded Apache web server isn't running out of keepalive connections and running into TIME_WAIT problems.</p> <p> </p> <p><br /> 先将resin.conf文g中的thread-minQthread-maxQthread-keepalive三个参数讄的比较大Q分别写上,1000Q?000Q?000Q当然这是根据你的机器情况和可能同时讉K的数量决定的Q如果你的网站访问量很大的,应该再适当攑֤?br /> 然后观察d理器中的javaU程变化情况Q看看到底是U程辑ֈ多大的时候,javaq程当掉的。我的是?79左右当掉?br /> 然后thread-minQthread-maxQthread-keepalive分别写ؓ150Q?00Q?00Q,也就是将当掉的时候的最大值稍微放大点Q作为thread-max的|因ؓ该系l一般不会超q这个倹{然后其他两个参数根据情况设|一下?br /> q只是我的估计|Ҏ(gu)机器性能和访问量不同Q应该有所不同?br /> 然后accept-buffer-sizeD|的较大Q我讄?0000以上Q这样可以让java能用到更多的内存资源?br /> q样的设|基本上能够满resin的正常运行,当掉resin服务的情况大大减,本设|适合于中型|站?/p> <p>Resin优化Q?<br /> <br /> The allocation of memory for the JVM is specified using -X options when starting Resin <br /> <br /> (the exact options may depend upon the JVM that you are using, the examples here are for the Sun JVM). <br /> <br /> JVM option passed to Resin Meaning <br /> -Xms initial java heap size <br /> -Xmx maximum java heap size <br /> -Xmn the size of the heap for the young generation <br /> <br /> Resin startup with heap memory options unix> bin/httpd.sh -Xmn100M -Xms500M -Xmx500M win> bin/httpd.exe -Xmn100M -Xms500M -Xmx500M install win service> bin/httpd.exe -Xmn100M -Xms500M -Xmx500M -install <br /> <br /> 原文Qhttp://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp <br /> <br /> <br /> JVM 优化Q?<br /> <br /> java -Xms<size> <br /> set initial Java heap size. default:Xms32m <br /> java -Xmx<size> <br /> set maximum Java heap size. default:Xmx128m <br /> <br /> set it like that: <br /> <br /> java -Xms=32m -Xmx=256m <br /> If the problem persist, increase Xmx more than 256 ( 512m for example ) <br /> <br /> -J-mx<num> </p> <p> </p> <p><span id="oyedrxh" class="javascript" id="text174266">Resin启动旉过bin目录下的wrapper.pl文gq行控制Q我们可以修改这个文件来加一些参敎ͼ比如要加入Java?Xms?Xmx参数 <br /> <br /> q行 <br /> vi /usr/local/resin-2.1/bin/wrapper.pl <br /> 扑ֈq修改以下这行ؓQ?<br /> $JAVA_ARGS="-Xms512m -Xmx512m"; <br /> <br /> 具体参数h据自q应用q行调节 </span><br /> <br /> </p> <div id="xpvkulv" class="tit">Resin的优?--日志的设|?/div> <div id="ubhnpzr" class="date">2007q?3?6?星期?10:25</div> <p> <table style="table-layout: fixed"> <tbody> <tr> <td> <div id="lcbouxd" class="cnt"> <p>log讄 <br /> <log name='' level='info' path='stdout:' rollover-period='1W' timestamp='[%Y/%m/%d %H:%M:%S.%s] '/> <br /> <log name='com.caucho.java' level='fine' path='stdout:' rollover-period='1W' timestamp='[%Y/%m/%d %H:%M:%S.%s] '/> <br /> <log name='com.caucho.loader' level='config' path='stdout:' rollover-period='1W' timestamp='[%Y/%m/%d %H:%M:%S.%s] '/> </p> <p>name 是指定对各个层次应用q行debugQname 讑֮有几U情况,如: <br /> Name=’’ name为空Q这Ҏ(gu)有应用、包括端口全面进行调试记载日?nbsp;<br /> Name=’com.caucho.jsp’ 指定只对jspq行调试记蝲日志 <br /> Name=’com.caucho.java’ 指定只对javac进行调?nbsp;<br /> Name=’com.caucho.server.port’ 指定只对端口、线E进行调?nbsp;<br /> Name=’com.caucho.server.port.AcceptPool 指定只对端口U程的创建和释放q行debug <br /> …. </p> <p>level 的别一般有Q? <br /> Off Severe info config fine finer finest all q几中配|别; <br /> Off 关闭日志输出 <br /> Severe 只输Z严重的出错信?nbsp;<br /> Info 输出一般的l合信息 <br /> Config 输出配置信息 <br /> Fine 输出resin的跟t信?nbsp;<br /> Finer 输出详细的跟t信?nbsp;<br /> Finest 输出比Finer更详l的跟踪消息、细节问?nbsp;<br /> All 输出所有的讉K输出消息 </p> <p>pathQ?nbsp;输出文g路径指向,可以形式?nbsp;path=’stdout:’ 注意后面有冒P或指定绝对\径path=’/usr/local/resin-3.0.7/log/stdout.log’ <br /> Timestamp : 完整的输出日期格式[%Y/%m/%d %H:%M:%S.%s]Q?nbsp;</p> <p>一般设|日志文件一周轮循一??nbsp;rollover-period=’1M’ ?nbsp;rollover-period=’7D’ , 当满一?pȝ会自动生成新日志记录文g,格式? stderr.log.20041201 stderr.log.20041208 <br /> rollover-period=’D’ ?nbsp;<br /> rollover-period=’h’ 时 <br /> rollover-period=’W’ ?nbsp;<br /> rollover-period=’M’ ?nbsp;</p> </div> </td> </tr> </tbody> </table> </p> <p><span id="xkqzjtd" class="javascript" id="text174282">当不需要改动程序时,关闭java自动~译会更快些.<br /> <br /> <compiling-loader path="webapps/WEB-INF/classes" /><br /> 加个属?br /> batch="false"</span></p> </div> <p> </p> <p><span id="fbkmhgb" class="javascript"><span id="dvbwgki" class="javascript" id="text174537">$JAVA_ARGS="-server";<br /> <br /> 据说java中的-server参数是让本地化编译更完全. </span><br /> </span></p> <br /> </div> <img src ="http://www.tkk7.com/jelver/aggbug/183376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2008-03-03 09:51 <a href="http://www.tkk7.com/jelver/articles/183376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Resin 3.1.2分析pȝ性能瓉Q{Q?/title><link>http://www.tkk7.com/jelver/articles/183349.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Mon, 03 Mar 2008 00:52:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/183349.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/183349.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/183349.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/183349.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/183349.html</trackback:ping><description><![CDATA[<table cellspacing="0" cellpadding="3" width="100%" border="0"> <tbody> <tr> <td align="left"><a ><br /> <img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=image%2Fgif&attachment=1309" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >resin-performance-ans-1.gif</a>(5.0 K)</td> </tr> <tr> <td align="left"><a ><img alt="附g" src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&contentType=image%2Fgif&attachment=1310" border="0" /></a></td> </tr> <tr> <td align="left" width="99%"><a >cpu-use.gif</a>(11.1 K)</td> </tr> <tr> <td style="border-top: #ccc 1px solid" colspan="2"> </td> </tr> </tbody> </table> <a >切换到灯片模式</a><br /> <br /> <!--attachment end-->q两天发现blogpȝ讉K响应变慢Q经分析发现服务器CPU接近100%Q而且降不下来Q经分析应该是有大量cM循环的操作导致?<br /> <br /> 采用Resin 3.1.2Q打开后台的Threads监控面Q如附gQ,讉K前台面Q多h几次Q在后台再刷新Threads面Q如果其中的Active中含有非Resin或Jdk的方法,说明该方法存在严重的性能问题一直处于执行状态而不能结束,特别是如果是你自己写的方法?<br /> <br /> l此Ҏ(gu)查,anotherbug发现当前Active的线E中l常停留在一个方法,于是该Ҏ(gu)暂时用Q再重启Resinq行跟踪Q发现Active不再出现该方法?<br /> <br /> 附g是Resin的Active的界面Q还有优化后的CPU使用情况Q几乎ؓ0Q?<br /> http://anotherbug.blog.chinajavaworld.com/entry/2938/0/<br /> <img src ="http://www.tkk7.com/jelver/aggbug/183349.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2008-03-03 08:52 <a href="http://www.tkk7.com/jelver/articles/183349.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Resin 3 pro高ƈ?响应性与E_性方??http://www.tkk7.com/jelver/articles/183345.html都市淘沙?/dc:creator>都市淘沙?/author>Mon, 03 Mar 2008 00:47:00 GMThttp://www.tkk7.com/jelver/articles/183345.htmlhttp://www.tkk7.com/jelver/comments/183345.htmlhttp://www.tkk7.com/jelver/articles/183345.html#Feedback0http://www.tkk7.com/jelver/comments/commentRss/183345.htmlhttp://www.tkk7.com/jelver/services/trackbacks/183345.html
resin版本为resin-pro-3.0.21QJVM为Jrockit 1.5_06Q?resin java 启动参数 -Xms256m -Xmx512m

1. 以下为resin.conf配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!--
            - Resin 3.0 configuration file.
            -->
            <resin xmlns="http://caucho.com/ns/resin"
            xmlns:resin="http://caucho.com/ns/resin/core">
            <!--
            - Logging configuration for the JDK logging API.
            -->
            <log name="" level="all" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
             
            <logger name="com.caucho.java" level="config"/>
            <logger name="com.caucho.loader" level="config"/>
             
            <dependency-check-interval>600s</dependency-check-interval>
             
            <javac compiler="internal" args=""/>
             
            <thread-pool>
            <thread-max>10240</thread-max>
            <spare-thread-min>50</spare-thread-min>
            </thread-pool>
             
            <min-free-memory>5M</min-free-memory>
             
            <server>
            <class-loader>
            <tree-loader path="${resin.home}/lib"/>
            <tree-loader path="${server.root}/lib"/>
            </class-loader>
             
            <keepalive-max>1024</keepalive-max>
            <keepalive-timeout>60s</keepalive-timeout>
             
            <resin:if test="${resin.isProfessional()}">
            <select-manager enable="true"/>
            </resin:if>
             
            <bind-ports-after-start/>
             
            <http server-id="" host="*" port="80"/>
             
            <cluster>
            <srun server-id="" host="127.0.0.1" port="6802"/>
            </cluster>
             
            <resin:if test="${resin.isProfessional()}">
            <persistent-store type="cluster">
            <init path="session"/>
            </persistent-store>
            </resin:if>
             
            <ignore-client-disconnect>true</ignore-client-disconnect>
             
            <resin:if test="${isResinProfessional}">
            <cache path="cache" memory-size="20M"/>
            </resin:if>
             
            <web-app-default>
            <class-loader>
            <tree-loader path="${server.root}/ext-webapp"/>
            </class-loader>
             
            <cache-mapping url-pattern="/" expires="60s"/>
            <cache-mapping url-pattern="*.gif" expires="600s"/>
            <cache-mapping url-pattern="*.jpg" expires="600s"/>
             
            <servlet servlet-name="directory"
            servlet-class="com.caucho.servlets.DirectoryServlet">
            <init enable="false"/>
            </servlet>
             
            <allow-servlet-el/>
             
            <session-config>
            <enable-url-rewriting>false</enable-url-rewriting>
            </session-config>
             
            </web-app-default>
             
            <host-default>
            <class-loader>
            <compiling-loader path="webapps/WEB-INF/classes"/>
            <library-loader path="webapps/WEB-INF/lib"/>
            </class-loader>
             
            <!--access-log path="logs/access.log"
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
            rollover-period="1W"/-->
             
            <web-app-deploy path="webapps"/>
             
            <ear-deploy path="deploy">
            <ear-default>
            <!-- Configure this for the ejb server
            -
            - <ejb-server>
            -   <config-directory>WEB-INF</config-directory>
            -   <data-source>jdbc/test</data-source>
            - </ejb-server>
            -->
            </ear-default>
            </ear-deploy>
             
            <resource-deploy path="deploy"/>
             
            <web-app-deploy path="deploy"/>
            </host-default>
             
            <resin:import path="${resin.home}/conf/app-default.xml"/>
             
            <host-deploy path="hosts">
            <host-default>
            <resin:import path="host.xml" optional="true"/>
            </host-default>
            </host-deploy>
             
            <host id="" root-directory=".">
            <web-app id="/" document-directory="d:\website\chat">
            </web-app>
            </host>
            </server>
            </resin>
             
            


2. 在应用的web.xml中加入resin status查看servlet映射

1
2
3
4
      <servlet-mapping servlet-class='com.caucho.servlets.ResinStatusServlet'>
            <url-pattern>/resin-status</url-pattern>
            <init enable="read"/>
            </servlet-mapping>
            


3. 启动resinQ确认应用正常启动?

4. 写访问测试程?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.io.InputStream;
            import java.net.URL;
             
             
            public class TestURL
            {
            public static void main(String[] args) throws Exception
            {
            long a = System.currentTimeMillis();
            System.out.println("Starting request url:");
            for(int i = 0; i < 10000; i++){
            URL url = new URL("http://192.168.1.200/main.jsp");
             
            InputStream is = url.openStream();
            is.close();
            System.out.println("Starting request url:"+i);
            }
            System.out.println("request url end.take "+(System.currentTimeMillis()-a)+"ms");
            }
             
            }
            


5. 在Jbuilder中执行TestURL

在执行过E中Q一边刷新http://192.168.1.200/resin-statusQ查看resin状?在http://*:80 中的 Active Threads ?TotalQ会一直增长,当长?12的时候不再增长,q时再刷新resin-status面Ӟ会发现打开很慢。原因是服务器已l达到最大连接数Q在{待前面q接的释放而不能接受新的连接?

于是下蝲Resin 3.0.21源码Q搜?512Q发现com.caucho.server.port.PortcM有以下代码:
1
2
3
4
5
6
7
8
9
10
  // default timeout
            private long _timeout = 65000L;
             
            private int _connectionMax = 512;//是q行Q查找resin所有源码后Q发现没有对q个D行设|?/font>
            private int _minSpareConnection = 16;
             
            private int _keepaliveMax = -1;
             
            private int _minSpareListen = 5;
            private int _maxSpareListen = 10;
            

_connectionMax 改ؓ 20480Q然后重新编译ƈ替换resin.jar中的PortcR?

6. 重新启动ResinQ再ơ运行TestURLq行试Q这ơ你会发现Threads Active ?Total 一直变大,且可以超q?12一直增大,在测试程序运行过E中h面Q页面响应性能q是不错?

另,试q程中Resin会打印出 1-3?强制执行GC的信息,属于正常?

7.待测试完毕,Threads Active ?Total 马上降ؓ1.Idle?Qd存ؓ536.87Meg I闲内存?80.33M

再经多次试Q结果一_内存回收正常Q表明当?resin E_性和响应性可靠?

]]>
Resin服务器安装配|手?Windows and Linux) Q{Q?/title><link>http://www.tkk7.com/jelver/articles/162397.html</link><dc:creator>都市淘沙?/dc:creator><author>都市淘沙?/author><pubDate>Thu, 22 Nov 2007 08:10:00 GMT</pubDate><guid>http://www.tkk7.com/jelver/articles/162397.html</guid><wfw:comment>http://www.tkk7.com/jelver/comments/162397.html</wfw:comment><comments>http://www.tkk7.com/jelver/articles/162397.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jelver/comments/commentRss/162397.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jelver/services/trackbacks/162397.html</trackback:ping><description><![CDATA[<p style="margin: 0cm 0cm 0pt"><font size="3"><strong><font face="Times New Roman">Resin服务器安装配|手?Windows and Linux)   <script src="http://blog.csdn.net/count.aspx?ID=773723&Type=Rank"></script><br /> http://blog.csdn.net/zynovo/archive/2006/06/05/773723.aspx<br /> 一、Windows</font><span style="font-family: 宋体">?/span><font face="Times New Roman">resin</font><span style="font-family: 宋体">的安装以及配|?/span></strong></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><strong><font face="Times New Roman">1 </font><span style="font-family: 宋体">、安?/span></strong></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><font face="Times New Roman">1</font><span style="font-family: 宋体">Q?/span><span style="font-family: 宋体">安装?/span><font face="Times New Roman">JDK</font></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><font face="Times New Roman">2</font><span style="font-family: 宋体">Q?/span><span style="font-family: 宋体">?/span><font face="Times New Roman">resin-3.0.x.zip</font><span style="font-family: 宋体">解压~?/span></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><font face="Times New Roman">3</font><span style="font-family: 宋体">Q?/span><span style="font-family: 宋体">q行</span><font face="Times New Roman">resin-3.0.x/httpd.exe</font></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><font face="Times New Roman">4</font><span style="font-family: 宋体">Q?/span><span style="font-family: 宋体">打开</span><font face="Times New Roman">http://localhost:8080</font><span style="font-family: 宋体">查看试面</span></font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><font size="3">如果正确打开Q窗口会昄如下信息Q?/font></span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"win32> resin-3.0.0"bin"httpd</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">Resin 3.0.0-beta (built Thu Feb 13 18:21:13 PST 2003)</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">Copyright(c) 1998-2002 Caucho Technology. All rights reserved.</font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><font face="Times New Roman">Starting Resin on Sat</font><span style="font-family: 宋体">Q?/span><font face="Times New Roman"> 01 Mar 2003 19:11:52 -0500 (EST)</font></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">[19:11:56.479] ServletServer[] starting</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">[19:11:57.000] Host[] starting</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">[19:11:58.312] Application[http://localhost:8080/doc] starting</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">[19:12:11.872] Application[http://localhost:8080/quercus] starting</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">...</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">[19:12:12.803]http listening to *:8080</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">[19:12:12.933]hmux listening to *:6802</font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><strong><font face="Times New Roman">2</font><span style="font-family: 宋体">、配|?/span></strong></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体">部v?/span><font face="Times New Roman">Windows</font><span style="font-family: 宋体">下的服务Q?/span></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">The Resin Web Server can be installed as an Windows service.</font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><font face="Times New Roman">Resin</font><span style="font-family: 宋体">服务器可以被安装成ؓ</span><font face="Times New Roman">Windows</font><span style="font-family: 宋体">的服?/span></font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体">要安装ؓ</span><font face="Times New Roman">Windows</font><span style="font-family: 宋体">的服务,可以用下面的命o</span></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> resin-3.0.x"bin"httpd -install -conf conf/myconf.conf</font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体">q样</span><font face="Times New Roman">Resin</font><span style="font-family: 宋体">׃作ؓ服务随着机器的启动而自动开启?/span></font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><font size="3">要想U除此服?/font></span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> resin-3.0.x"bin"httpd -remove</font></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体">你也可以用如下命令开启和关闭</span><font face="Times New Roman">Resin</font><span style="font-family: 宋体">的服务:</span></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> net start resin</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">...</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> net stop resin</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><font size="3">多服务v配置Q?/font></span></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体">使用参数</span><font face="Times New Roman"> -install-as foo</font><span style="font-family: 宋体">来指定一个特定的服务?/span></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> resin-3.0.x"bin"httpd -install-as ResinA -conf conf/myconf.conf</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">-server a</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> net start ResinA</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><font size="3">注意Q?/font></span></p> <p style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体">有一?/span><font face="Times New Roman">JDK</font><span style="font-family: 宋体">存在q样?/span><font face="Times New Roman">Bug</font><span style="font-family: 宋体">Q当理员帐h销以后服务也会随着关闭Q解军_法是在安装的时候用参?/span><span style="font-family: 宋体">–</span><font face="Times New Roman">Xrs:</font></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3">C:"> resin3.0.0/httpd.exe -install –Xrs</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman" size="3"><strong>二、Linux<span style="font-family: 宋体">下resin<span style="font-family: 宋体">的安装以及配|:</span></strong></font></span></p> <p style="margin: 0cm 0cm 0pt"><strong>1<span style="font-family: 宋体">、安?/span></strong></p> <p style="margin: 0cm 0cm 0pt">1<span style="font-family: 宋体">Q?/span> <span style="font-family: 宋体">安装</span> JDK 1.4 </p> <p style="margin: 0cm 0cm 0pt">2Q?<span style="font-family: 宋体">定环境变量</span>JAVA_HOME<span style="font-family: 宋体">讄正确</span></p> <p style="margin: 0cm 0cm 0pt">3Q?<span style="font-family: 宋体">安装</span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">单独q行Q?/span></p> <p style="margin: 0cm 0cm 0pt"># tar zxvf resin-3.0.4.tar.gz </p> <p style="margin: 0cm 0cm 0pt"># mv resin03.0.6 /usr/local/resin</p> <p style="margin: 0cm 0cm 0pt">#cd /usr/local/resin</p> <p style="margin: 0cm 0cm 0pt"># ./configure </p> <p style="margin: 0cm 0cm 0pt"># make </p> <p style="margin: 0cm 0cm 0pt"># make install</p> <p style="margin: 0cm 0cm 0pt">#cd bin</p> <p style="margin: 0cm 0cm 0pt">#./httpd.sh start</p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><strong>自动启动Q?/strong></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">?/span>/etc/rc.d/rc.local<span style="font-family: 宋体">中加入如下语句:</span></p> <p style="margin: 0cm 0cm 0pt">/usr/local/resin/bin/httpd.sh start</p> <p style="margin: 0cm 0cm 0pt"><strong><span style="font-family: 宋体">?/span>Apache<span style="font-family: 宋体">整合Q?/span></strong></p> <p style="margin: 0cm 0cm 0pt">1QApache<span style="font-family: 宋体">安装</span><br /> # tar zxvf httpd-2.49.tar.gz <br /> # cd httpd-2.49 <br /> # ./configure --prefix=/usr/local/httpd --enable-modules=so --enable-so <br /> --prefix<br /> --enable-modules<span style="font-family: 宋体">用来指定pȝ允许使用的功能扩展模块的cdQ这里指定ؓ</span>so<span style="font-family: 宋体">cd?/span><br /> --enabel-so <span style="font-family: 宋体">用来指定允许使用</span>DSO<span style="font-family: 宋体">Q?/span>Dynamic Share Object<span style="font-family: 宋体">动态共享对象)?/span><br /> # make <br /> # make install<br /> <span style="font-family: 宋体">讄</span>apache<span style="font-family: 宋体">自动启动Q?/span><br /> <span style="font-family: 宋体">?/span>Apache<span style="font-family: 宋体">的启动文?/span>apachectl<span style="font-family: 宋体">写入</span>rc.local<span style="font-family: 宋体">?/span><br /> /usr/local/httpd/bin/apachectl start</p> <p style="margin: 0cm 0cm 0pt">2QResin<span style="font-family: 宋体">安装</span></p> <p style="margin: 0cm 0cm 0pt"># tar zxvf resin-3.0.4.tar.gz <br /> # cd resin-3.0.4 <br /> # ./configure --prefix=/usr/local/resin --with-apache=/usr/local/httpd <br /> # make <br /> # make install<br /> <span style="font-family: 宋体">此时已经生成</span>Resin<span style="font-family: 宋体">q接</span>Apache2<span style="font-family: 宋体">?/span>.so<span style="font-family: 宋体">文g了,其存在与</span>$APACHE_HOMEe/modules/mod_caucho.so</p> <p style="margin: 0cm 0cm 0pt">conf/httpd.conf<span style="font-family: 宋体">中就会多Z下语句:</span></p> <p style="margin: 0cm 0cm 0pt">LoadModule caucho_modules modules/mod_caucho.so    <br />  ResinConfigServer localhost 6802     </p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10.5pt; font-family: 宋体">分别先后启动</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'">Resin</span><span style="font-size: 10.5pt; font-family: 宋体">?/span><span style="font-size: 10.5pt; font-family: 'Times New Roman'">Apache <br /> </span><span style="font-size: 10.5pt; font-family: 宋体">讉K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'">http://hostname/caucho-status </span><span style="font-size: 10.5pt; font-family: 宋体">可以看到</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'">Resin</span><span style="font-size: 10.5pt; font-family: 宋体">的状态页?/span></p> <span style="font-size: 10.5pt; font-family: 宋体"> <p style="margin: 0cm 0cm 0pt"><strong><font face="Times New Roman">2 </font><span style="font-family: 宋体">、配|?/span></strong></p> <p style="margin: 0cm 0cm 0pt"><strong><font face="Times New Roman">1</font><span style="font-family: 宋体">Q?/span><font face="Times New Roman">linux</font><span style="font-family: 宋体">下?/span><font face="Times New Roman">resin</font><span style="font-family: 宋体">的单服务器配|?/span></strong></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">使用单服务器Ҏ(gu)Q只要安装完毕,配置一?/span><font face="Times New Roman">Resin</font><span style="font-family: 宋体">?/span><font face="Times New Roman">resin.conf</font><span style="font-family: 宋体">文g?/span><font face="Times New Roman">app_default.xml</font><span style="font-family: 宋体">文g可以了Q?/span><font face="Times New Roman">resin.conf</font><span style="font-family: 宋体">文g中需要配|两处,一是端口号Q另一处是</span><font face="Times New Roman">Web</font><span style="font-family: 宋体">E序存放目录Q?/span><font face="Times New Roman">app_default.xml</font><span style="font-family: 宋体">内可配置默认首页的搜索顺序。由于原|站使用多个端口配置Q所以单服务器只能用于做单个站点的测试用?/span></p> <p style="margin: 0cm 0cm 0pt"><strong><font face="Times New Roman">2</font><span style="font-family: 宋体">Q?/span><font face="Times New Roman">linux</font><span style="font-family: 宋体">下?/span><font face="Times New Roman">resin</font><span style="font-family: 宋体">的多服务器配|以及多实例开动运行的配置</span></strong></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       </font><span style="font-family: 宋体">有时候需要运行多个服务器以在同一个テQC监听多个端口Q这时候就需要用单独的</span><font face="Times New Roman">Resin</font><span style="font-family: 宋体">服务器运行多个实例,以监听多个端口来部v多个</span><font face="Times New Roman">Web</font><span style="font-family: 宋体">站点?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">可以有如下两U配|方法:</span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><strong><em>W一U方法:</em></strong></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">q种Ҏ(gu)为多ơ?/span><font face="Times New Roman">httpd.sh</font><span style="font-family: 宋体">的参数指定配|文件和q行时的</span><font face="Times New Roman">pid</font><span style="font-family: 宋体">文gQ实现多个实例的q行?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">使用的命令行如下所C:</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">$RESIN_HOME/bin/httpd.sh -conf conf/resin1.conf -pid resin1.pid start</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">解释Q?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       -conf </font><span style="font-family: 宋体">选项为选择此服务器实例所用的配置文gQ在q个文g里面配置不同的端口和ȝ录?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">-pid </font><span style="font-family: 宋体">q程</span><font face="Times New Roman">id</font><span style="font-family: 宋体">及所?/span><font face="Times New Roman">pid</font><span style="font-family: 宋体">文g?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       start</font><span style="font-family: 宋体">启动?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">用以上命令,在徏立多个服务器配置文g以后可以手工打开多个服务器实例?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">把这些语句加?/span><font face="Times New Roman">/etc/rc.d/rc.local</font><span style="font-family: 宋体">中就可以实现开动启动了?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"><strong><em> </em></strong></font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体"><strong><em>W二U方法:</em></strong></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">q种Ҏ(gu)使用</span><font face="Times New Roman">Chkconfig</font><span style="font-family: 宋体">命o讄多服务器自动启动Q运行于不同</span><span style="font-family: 宋体">pȝq行U别?/span><span style="font-family: 宋体">后台方式。ƈ使他们成为可在图形界面下理的服务?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">讄?/span><font face="Times New Roman">JAVA_HOME</font><span style="font-family: 宋体">环境变量后将</span><font face="Times New Roman">RESIN</font><span style="font-family: 宋体">解包?/span><font face="Times New Roman">/home/resin</font><span style="font-family: 宋体">下,执行~译脚本</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#tar zxf resin-version.tar.gz</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#mv resin-version /home/resin</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#cd /home/resin/</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#./configure</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#make</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#make install</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">?/span><font face="Times New Roman">make install</font><span style="font-family: 宋体">生成?/span><font face="Times New Roman">$RESIN_HOME/contrib/init.resin</font><span style="font-family: 宋体">复制?/span><font face="Times New Roman">/etc/rc.d/init.d/</font><span style="font-family: 宋体">目录下改名ؓ</span><font face="Times New Roman">resinx</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">修改</span><font face="Times New Roman">resin</font><span style="font-family: 宋体">文g的内容(三处Q?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">Q?/span><font face="Times New Roman">1</font><span style="font-family: 宋体">Q?/span><font face="Times New Roman">JAVA</font><span style="font-family: 宋体">环境讄</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       </font><span style="font-family: 宋体">扑ֈ以下代码D?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       JAVA_HOME=/usr/java</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">RESIN_HOME=/usr/local/resin</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">q修改他们ؓ相应的目录,W一个ؓ</span><font face="Times New Roman">JDK</font><span style="font-family: 宋体">安装ȝ录,W二个ؓ</span><font face="Times New Roman">Resin</font><span style="font-family: 宋体">安{ȝ录?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">Q?/span><font face="Times New Roman">2</font><span style="font-family: 宋体">Q?/span><font face="Times New Roman">PID=$RESIN_HOME/resin.pid</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">修改?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">PID=$RESIN_HOME/resin1.pid</font><span style="font-family: 宋体">Q很清楚Q要不一L</span><font face="Times New Roman">pid</font><span style="font-family: 宋体">Q?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">Q?/span><font face="Times New Roman">3</font><span style="font-family: 宋体">Q、找到程序段</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">start)</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       echo -n "Starting resin: "</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       if test -n "$USER"; then</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       su $USER -c "$EXE -pid $PID start $ARGS"</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       else</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       $EXE -pid $PID start $ARGS</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">        fi</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       echo</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       ;;</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">修改?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">start)</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       echo -n "Starting resin: "</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       if test -n "$USER"; then</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       su $USER -c "$EXE -conf $RESIN_HOME/conf/resin1.conf -pid $PID start $ARGS"</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       else</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       $EXE -conf $RESIN_HOME/conf/resin1.conf -pid $PID start $ARGS</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">        fi</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       echo</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">       ;;</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">其实上面的程序和W一部分是一LQ只是用脚本来运行了?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">最?/span><font face="Times New Roman">chmod +x resin1</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">用上面的Ҏ(gu)拯?/span><font face="Times New Roman">resin2</font><span style="font-family: 宋体">Q?/span><font face="Times New Roman">resin3.....</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">chmod +x resin1</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">chmod +x resin2</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">......</font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">命o为:</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">cp contrib/init.resin /etc/rc.d/init.d/resin1</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">vi /etc/rc.d/init.d/resin1</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">i</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">:wq</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">chmod +x /etc/rc.d/init.d/resin1</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">如此你想q行几个服务器实例创建几个这L文g</span><font face="Times New Roman">(resinx)</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">修改</span><font face="Times New Roman">resin</font><span style="font-family: 宋体">中的一些设|:</span><font face="Times New Roman">JAVA_HOME RESIN_HOME USER</font><span style="font-family: 宋体">{,</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">?/span><font face="Times New Roman">resin</font><span style="font-family: 宋体">服务在不同的启动U中讄成自启动</span><font face="Times New Roman">:</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#/sbin/chkconfig resin1 reset </font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">#/sbin/chkconfig resin2 reset </font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">......</font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">创徏不同的配|文?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">注意每一个配|文件必M持三处不同:</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">(1)srun</font><span style="font-family: 宋体">Q负载^衡配|)部分端口号必M同,用不同的</span><font face="Times New Roman">ip</font><span style="font-family: 宋体">地址也可以?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">在原文g的如下部分:</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"><cluster></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">      <srun server-id="" host="127.0.0.1" port="6802"/></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"></cluster></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">(2)</font><span style="font-family: 宋体">默认L件目录要设ؓ不同Q不然就失去了多个实例的意义Q不然的话还不如用负载^衡来提高性能</span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"><web-app id="/" document-directory="webapps/ROOT"/></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman">(3)</font><span style="font-family: 宋体">服务器的端口号必M同?/span></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"><http server-id="" host="*" port="8080"/></font></p> <p style="margin: 0cm 0cm 0pt"><font face="Times New Roman"> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">q样pȝ启动的时候,</span><font face="Times New Roman">resin</font><span style="font-family: 宋体">׃在后台运行多个实例了Q效果和W一步一栗?/span></span></p> <img src ="http://www.tkk7.com/jelver/aggbug/162397.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jelver/" target="_blank">都市淘沙?/a> 2007-11-22 16:10 <a href="http://www.tkk7.com/jelver/articles/162397.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux下的resin定时重启http://www.tkk7.com/jelver/articles/149647.html都市淘沙?/dc:creator>都市淘沙?/author>Sat, 29 Sep 2007 09:55:00 GMThttp://www.tkk7.com/jelver/articles/149647.htmlhttp://www.tkk7.com/jelver/comments/149647.htmlhttp://www.tkk7.com/jelver/articles/149647.html#Feedback0http://www.tkk7.com/jelver/comments/commentRss/149647.htmlhttp://www.tkk7.com/jelver/services/trackbacks/149647.html   #crontab   -e  
  d如下一行:  
  0   8   *   *   *   /usr/local/resin-3.0.12/bin/httpd.sh   restart  
  表示每天凌晨8点自动重启resin  
   
  此时要注意:  
  resin自动重启时是不读入环境变量的Q!Q? 
  因此我们要在resin的启?nobr oncontextmenu="return false;" onmousemove="kwM(0);" id="key0" onmouseover="kwE(event,0, this);" style="color: #6600ff; border-bottom: #6600ff 1px dotted; background-color: transparent; text-decoration: underline" onclick="return kwC();" onmouseout="kwL(event, this);" target="_blank">文ghttpd.sh中加上环境变量!  
  #vi   httpd.sh  
  注意一定要?!   /bin/sh攑֜文g的第一行,否则无法手动执行httpd.sh文g  
  然后在下面添加如下几行:  
  CLASSPATH=......  
  LANG=......  
  JAVA_HOME=......  
  PATH=......  
  export   CLASSPATH   LANG   JAVA_HOME   PATH  
   
  注意最后一定要export各个变量Q否则无法生? 
  q四个变量的值可以通过q个命oQ? 
  #env  
  来查看当?nobr oncontextmenu="return false;" onmousemove="kwM(2);" id="key2" onmouseover="kwE(event,2, this);" style="color: #6600ff; border-bottom: #6600ff 1px dotted; background-color: transparent; text-decoration: underline" onclick="return kwC();" onmouseout="kwL(event, this);" target="_blank">机器上的配置Q然后拷贝过d可以? 
   
   
  我的blogQhttp://farmerinchina.blog.sohu.com

]]>
JSTL与Resin版本的问题(转)http://www.tkk7.com/jelver/articles/143975.html都市淘沙?/dc:creator>都市淘沙?/author>Mon, 10 Sep 2007 06:12:00 GMThttp://www.tkk7.com/jelver/articles/143975.htmlhttp://www.tkk7.com/jelver/comments/143975.htmlhttp://www.tkk7.com/jelver/articles/143975.html#Feedback0http://www.tkk7.com/jelver/comments/commentRss/143975.htmlhttp://www.tkk7.com/jelver/services/trackbacks/143975.htmlJSTL与Resin版本的问?/a>

JSTL1.0是需要Servlet2.3和JSP1.2的?br /> JSTL1.1是需要Servlet2.4和JSP2.0的?br />  
Resin?.1.2版本开始自己实CJSTL的core和fmt两个TAGLIB?br />  
使用Resin自带的JSTL
不需要拷贝JAR和TLD文gQ也不需要配|web.xml?br /> 只要在页面引用就可以了,注意与标准JSTL1.1的区别?br /> http://java.sun.com/jstl/core
” prefix=”c”%>
http://java.sun.com/jstl/fmt” prefix=”fmt”%>
http://java.sun.com/jsp/jstl/functions” prefix=”fn”%>
 
感觉速度比较快?br /> 如果要禁止自带的JSTLQ需要在Resin的配|文仉讄

 
  …

使用标准的JSTL1.1
需要将JAR包拷贝到WEB-INF/lib目录下,不需要拷贝TLD文gQ不需要配|web.xml?br /> 在页面这样引?br /> http://java.sun.com/jsp/jstl/core” prefix=”c” %>
http://java.sun.com/jsp/jstl/fmt” prefix=”fmt” %>

使用标准的JSTL1.0
需要将JAR包拷贝到WEB-INF/lib目录下,拯需要的TLD文g?br /> 配置web.xml
 
  jstl-c
  /WEB-INF/tld/c.tld
 
 
  jstl-fmt
  /WEB-INF/tld/fmt.tld
 
在页面这样引?/p>

 
如果没有止Resin自带的JSTLQ然后自己又在Resin2.1.16里配|了标准JSTL1.0。结果可能导致fmt失效?/p>



]]>
Resin定时备䆾日志http://www.tkk7.com/jelver/articles/135176.html都市淘沙?/dc:creator>都市淘沙?/author>Wed, 08 Aug 2007 02:35:00 GMThttp://www.tkk7.com/jelver/articles/135176.htmlhttp://www.tkk7.com/jelver/comments/135176.htmlhttp://www.tkk7.com/jelver/articles/135176.html#Feedback0http://www.tkk7.com/jelver/comments/commentRss/135176.htmlhttp://www.tkk7.com/jelver/services/trackbacks/135176.html通过讄resin.conf文g来实现将日志以每日或每周的方式来存放Q以便查看日志信息,
具体操作很简单,只需要参看红色字体位|的说明讄卛_Q共两处Q?br>
<!--
   - Resin 3.0 configuration file.
  -->
<resin xmlns="       xmlns:resin="  <!--
     - Logging configuration for the JDK logging API.
    -->
  <log name="" level="info" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
  <log name="com.caucho.java" level="config" path="stdout:"
       timestamp="[%H:%M:%S.%s] "/>
  <log name="com.caucho.loader" level="config" path="stdout:"
       timestamp="[%H:%M:%S.%s] "/>

<!--备䆾每日日志Qƈ且压~ؓ.gz格式文g减少占用定wQ如果一周备份一ơ则需要将“1D”改ؓ“1W”-->
<log name="" level="info" path="log/stdout.log" timestamp="[%H:%M:%S.%s] "
     archive-format="stdout.log.%Y-%m-%d.gz"
     rollover-period="1D"/>


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

  <!--
     - You can change the compiler to "javac" or jikes.
     - The default is "internal" only because it's the most
     - likely to be available.
    -->
  <javac compiler="internal" args=""/>

  <!-- Security providers.
     - <security-provider>
     -    com.sun.net.ssl.internal.ssl.Provider
     - </security-provider>
    -->

  <!--
     - If starting bin/resin as root on Unix, specify the user name
     - and group name for the web server user.
     -
     - <user-name>resin</user-name>
     - <group-name>resin</group-name>
    -->

  <!--
     - Configures threads shared among all HTTP and SRUN ports.
    -->
  <thread-pool>
    <!-- Maximum number of threads. -->
    <thread-max>1024</thread-max>

    <!-- Minimum number of spare connection threads. -->
    <spare-thread-min>25</spare-thread-min>
  </thread-pool>

  <!--
     - Configures the minimum free memory allowed before Resin
     - will force a restart.
    -->
  <min-free-memory>1M</min-free-memory>

  <server>
    <!-- adds all .jar files under the resin/lib directory -->
    <class-loader>
      <tree-loader path="${resin.home}/lib"/>
      <tree-loader path="${server.root}/lib"/>
    </class-loader>

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

    <resin:if test="${resin.isProfessional()}">
      <select-manager enable="true"/>
    </resin:if>

    <!-- listen to the http ports only after the server has started. -->
    <bind-ports-after-start/>

    <!-- The http port -->
    <http server-id="" host="*" port="6060"/>

    <!--
       - SSL port configuration:
       -
       - <http port="8443">
       -   <openssl>
       -     <certificate-file>keys/gryffindor.crt</certificate-file>
       -     <certificate-key-file>keys/gryffindor.key</certificate-key-file>
       -     <password>test123</password>
       -   </openssl>
       - </http>
      -->

    <!--
       - The local cluster, used for load balancing and distributed
       - backup.
      -->
    <!--cluster>
      <srun server-id="" host="127.0.0.1" port="6806"/>
    </cluster-->

    <!--
       - Configures the persistent store for single-server or clustered
       - in Resin professional.
      -->
    <resin:if test="${resin.isProfessional()}">
      <persistent-store type="cluster">
        <init path="session"/>
      </persistent-store>
    </resin:if>

    <!--
       - Enables/disables exceptions when the browser closes a connection.
      -->
    <ignore-client-disconnect>true</ignore-client-disconnect>

    <!--
       - For security, use a different cookie for SSL sessions.
       - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
      -->

    <!--
       - Enables the cache (available in Resin Professional)
      -->
    <resin:if test="${isResinProfessional}">
      <cache path="cache" memory-size="8M"/>
    </resin:if>

    <!--
       - Enables periodic checking of the server status.
       -
       - With JDK 1.5, this will ask the JDK to check for deadlocks.
       - All servers can add <url>s to be checked.
      -->
    <resin:if test="${isResinProfessional}">
      <ping>
        <!-- <url>http://localhost:8080/test-ping.jsp</url> -->
      </ping>
    </resin:if>

    <!--
       - Defaults applied to each web-app.
      -->
    <web-app-default>
      <!--
         - Extension library for common jar files.  The ext is safe
         - even for non-classloader aware jars.  The loaded classes
         - will be loaded separately for each web-app, i.e. the class
         - itself will be distinct.
        -->
      <class-loader>
        <tree-loader path="${server.root}/ext-webapp"/>
      </class-loader>

      <!--
         - Sets timeout values for cacheable pages, e.g. static pages.
        -->
      <cache-mapping url-pattern="/" expires="5s"/>
      <cache-mapping url-pattern="*.gif" expires="60s"/>
      <cache-mapping url-pattern="*.jpg" expires="60s"/>

      <!--
         - Servlet to use for directory display.
        -->
      <servlet servlet-name="directory"
              servlet-class="com.caucho.servlets.DirectoryServlet"/>

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

      <!--
         - for security, disable session URLs by default.
        -->
      <session-config>
        <enable-url-rewriting>true</enable-url-rewriting>
        <save-only-on-shutdown>true</save-only-on-shutdown>
        <file-store>${resin.home}/webapps</file-store>
        <ignore-serialization-errors>true</ignore-serialization-errors>
      </session-config>

      <!--
         - For security, set the HttpOnly flag in cookies.
         - <cookie-http-only/>
        -->
    </web-app-default>

    <!--
       - Sample database pool configuration
       -
       - The JDBC name is java:comp/env/jdbc/test
         <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>
      -->

    <!--
       - Default host configuration applied to all virtual hosts.
      -->
    <host-default>
      <class-loader>
        <compiling-loader path="webapps-/WEB-INF/classes"/>
        <library-loader path="webapps-/WEB-INF/lib"/>
      </class-loader>

      <!--
         - With another web server, like Apache, this can be commented out
         - because the web server will log this information.
        -->
  <!--查看上面U色字体的说?br>-->
      <access-log path="logs/access.log" 
             archive-format="stdout.log.%Y-%m-%d.gz"
            rollover-period="1D"/>
 

      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps-"/>

      <!-- creates the deploy directory for .ear expansion -->
      <ear-deploy path="deploy">
        <ear-default>
          <!-- Configure this for the ejb server
             -
             - <ejb-server>
             -   <config-directory>WEB-INF</config-directory>
             -   <data-source>jdbc/test</data-source>
             - </ejb-server>
            -->
        </ear-default>
      </ear-deploy>

      <!-- creates the deploy directory for .rar expansion -->
      <resource-deploy path="deploy"/>

      <!-- creates a second deploy directory for .war expansion -->
      <web-app-deploy path="deploy"/>
    </host-default>

    <!-- includes the web-app-default for default web-app behavior -->
    <resin:import path="${resin.home}/conf/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=".">
      <!--
         - configures an explicit root web-app matching the
         - webapp's ROOT
        -->
      <!--web-app id="/" document-directory="webapps/ROOT"/-->

      <!--
         - Administration application /resin-admin
         -
         - password is the md5 hash of the password.
         - localhost is true to limit access to the localhost
        -->
      <resin:set var="resin_admin_password"  default=""/>
      <resin:set var="resin_admin_localhost" default="true"/>

      <!--web-app id="/resin-admin" document-directory="${resin.home}/php/admin"/-->
       <web-app id="/" document-directory="webapps/job">

 
      </web-app>

      <!--web-app id="resin-doc" document-directory="webapps/resin-doc"/-->
    
    </host>
  </server>
</resin>

 



]]>
apache+tomcat+mysql 负蝲q和集?zhuan)http://www.tkk7.com/jelver/articles/113258.html都市淘沙?/dc:creator>都市淘沙?/author>Tue, 24 Apr 2007 09:01:00 GMThttp://www.tkk7.com/jelver/articles/113258.htmlhttp://www.tkk7.com/jelver/comments/113258.htmlhttp://www.tkk7.com/jelver/articles/113258.html#Feedback0http://www.tkk7.com/jelver/comments/commentRss/113258.htmlhttp://www.tkk7.com/jelver/services/trackbacks/113258.html公司开发了一个网站,估计最高在Uh数是3万,q发人数最?00人。开发的|站是否能否承受q个压力Q如何确保网站的负荷没有问题Q经q研I决定如下:
Q?Q?采用负蝲q和集技术,初步机构采用Apache+Tomcat的机技术?br>Q?Q?采用压力试工具Q测试压力。工hLoadrunner?br>g环境搭徏Q?br>Z能够q行压力试Q需要搭Z个环境。刚开始时Q测试在公司局域网内进行,但很快发C一个问题,即一个脚本的压力试l果每次都不一Pq且差别很大。原来是受公司网l的影响Q于是决定搭Z个完全隔ȝ局域网试。搭建后的局域网配置如下Q?br>Q?Q?|络速度Q?00M
Q?Q?三台服务器:
负蝲服务?Q操作系lwindows2003Q?br>Tomcat服务器:操作pȝwindows2000 Professional
数据库服务器Q操作系lwindows2000 Professional
三台机器的cpu 2.4 G, 内存 1G?br>软g环境搭徏Q?br>软g的版本如下:
Apache 版本Q?.054Q?br>Tomcat5.0.30,
mysql Q?.1.14.
JDK1.5
压力试工具QLoadrunner7.8?


负蝲qҎ(gu)如下Q?br>一台机器(操作pȝ2003Q安装apacheQ作载服务器Qƈ安装tomcat作ؓ一个workerQ一个单独安装tomcatQ作为第二个workerQ剩下的一台单独作为数据库服务器?br>Apache和tomcat的负载^衡采用JK1.2.14Q没有采?.0Q主要是2.0不再l护了)?br>集群Ҏ(gu)Q?br>采用Tomcat本n的集方案。在server.xml配置?br>压力试问题Q?br>压力试后,发现了一些问题,C一列出来:
Q?Q?采用Tocmat集群后,速度变得很慢。因为集后Q要q行session复制Q导致速度较慢。Tomcatd的复Ӟ目前不支持application复制。复制的作用Q主要用来容错的Q即一台机器有故障后,apache可以把请求自动{发到另外一个机器。在定w和速度的考虑上,我们最l选择速度Q去掉了Tomcat集群?br>Q?Q?操作pȝ最大ƈ发用L限制Q?br>Z采用|站的压力,我们开始的时候,仅测试Tomcat的最大负载数。Tomcat服务器安装的操作pȝ是windows2000 Professional。当我们用压力测试工Pq发试Ӟ发现只要过15个ƈ发用P会经常出现无法连接服务器的情c经q研IӞ发现是操作系l的问题Qwindows2000 Professional 支持的ƈ发访问用h限,默认的好像是15个。于是我们把操作pȝ全部采用windows2003 server版本?br>Q?Q?数据库连接池的问题:
试数据库连接性能Ӟ发现数据库连接速度很慢。每增加一些用Pq接性能差了很多。我们采用的数据库连接池是DBCPQ默认的初始化ؓ50个,应该不会很慢吧。查询数据库的连接数Q发现初始化Q只初始化一个连接。ƈ发增加一个用hQ程序就会重新创Z个连接,Dq接很慢。原因就在这里了。如何解军_Q偶在JDK1.4下的Tomcat5.0.30下执行数据库q接压力试Q发现速度很快Q程序创建数据库q接的速度也是很快的。看来JDK1.5的JDBC驱动E序有问题。于是我们修?JDK的版本ؓ1.4.

Q?Q?C3P0和DBCP
C3P0是Hibernate3.0默认的自带数据库q接池,DBCP是Apache开发的数据库连接池。我们对q两U连接池q行压力试Ҏ(gu)Q发现在q发300个用户以下时QDBCP比C3P0q_旉?U左叟뀂但在ƈ?00个用hQ两者差不多?/p>

速度上虽然DBCP比C3P0快些Q但是有BUGQ当DBCP建立的数据库q接Q因为某U原因断掉后QDBCP不会再重新创徏新的q接Q导致必重新启动Tomcat才能解决问题。DBCP的BUG使我们决定采用C3P0作ؓ数据库连接池?br>调整后的Ҏ(gu)Q?br>操作pȝWindows2003 server版本
JDK1.4
Tomcat 5.0.30
数据库连接池C3P0
仅采用负载^衡,不采用集?br>软g的配|:
Apache配置Q主要配|httpd.conf和新增加的文件workers.properties
Httpd.confQ?br>#一个连接的最大请求数?br>MaxKeepAliveRequests 10000
#NT环境Q只能配|这个参数来提供性能
<IfModule mpm_winnt.c>
#每个q程的线E数Q最?920。NT只启动父子两个进E,不能讄启动多个q程
ThreadsPerChild 1900
每个子进E能够处理的最大请求数
MaxRequestsPerChild 10000
</IfModule>

# 加蝲mod_jk
#
LoadModule jk_module modules/mod_jk.so
#
# 配置mod_jk
#
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
#h分发Q对jsp文gQ?do{动态请求交由tomcat处理
DocumentRoot "C:/Apache/htdocs"
JkMount /*.jsp loadbalancer
JkMount /*.do loadbalancer
JkMount /servlet/* loadbalancer
#xLLookupQ如果ؓonQ很影响性能Q可以有10多秒钟的延迟?br>HostnameLookups Off
#~存配置
LoadModule cache_module modules/mod_cache.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so

<IfModule mod_cache.c>
CacheForceCompletion 100
CacheDefaultExpire 3600
CacheMaxExpire 86400
CacheLastModifiedFactor 0.1

<IfModule mod_disk_cache.c>
CacheEnable disk /
CacheRoot c:/cacheroot
CacheSize 327680
CacheDirLength 4
CacheDirLevels 5
CacheGcInterval 4
</IfModule>
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 8192
MCacheMaxObjectCount 10000
MCacheMinObjectSize 1
MCacheMaxObjectSize 51200
</IfModule>
</IfModule>
worker. Properties文g
#
# workers.properties Q可以参?br>http://jakarta.apache.org/tomcat/connectors-doc/config/workers.html
# In Unix, we use forward slashes:
ps=

# list the workers by name

worker.list=tomcat1, tomcat2, loadbalancer

# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13

# Specify the size of the open connection cache.
#worker.tomcat1.cachesize

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=900

# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat1.port=8009
worker.tomcat1.host=202.88.8.101
worker.tomcat1.type=ajp13

# Specify the size of the open connection cache.
#worker.tomcat1.cachesize

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=2000

# ------------------------
# Load Balancer worker
# ------------------------

#
# The loadbalancer (type lb) worker performs weighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1,tomcat2

#
# END workers.properties
#

Tomcat1配置:
<!--配置server.xml
L8080端口Q即注释掉如下代码:-->
<Connector
port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />

<!--配置8009端口如下Q?->
<Connector port="8009"
maxThreads="500" minSpareThreads="400" maxSpareThreads="450"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
<!--配置引擎-->
<Engine name="Catalina" defaultHost="localhost" debug="0" jvmRoute="tomcat1">

启动内存配置,开发configure tomcatE序卛_配置Q?br>Initial memory pool: 200 M
Maxinum memory pool:300M
Tomcat2配置Q?br>配置和tomcat1差不多,需要改动的地方如下Q?br><!--配置引擎-->
<Engine name="Catalina" defaultHost="localhost" debug="0" jvmRoute="tomcat2">

启动内存配置,开发configure tomcatE序卛_配置Q?br>Initial memory pool: 512 M
Maxinum memory pool:768M
Mysql配置Q?br>ServercdQDedicated MySQL Server Machine
Database usage:Transational Database Only
q发q接数量QOnline Transaction Processing(OLTP)
字符集:UTF8
数据库连接池的配|:
我们采用的是spring 框架Q配|如下:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.url">jdbc:mysql://202.88.1.103/db</prop>
<prop key="hibernate.connection.username">sa</prop>
<prop key="hibernate.connection.password"></prop>

<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.use_sql_comments">false</prop>

<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.max_fetch_depth">2</prop>

<prop key="hibernate.c3p0.max_size">200</prop>
<prop key="hibernate.c3p0.min_size">5</prop>
<prop key="hibernate.c3p0.timeout">12000</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
<prop key="hibernate.c3p0.acquire_increment">1</prop>
</props>
</property>
其他的没有额外配|?br>LoadRunner 常见问题Q?br>Q?Qsofeware caused connctionQ这U情况,一般是脚本有问题,或者loadrunner有问题。解x法:重新启动机器Q或者重新录制脚本,估计是loadrunner的bug?br>Q?Qcannot connect to server:无法q接到服务器。这U情冉|服务器的配置有问题,服务器无法承受过多的q发q接了。需要优化服务器的配|,
如操作系l采用windows 2003 serverQ?br>优化tomcat配置QmaxThreads="500" minSpareThreads="400" maxSpareThreads="450"。但是tomcat 最多支?00个ƈ发访?br>优化apache配置Q?br>ThreadsPerChild 1900
MaxRequestsPerChild 10000
其他的错误如Q?br>Action.c(10): Error -27791: Server has shut down the connection prematurely
HTTP Status-Code=503 (Service Temporarily Unavailable)
一般都是由于服务器配置不够好引LQ按照问题(2Q处理,如果仍旧不行Q需要优化硬件和调整E序了?br>Apache问题Q?br>Q?Q?File does not exist: C:/Apache/htdocs/favicon.icoQ?br>q个问题是apacheQhtdocs目录没有favicon.ico文g引v的,该文件是|站的图标,仅在firefox,myIE{浏览器出现?br>Q?Q?囄无法昄Q?br>配置a(chn)pache后,却无法显C图片?br>解决Ҏ(gu)Q把E序的图片,按照E序l构copy到apache的htdocs目录下?br>Q?Q?无法处理hQ?br>当我们输?***.do 命o后,apache返回错误信息,而连接tomcat却没有问题。原因是没有?do命o转发ltomcat处理。解x法如下:
在apache配置文g中配|如下内容:
DocumentRoot "C:/Apache/htdocs"
JkMount /*.jsp loadbalancer
JkMount /*.do loadbalancer


ȝQ?br>|站的压力测试,涉及的知识面挺广的,不仅要熟(zhn)压力测试工Pq要知道如何配置和优化应用服务器和数据库Qƈ且需要知道如何优化网l、操作系l、硬件系l?br>试中不仅要善于发现问题Q要知道如何解决。最重要的一点,要有良好的测试方法。刚开始测试时Q可以从最单的试脚本入手Q不需要太复杂的脚本,q样便于发现问题。如我们刚开始时Q就从一个简单的下蝲登陆界面的脚本入手,试一个tomcat的压力负载。一个简单的获取登陆的脚本,帮助我们优化了tomcat的配|;后来再测试数据库q接Q也是一个简单的数据库连接脚本,帮助我们优化了数据库q接池;然后利用q些单的脚本Q测试apache的负载^衡,优化了apache配置。最后运行复杂的脚本Q模拟多U角色的用户在不同时间下的处理,以测试网站压力负载?/p>

]]>
վ֩ģ壺 ˳ӰԺ밴Ħ| 2018ĻƵ| ŮҺƵ| AV˾Ʒպһ| һۿ| һ߹ۿ | ŷպһ| Ƶ| 1024Ѹùۿվ| Ƶۿ99| aëƬaѿԿ| ҹѸ߹ۿ| ĻӰѿ| ޾Ʒ| ޾Ʒtvþþþþþþ| ҹӰձŷ޾Ʒһ| ҹþӰԺ| õһۺϾƷ| ˺ݺۺϾþ| selaobanƵѾƷ| ŮƵۿ| þҹ³Ƭ| ҵС身߿Ѹ | ߹ۿ| ҹӰһ| ˳С˵վɫ| ƷƬ߻| selaobanƵѾƷ| þ99ȾƷѹۿţţ| 91ѹۿվ| һƵѹۿ | ëƬƵۿ| ޹߹ۿ| AVվþþƷ | ɫͼƬС˵| Ƶѹۿ| þ99ྫƷѹۿ| ëƬѹۿƵ| ۺС˵| ۺɫһС˵| ޳avƬ롿|