📄 1318.html
字号:
# ln ../init.d/tomcat2 K03tomcat2<br>
<br>
<br>
如果用自带的startup.sh,则修改bin/catalina.sh,在开始处加上<br>
代码:<br>
<br>
CATALINA_HOME=/path/to/tomcat2; export CATALINA_HOME<br>
<br>
<br>
III. 修改两个Tomcat的配置文件server.xml<br>
<br>
代码:<br>
<br>
要修改的内容 Control Port <br>
修改前 <Server port="8005" <br>
修改后tomcat1 <Server port="11005" <br>
修改后tomcat2 <Server port="12005"<br>
<br>
要修改的内容 AJP13 Port <br>
修改前 <Connector port="8009" <br>
修改后tomcat1 <Connector port="11009" <br>
修改后tomcat2 <Connector port="12009"<br>
<br>
要修改的内容 Http Port <br>
修改前 <Connector port="8080" <br>
修改后tomcat1 <Connector port="11080" <br>
修改后tomcat2 <Connector port="12080"<br>
<br>
要修改的内容 Set jvmRoute <br>
修改前 <Engine name="Catalina" defaultHost="localhost" debug=0"> <br>
修改后tomcat1 <Engine jvmRoute="tomcat1" name="Catalina" defaultHost="localhost" debug=0"><br>
修改后tomcat2 <Engine jvmRoute="tomcat2" name="Catalina" defaultHost="localhost" debug=0"><br>
<br>
<br>
IV. 配置workers2.proerties<br>
<br>
代码:<br>
<br>
#---- worker2.properties<br>
<br>
[logger.apache2]<br>
level=DEBUG<br>
<br>
# Shared memory handling. Needs to be set.<br>
[shm]<br>
file=/var/apache/logs/shm.file<br>
size=1048576<br>
<br>
[channel.socket:localhost:11009]<br>
tomcatId=localhost:11009<br>
port=11009<br>
host=127.0.0.1<br>
lb_factor=1<br>
group=lb_1<br>
disabled=0<br>
<br>
[channel.socket:localhost:12009]<br>
tomcatId=localhost:12009<br>
port=12009<br>
host=127.0.0.1<br>
lb_factor=1<br>
group=lb_1<br>
disabled=0<br>
<br>
[status:status]<br>
<br>
[lb:lb]<br>
info=Default load balancer<br>
debug=1<br>
<br>
[lb:lb_1]<br>
info=Second load balancer<br>
debug=0<br>
<br>
# Uri mapping<br>
<br>
[uri:/jkstatus/*]<br>
group=status:status<br>
<br>
[uri:/*]<br>
group=lb:lb_1<br>
<br>
#---- end of workers2.properties<br>
<br>
<br>
<br>
V. 创建两个测试用的jsp文件<br>
/path/to/tomcat1/webapps/ROOT/test.jsp<br>
代码:<br>
<br>
<br>
<html><br>
body bgcolor="red" <br>
<center><br>
<%= request.getSession().getId() %><br>
<h1>Tomcat 1</h1><br>
</body><br>
</html><br>
<br>
<br>
<br>
/path/to/tomcat2/webapps/ROOT/test.jsp<br>
代码:<br>
<br>
<br>
<html><br>
body bgcolor="blue" <br>
<center><br>
<%= request.getSession().getId() %><br>
<h1>Tomcat 2</h1><br>
</body><br>
</html><br>
<br>
<br>
<br>
VI. 测试<br>
启动tomcat1、tomcat2和apache<br>
代码:<br>
<br>
# /etc/init.d/tomcat start<br>
# /etc/init.d/tomcat2 start<br>
# /etc/init.d/apache start<br>
<br>
用浏览器测试一下 http://yourserverip/test.jsp<br>
红色页面说明访问的是tomcat1<br>
蓝色的是tomcat2<br>
<br>
VII. Links<br>
http://raibledesigns.com/tomcat/<br>
<br>
<br>
实现session的复制<br>
<br>
I. 修改server.xml<br>
取消server.xml文件中对下面这段代码的注释,还要修改tcpListenPort的值,注意不能冲突,可以设成4001和4002<br>
代码:<br>
<br>
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"<br>
managerClassName="org.apache.catalina.cluster.session.DeltaManager"<br>
expireSessionsOnShutdown="false"<br>
useDirtyFlag="true"><br>
<br>
<Membership<br>
className="org.apache.catalina.cluster.mcast.McastService"<br>
mcastAddr="228.0.0.4"<br>
mcastPort="45564"<br>
mcastFrequency="500"<br>
mcastDropTime="3000"/><br>
<br>
<Receiver<br>
className="org.apache.catalina.cluster.tcp.ReplicationListener"<br>
tcpListenAddress="auto"<br>
tcpListenPort="4001"<br>
tcpSelectorTimeout="100"<br>
tcpThreadCount="6"/><br>
<br>
<Sender<br>
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"<br>
replicationMode="pooled"/><br>
<br>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"<br>
filter=".*.gif;.*.js;.*.jpg;.*.htm;.*.html;.*.txt;"/><br>
</Cluster><br>
<br>
<br>
II. 修改web.xml<br>
修改演示Servlet的Web应用的web.xml文件,添加<distributable/>元素。<br>
代码:<br>
<br>
......<br>
<br>
<display-name>Servlet 2.4 Examples</display-name><br>
<description><br>
Servlet 2.4 Examples.<br>
</description><br>
<br>
<distributable/><br>
<br>
......<br>
<br>
<br>
<br>
III. 测试<br>
<br>
访问url: http://serverip/servlets-examples/servlet/SessionExample<br>
<br>
<br>
1. 关闭tomcat1和tomcat2;<br>
2. 启动tomcat1<br>
3. 在浏览器中输入属性名tomcat1和属性值tomcat1再提交,返回的页面显示session中有刚刚输入的tomcat1属性;<br>
4. 启动tomcat2;<br>
5. 过一会后(等待tomcat2和tomcat1通信并复制信息)关闭tomcat1;<br>
6. 在浏览器中输入属性名tomcat2和属性值tomcat2再提交,返回的页面显示session中有刚刚输入的tomcat2属性,还有先前输入的tomcat1属性;<br>
7. 启动tomcat1;<br>
8. 过一会后(等待tomcat2和tomcat1通信并复制信息)关闭tomcat2;<br>
9. 在浏览器中输入属性名tomcat11和属性值tomcat11再提交,返回的页面显示session中有刚刚输入的tomcat11属性,还有先前输入的tomcat1和tomcat2属性;<br>
<br>
<br>
<br>
<br>
IV. 参考文档<br>
<br>
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/cluster-howto.html<br>
http://www-900.ibm.com/developerWorks/cn/java/l-jetspeed/
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -