(转载)Resin安装配置及使⽤教程
Resin是⼀个提供⾼性能的,⽀持 Java/PHP 的应⽤服务器。⽬前有两个版本:⼀个是GPL下的开源版本,提供给⼀些爱好者、开发⼈员和低流量⽹站使⽤;⼀种是收费的专业版本,增加了⼀些更加适⽤于⽣产环境的特性。
Resin也可以和许多其他的⼀起⼯作,⽐如Apache Server和IIS等。Resin⽀持Servlets 2.3标准和JSP 1.2标准。熟悉ASP和PHP的⽤户可以发现⽤Resin来进⾏JSP编程是件很容易的事情。
Resin⽀持负载平衡,可以增加WEB站点的可靠性。⽅法是增加服务器的数量。⽐如⼀台Server的错误率是1%的话,那么⽀持负载平衡的两个Resin服务器就可以使错误率降到0.01%。到⽬前为⽌,Resin对WEB应⽤的⽀持已经远远超过Tomcat等各种⼤型的Server。
服务器区 / 25.8M / 中⽂
Resin的⼀些特性:
可靠性:Resin包含了很多可靠的特性,包括服务器⾃动重启、检测并重启死锁的服务器、管理JVM内存以防⽌内存泄露等。
集:Resin可以将多个服务器作为⼀个服务器来对客户进⾏响应,从⽽增强服务器的扩展能⼒。
持久和分布的sessions:持久的session能够在服务器重启的时候保持现有的Http会话,分布式的session可以在多个服务器之间共享Http会话的状态。
增强的本地代码:同时为Windows和Linux系统提供了本地的代码增强⽀持。能够改善Socket链接、持久链接和⽂件读写⽅⾯的性能。
OpenSSL:提供原⽣的OpenSSL库⽀持,⽐JSSE提供的⽅案要好很多。
HTTP代理缓存:能够通过内存和磁盘缓存系统提⾼服务器的性能表现,将动态页⾯的速度提⾼到接近静态页⾯。
Gzip过滤器:通过gzip来减少带宽。
Resin服务器的安装(Windows - 独⽴版)
1、安装或更⾼
2、确保JDK的安装以及正确设置了环境变量JAVA_HOME
3、解压Resin⽂件
4、执⾏ java –jar resin-3.1.8/lib/resin.jar
5、或者运⾏
6、在浏览器地址栏中输⼊ localhost:8080 即可进⾏访问
我们也可以将Resin设置为系统服务。
的配置:
Resin的配置⽂件位于 ./conf/ 下,默认的配置⽂件为 f。
配置简单的,我们只要加⼊
<host host-name=".heep" root-directory="D:\workspaces\java\testsys">
<access-log path="logs/test.access.log"
format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
rollover-period="1W"/>
<web-app id="/" root-directory="WebRoot/">
</web-app>
</host>
</cluster>
另外在host⽂件中加⼊对应的记录,这样,我们就可以访问 test.heep 了!
Resin的配置案例如下:(Linux系统)
本⽂resin采⽤版本为:Resin 2.1.13
本⽂所有代码均已测试通过
我的⼯程⽬录结构如下:
/(root)
|--resin(resin根⽬录)
| |--bin
| |--conf
| | |--f(resin配置⽂件今天的主⾓)
| |--lib
|--src
|--java(⽤于放置java源⽂件)
|--test(测试⽂件⽬录)
|--webapp(web应⽤的根⽬录,将来doc-dir会指向这⾥)
|---WEB-INF
|------classes
|------lib
perl下载安装教程|------l(web配置⽂件)
|------l(其他配置⽂件)
以下是f⽂件源码
<caucho>
<log id='/logs' href='stderr:' timestamp='[%Y-%m-%d %H:%M:%S.%s]'/>
<http-server error-log="logs/errors.log">
<doc-dir>../src/webapp</doc-dir>
<!-- the http port -->
<http port='82'/>
<host id=''>
<web-app id='/'>
<work-dir>../../build/work</work-dir>
<temp-dir>../../build/tmp</temp-dir>
<cache-mapping url-pattern="/*" expires="2"/>
<class-update-interval>
100000000
</class-update-interval>
<jsp jsp-update-interval="1s"/>
<classpath id='WEB-INF/classes'/>
</web-app>
</host>
</http-server>
</caucho>
<?xml version="1.0" encg="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "java.sun/dtd/web-app_2_3.dtd"> <web-app>
<display-name>Acme Corp</display-name>
<filter>
<filter-name>webwork</filter-name>
<filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.t.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!--
This typically isn't required, as the taglib is included in webwork.jar.
If you really need a taglib configuration l, copy webwork/src/java/META-INF/taglib.tld
to the WEB-INF directory as webwork.tld.
-->
<!--taglib>
<taglib-uri>webwork</taglib-uri>
<taglib-location>/WEB-INF/webwork.tld</taglib-location>
</taglib-->
</web-app>
在慢速机器上的Resin启动:
RESIN是⼀个JAVA应⽤,启动过程中需要消耗⼤量的CPU资源。因此在⼀些⽐较慢的机器上或者按照
以上的配置有时候会很奇怪的启动不起来,在stderr.log中显⽰:"can't connect to parent",这个问题可以通过在服务启动后加上⼀个15秒的延时解决:
在/etc/init.d/resin: 43⾏左右:
if test -n "$USER"; then
su - $USER -c "$EXE -pid $PID start $ARGS"
else
$EXE -pid $PID start $ARGS
fi
#服务启动后,加上⼀个15秒的延时解决
sleep 15
问题解决过程和思路:
先检查resin的⽇志:stderr.log,⾥⾯有can't connect to parent,然后在google上查"resin2 can't connect to parent"和"resin can't connect to parent",⼤约有⼏篇邮件列表归档吧,在⼀篇邮件列表归档中有技术⽀持说正在调整服务等待时间解决类似问题(需要改SOURCE),另外⼀个⼈说他的P4服务器启动时需要启动很多消耗CPU的服务,也会导致RESIN启动不了,然后我在⾃⼰的机器上尝试了⼀下,在RESIN 启动前就登录到机器上,发现启动时RESIN和PERL脚本其实都运⾏了,但过了⼀会⼉相应进程就退出了,在启动后系统⽐较平稳了,再启动RESIN,RESIN服务就是好的,说明说明脚本本⾝没有问题,按我以前的经验,JAVA应⽤是⼀个⽐较吃CPU资源的类型,为了让RESIN 有⾜够的CPU资源的启动,在启动后我增加了15秒的延迟,以防⽌后续服务影响RESIN的启动。问题就解决了,⽽且在其他机器上试也成功了。
当然,最好还是CAUCHO解决了这个问题⼤家就都不⽤学这些⼩技巧了。因此我将类似中所有的BUG报告中提交了⾃⼰的解决⽅案,要求在sin脚本中增加⼀个全局变量,允许⽤户设置启动时的等待时间。并把这个解决思路追加到⽂档中,让⼤家能够⽤⾃⼰的⾏动积极⽀持开源软件。
利⽤Resin内置的⽇志轮循,HTTP,缓存和简单HTTP认证
作为应⽤服务器,很多功能都不⽤⾃⼰再开发了:建议把这些和应⽤服务器相关的配置放在f⾥,⽽和应⽤服务器⽆关的Web应⽤的标准配置放在l中。
<host id='example.chedong'>
<access-log id='logs/example_access.log'>
<!--rotate log daily-->
<rollover-period>1D</rollover-period>
</access-log>
<error-log id='logs/example_error.log'>
<rollover-period>1M</rollover-period>
</error-log>
<web-app id='/' app-dir='/www/myapp/'>
<classpath id='WEB-INF/classes' source='WEB-INF/src' compile='true'/>
<!--http compress-->
<filter-mapping url-pattern='/result'
filter-name='com.caucho.http.filter.GzipFilter'/>
<!--admin need authorization-->
<login-config auth-method='basic'>
<authenticator>
<class-name>com.caucho.http.security.XmlAuthenticator</class-name> <init-param user='myname:password:user'/>
</authenticator>
</login-config>
<security-constraint url-pattern='/admin' role-name='user'/>
</web-app>
</host>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论