参考网站:
http://www.oschina.net/p/resin
http://caucho.com/resin-4.0/admin/starting-resin.xtp
一、resin产生背景
Resin是CAUCHO公司(http://www.caucho.com/)的产品,是一个非常流行的支持servlets 和jsp的引擎,速度非常快。Resin本身包含了一个支持HTTP/1.1的WEB服务器。虽然它可以显示动态内容,但是它显示静态内容的能力也非常强,速度直逼APACHE SERVER。许多站点都是使用该WEB服务器构建的。
Resin也可以和许多其他的WEB服务器一起工作,比如Apache server和IIS等。Resin支持Servlets 2.3标准和JSP 1.2标准。熟悉ASP和PHP的用户可以发现用Resin来进行JSP编程是件很容易的事情。
Resin支持负载平衡(Load balancing),可以增加WEB站点的可靠性。方法是增加服务器的数量。比如一台SERVER的错误率是1%的话,那么支持负载平衡的两个Resin服务器就可以使错误率降到0.01%。
二、resin环境准备及安装
resin环境安装准备
1)系统环境
2)软件需求
系统:centos5.8(x86_64)
centos6.4(x86_64)
软件: jdk-6u34-fcs-bin-b04-linux-amd64-19_jul_2012.bin 或者 jdk-6u34-linux-x64.bin
版本需求:
Resin 3.1 needs Java before it can run.It needs JDK 1.5 or a later JDK.
Resin 3.1 needs Java before it can run.Resin requires JDK 6.0 or later.
http://www.caucho.com/resin-3.1/doc/starting.xtp
http://www.caucho.com/resin-4.0/admin/starting-resin.xtp
http://www.caucho.com/download/resin-3.1.13.tar.gz ------》下载resin-3.1.13.tar.gz版本
httpd-2.2.23.tar.gz
地址:
http://www.caucho.com/download/
http://httpd.apache.org/download.cgi
http://java.sun.com/javase/downloads/index.jsp
http://www.oracle.com/technetwork/java/javase/archive-139210.html ---》下载jdk-6u34-linux-x64.bin
安装JDK环境
1)下载JDK
登陆http://www.oracle.com/technetwork/java/javase/archive-139210.html 下载对应的jdk版本。
或者上传jdk-6u34-linux-x64.bin到/home/peng/tools
[root@data-1-1 tools]# ll jdk-6u34-linux-x64.bin
-rwxr-xr-x 1 root root 72036348 Jan 8 2016 jdk-6u34-linux-x64.bin
2)增加权限并安装
[root@data-1-1 tools]# chmod +x jdk-6u34-linux-x64.bin
[root@data-1-1 tools]# ./jdk-6u34-linux-x64.bin
[root@data-1-1 tools]# ls -ld jdk1.6.0_34/
drwxr-xr-x 8 root root 4096 Nov 29 00:48 jdk1.6.0_34/
安装完成后,会在当前目录下建立jdk1.6.0_34/的目录。
提示:JDK全称Java(TM) SE Development Kit 6 successfully installed.
3)配置JDK的安装路径
mkdir -p /application
cd /home/peng/tools
mv jdk1.6.0_34/ /application/
ln -s /application/jdk1.6.0_34/ /application/jdk
ls -l /application/ |grep jdk
/application/jdk/bin/java –version
查看版本信息:
[root@data-1-1 tools]# /application/jdk/bin/java -version
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)
4)设置JAVA变量
echo "#java start_config at 2016-1-7" >>/etc/profile
echo 'export JAVA_HOME=/application/jdk' >>/etc/profile
echo 'export PATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib'>>/etc/profile
echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin'>>/etc/profile
echo 'RESIN_HOME=/application/resin' >>/etc/profile
echo "#java env end config at 2016-1-7" >>/etc/profile
生效:
source /etc/profile
查看:
echo $JAVA_HOME
echo $CLASSPATH
echo $RESIN_HOME
echo $PATH
5)安装resin
[root@data-1-1 ~]# cd /home/peng/tools/
[root@data-1-1 tools]# wget http://www.caucho.com/download/resin-3.1.13.tar.gz
[root@data-1-1 tools]# tar -zxf resin-3.1.13.tar.gz
[root@data-1-1 tools]# mv resin-3.1.13 /application/
[root@data-1-1 tools]# ln -s /application/resin-3.1.13/ /application/resin
[root@data-1-1 tools]# ls -l /application/
lrwxrwxrwx 1 root root 26 Nov 29 01:39 resin -> /application/resin-3.1.13/
resin配置文件说明及修改
[root@data-1-1 ~]# cd /application/resin/conf
[root@data-1-1 conf]# diff resin.conf resin.conf.orig
[root@data-1-1 ~]# vim +88 /application/resin/conf/resin.conf -->删除默认配置文件的88-146行。加入如下内容
要删除的内容:
88
89
90
91
92
103
104
107
108
109
110
111
112
116
117
120
121
122
123
127
128
129
130
131
132
133
134
135
136
137
138
139
146
以上参数说明如下:
!-- resin Configure at 2016-1-11 -->
提示:可以把
启动resin
[root@data-1-1 ~]# /application/resin/bin/httpd.sh -server peng start
[root@data-1-1 ~]# netstat -tunlp |egrep "6911|6921|8080"
tcp 0 0 ::ffff:192.168.1.140:6911 :::* LISTEN 10298/java
tcp 0 0 ::ffff:127.0.0.1:6921 :::* LISTEN 10269/java
tcp 0 0 :::8080 :::* LISTEN 10298/java
提示:
8080 --->resin web server的端口,如果不需要resin做web server,可以关掉这个配置。
6921 --->watchdog的端口
6911 --->真正的resin端口,这个必须要起来,将来在Apache里就是把请求抛给这个端口解析的。
命令帮助:
[root@data-1-1 ~]# /application/resin/bin/httpd.sh -h
unknown argument '-h'
usage: java -jar resin.jar [-options] [status | start | stop | restart | kill | shutdown]
where options include:
-conf
-log-directory
-resin-home
-root-directory
-server
-watchdog-port
-verbose : print verbose starting information
浏览器查看页面
用http://hostip:8080访问resin的默认页面
192.168.1.140:8080/
查看的结果如下:
出现上面的页面显示,则说明resin服务配置OK了!
jsp文件默认路径存放在
[root@data-1-1 ~]# ll /application/resin/webapps/ROOT/
total 8
-rw-r--r-- 1 root root 1507 Nov 9 2012 index.jsp
drwxr-xr-x 5 root root 4096 Nov 29 04:30 WEB-INF
[root@data-1-1 ~]# echo '99+1=<%=99+1%>' >/application/resin/webapps/ROOT/test.jsp
[root@data-1-1 ~]# cat /application/resin/webapps/ROOT/test.jsp
99+1=<%=99+1%>
**[root@data-1-1 ~]# curl http://192.168.1.140:8080/test.jsp**
99+1=100
开发启动脚本
[root@data-1-1 ~]# cat /etc/init.d/resin-peng
#!/bin/bash
. /etc/init.d/functions
StartPath='/application/resin/bin/httpd.sh'
ResinLog=/app/logs/resinlog
[ ! -d $ResinLog ] && mkdir -p $ResinLog
resind () {
#如果是多进程增加上面的配置段即可。
for id in peng
do
$StartPath -server $id $1 >>$ResinLog/resin_startup.log
if [ $? -eq 0 ];then
action "$1 $id resin…" /bin/true
else
action "$1 $id resin…" /bin/false
fi
done
}
case "$1" in
start)
resind $1
echo "--------checking------"
sleep 10
netstat -lnt |egrep "80|69"
echo "--------checkover-----"
;;
stop)
resind $1
;;
restart)
resind stop
resind start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
赋予权限:
[root@data-1-1 ~]# chmod +x /etc/init.d/resin-peng
测试结果:
[root@data-1-1 ~]# /etc/init.d/resin-peng restart
stop peng resin… [ OK ]
start peng resin… [ OK ]
配置resin开机自启动说明
脚本如下:
[root@data-1-1 ~]# cat /etc/init.d/resin-peng
#!/bin/bash
#author at 20160111
#linux startup script for Resin
# chkconfig: 345 85 15
# description: Resin is a Java Web server.
#
#To install,configure this file as needed and copy init.resin
#to /etc/rc.d/init.d as resin. Then use "# /sbin/chkconfig resin reset"
#
. /etc/init.d/functions
StartPath='/application/resin/bin/httpd.sh'
ResinLog=/app/logs/resinlog
[ ! -d $ResinLog ] && mkdir -p $ResinLog
resind () {
#如果是多进程增加上面的配置段即可。
for id in peng
do
$StartPath -server $id $1 >>$ResinLog/resin_startup.log
if [ $? -eq 0 ];then
action "$1 $id resin…" /bin/true
else
action "$1 $id resin…" /bin/false
fi
done
}
case "$1" in
start)
resind $1
echo "--------checking------"
sleep 10
netstat -lnt |egrep "80|69"
echo "--------checkover-----"
;;
stop)
resind $1
;;
restart)
resind stop
resind start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
加入到chkconfig中:
[root@data-1-1 ~]# chkconfig --add /etc/init.d/resin-peng
[root@data-1-1 ~]# chkconfig --list resin-peng
resin-peng 0:off 1:off 2:off 3:on 4:on 5:on 6:off
启动resin服务异常解决办法
[root@data-1-1 ~]# cat /app/logs/resinlog/resin_startup.log
Resin/3.1.13 started -server 'peng' for watchdog at 127.0.0.1:6921
Resin/3.1.13 stopped -server 'peng' for watchdog at 127.0.0.1:6921
Resin/3.1.13 started -server 'peng' for watchdog at 127.0.0.1:6921
提示:/app/logs/resinlog/resin_startup.log这个日志路径是启动脚本里定义的。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章