安装 jdk
tar -xf server-jre-8u77-linux-x64.tar.gz
mkdir /usr/local/java
mv jdk1.8.0_77/ /usr/local/java/
vim /etc/profile 在末尾加上如下
export JAVA_HOME=/usr/local/java/jdk1.8.0_77/
export CLASSPATH=$CLASSPATH:$JAVA_HOMEb:$JAVA_HOME/jreb
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
source /etc/profile
[[email protected] java]# source /etc/profile
[[email protected] java]# java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
安装 resin
tar -xf resin-4.0.44.tar.gz
cd resin-4.0.44
./configure --prefix=/usr/local/resin --with-resin-log=/usr/local/resin/logs --with-java-home=/usr/local/java/jdk1.8.0_77/
make make install
/usr/local/resin/bin/resinctl 启动
虚拟主机配置
cd /usr/local/resin
cp -r webapps webapps2
cp conf/resin.xml conf/resin2.xml
修改resin2.xml 如下红色部分
<cluster id="app2">
<!-- define the servers in the cluster -->
<server-multi id-prefix="app2-" address-list="${app_servers2}" port="6801"/>
<host-default>
<!-- creates the webapps directory for .war expansion -->
<web-app-deploy path="webapps2"
expand-preserve-fileset="WEB-INF/work/**"
multiversion-routing="${webapp_multiversion_routing}"
path-suffix="${elastic_webapp?resin.id:‘‘}"/>
</host-default>
<!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
<host-deploy path="hosts">
<host-default>
<resin:import path="host.xml" optional="true"/>
</host-default>
</host-deploy>
<!-- the default host, matching any host name -->
<host id="" root-directory=".">
<!--
- webapps can be overridden/extended in the resin.xml
-->
<web-app id="/" root-directory="webapps2/ROOT"/>
</host>
<resin:if test="${resin_doc}">
<host id="${resin_doc_host}" root-directory="${resin_doc_host}">
<web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
</host>
</resin:if>
</cluster>
<cluster id="web">
<!-- define the servers in the cluster -->
<server-multi id-prefix="web-" address-list="${web_servers}" port="6810"/>
<host id="" root-directory="web">
<web-app id="">
<resin:LoadBalance regexp="" cluster="app2"/>
</web-app>
<web-app id="/async">
<resin:LoadBalance regexp="" cluster="app2"/>
</web-app>
</host>
</cluster>
修改resin.properties 文件
添加 app2.http : 8081 app_servers2 : 127.0.0.1:6801
app_servers : 127.0.0.1:6800
app_servers2 : 127.0.0.1:6801
app.http : 8080
app2.http : 8081
修改完后启动服务
/usr/local/resin/bin/resin.sh -conf /usr/local/resin/conf/resin.xml start
/usr/local/resin/bin/resin.sh -conf /usr/local/resin/conf/resin2.xml start
测试
vim /usr/local/resin/webapps/ROOT/index.jsp
<body>
<h1>han1 TOMCAT_1 JSP Test Page</h1>
<%=new java.util.Date()%>
</body>
</html>
vim /usr/local/resin/webapps2/ROOT/index.jsp
<body>
<h1>han2 TOMCAT_1 JSP Test Page</h1>
<%=new java.util.Date()%>
</body>
</html>
chmiod +x /usr/local/resin/webapps/ROOT/index.jsp
chmiod +x /usr/local/resin/webapps2/ROOT/index.jsp
到此完成 关于动静分离 和负载均衡 和tomcat 一样 这里就不演示了