Samuel Learning

  • 联系
  •  
  • 管理

文章分类(203)

  • 01 ASP/HTML(6)
  • 02 Script/CSS(16)
  • 03 C/C++
  • 04 XML(4)
  • 05 微软编程(26)
  • 06 J2EE(60)
  • 09 Linux(14)
  • 10 Database(27)
  • 11 报表打印
  • 12 打包安装(1)
  • 13 模式重构(2)
  • 14 系统架构
  • 15 敏捷开发(11)
  • 16 案例分析(30)
  • 17 Workflow(1)
  • 18 配置管理(1)
  • 19 项目管理
  • 20 英语(4)

新闻分类(52)

  • CXF学习
  • Hibernate学习(1)
  • iBatis学习(16)
  • Struts1学习(1)
  • Struts2学习(34)

.NET资源

  • adxmenu
  • C# Open Source
  • DNN Directory
  • M2Land
  • Windows Form FAQ
  • 中国DNN
  • 中国DNN联盟

Ajax

  • DoJo
  • GWT
  • JQuery
  • jquery autocomplete
  • jquery flexgrid
  • JQuery Form
  • jquery masked input
  • JQuery UI
  • jquery validation
  • Jquery 图表
  • jquery报表
  • jquery插件集合
  • Qooxdoo
  • Tibco GI
  • YUI
  • YUI-EXT
  • ZeroKode

Java开源

  • ABLE
  • Agile Tao
  • Ajax4JSF
  • Alfresco
  • AppFuse
  • Compiere
  • Equinox
  • Findbugs
  • Geronimo
  • Grails
  • Harmony
  • Hibernate论坛
  • JAG
  • Java开源大全
  • Java视线论坛
  • jBPM工作流
  • JSFTutorials
  • Nereide ERP
  • Ofbiz ERP
  • Opentaps ERP
  • operamasks
  • Petstore
  • Prototype.js
  • RIFE
  • Runa
  • SpringSide
  • Struts Menu
  • Sun Glassfish
  • Trails
  • YUI4JSF
  • 满江红

Mobile

  • Sencha

WEB资源

  • DHTML中心
  • DHTML参考手册
  • DHTML文档
  • EclipsePlugin
  • Firebug
  • GRO Clinux
  • jMaki
  • JSTL文档
  • LoadIcon
  • Openlaszlo
  • Struts Menu 展示
  • Web Test Tools
  • WebCtrs
  • Webdeveloper
  • 中国RIA开发者论坛

Workflow

  • E-Workflow
  • JBPM
  • OpenWFE
  • OSWorkflow
  • WFMC
  • Workflow Research

其他连接

  • confach
  • CPP
  • ejay
  • Giovanni
  • 丹佛
  • 交大e-learning
  • 交大研究生院
  • 可恶的猫
  • 天天@blog
  • 我的相册
  • 阿飞

大牛人

  • 32篇JBPM
  • David.Turing
  • HongSoft@业务集成
  • Joel
  • Koen Aers
  • Martinfowler
  • Raible Matt
  • Raible Wiki
  • Scott W.Ambler
  • Tom Baeyens
  • Uncle Bob
  • 一个世界在等待
  • 子在川上曰
  • 小布老师
  • 小明
  • 差沙
  • 徐昊
  • 江南白衣
  • 汪博士
  • 汪小金
  • 银狐999

开源软件

  • 2Bizbox ERP
  • CompiereCRM&ERP
  • EGW
  • Vtiger CRM
  • webERP

敏捷

  • Canoo
  • Cruisecontrol
  • DBUnit
  • EL4Ant
  • Extreme Programming
  • Fit
  • Fitnesse
  • JFrog
  • Liquibase
  • Maven
  • MockObjects
  • Selenium
  • Squish
  • xpairtise
  • XPlanner
  • XProgramming
  • 敏捷联盟

数据库

  • Oracle 中国
  • Oracle-ERP
  • Oracle在线社区

未归类

  • Aquarius Orm Studio
  • mambo建站系统
  • Oracle产品下载
  • 远程同步管理工具Capivara

经典框架

  • Apache Shale
  • formdef-struts
  • FreeMarker 主页
  • JBoss Seam
  • JSF 中心
  • JSF 入门应用
  • JSF中国
  • MyFaces官方
  • Spring 社区
  • Spring专业网站
  • Spring中文论坛
  • Spring参考手册
  • Spring官方网站
  • strecks-struts
  • Struts1
  • Struts2
  • Struts-layout
  • StrutsWiKi
  • Tapestry WIKI
  • Tapestry 官方
  • Tapestry4开发指南
  • Tapestry中文文档
  • Webwork2文档
  • Wicket

网络教程

  • Laliluna
  • RoseIndia
  • Sang Shin
  • Visualbuilder

著名站点

  • Buildix
  • Dev2Dev
  • IBM dev中国
  • InfoQ
  • ITPub
  • Java Eye
  • Java Research
  • JavaRead
  • JavaWorldTW
  • Matrix
  • PHP100
  • PHPX
  • SpringSideWiKi
  • TheServerSide
  • TWPHP
  • 中国工作流论坛

项目管理

  • 管理人网

最新评论

View Post

Tomcat 负载均衡

Step 1 Download 3 software
 
    1, Apache2.0.xx
    2,Tomcat5.5.1x
    3,mod_jk, it is connector of  tomcat

Step 2 Install Apache2.0 at d:\Apache2, start service, then browse http://localhost for testing, you can see welcome page of apache.

Step 3 Install 2 Tomcats at d:\tomcat1 and d:\tomcat2, set JAVA_HOME, PATH, start tomcat service, then browse http://localhost:8080 for test, you can see welcome page of tomcat.

Step 4 Config apache: 

       Copy mod_jk.so to d:\apache2\modules.
      
       Add “include D:\Apache2\conf\mod_jk.conf” in the end of d:\apache2\conf\httpd.conf

 

       Add a new file: d:\Apache2\conf\mod_jk.conf, the content is as following:

# Load mod_jk module

LoadModule jk_module modules/mod_jk.so

 

# Where to find workers.properties

JkWorkersFile conf/workers.properties

 

# Where to put jk logs

JkLogFile logs/mod_jk.log

 

# Set the jk log level [debug/error/info]

JkLogLevel info

 

# Select the log format

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

 

# JkOptions indicate to send SSL KEY SIZE ,

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

 

# JkRequestLogFormat set the request format

JkRequestLogFormat "%w %V %T"

 

# Send servlet for context /examples to worker named ajp13

#JkMount /servlet/* ajp13

 

# Send JSPs for context /examples to worker named ajp13

JkMount /*.jsp loadbalancer

 

JkMount /*.htm loadbalancer


    Add a new file d:\Apache2\conf\ workers.properties, the content is as following:

#

# workers.properties

#

 

# In Unix, we use forward slashes:

ps=/

 

# list the workers by name

 

worker.list=tomcat1, tomcat2, loadbalancer

 

# ------------------------

# First tomcat server

# ------------------------

worker.tomcat1.port=11009

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=100

 

 

# ------------------------

# Second tomcat server

# ------------------------

worker.tomcat2.port=12009

worker.tomcat2.host=localhost

worker.tomcat2.type=ajp13

 

# Specify the size of the open connection cache.

#worker.tomcat2.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.tomcat2.lbfactor=100

 

 

# ------------------------

# 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

#

 

 

Step 5 Config Tomcat

 

       Modify conf/server.xml file

 

    1 Add a unique jvmRoute to the Catalina engine

 

Near line 100, replace:

 

    <Engine name="Standalone" defaultHost="localhost" debug="0">

with:

 

    <Engine jvmRoute="tomcat1" name="Standalone" defaultHost="localhost" debug="0">

For tomcat2, put jvmRoute="tomcat2".

 

2 Change the control port

 

At line 13, replace:

 

    <Server port="8005"

with:

 

    <Server port="11005"

For the tomcat2 server, replace port 8005 with 12005. This will prevent the two servers from conflicting.

 

3 Change the AJP13 port

 

At line 75, in the AJP 13 connector definition, replace:

 

    port="8009"

with:

 

    port="11009"

For the tomcat2 server, replace port 8009 with 12009.

 

4 Disable the standalone HTTP port

 

We don't want or need our tomcat servers to directly respond to HTTP requests. So we comment out the HttpConnector section between lines and 58 in the server.xml file.

 

Example:

 

<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->

<!--

    <Connector className="org.apache.catalina.connector.http.HttpConnector"

               port="8080" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="60000"/>

-->   

NOTE: If you don't comment this out, you will need to change the port numbers so they don't conflict between tomcat instances.

 

 

Step 6 Test  
            1 Create a file named index.jsp and put it in the /usr/local/tomcat1/webapps/ROOT directory:

<html>

<body bgcolor="red">

<center>

<%= request.getSession().getId() %>

<h1>Tomcat 1</h1>

</body>

</html>

 

 

2 Create a file named index.jsp and put it in the /usr/local/tomcat2/webapps/ROOT directory:

<html>

<body bgcolor="blue">

<center>

<%= request.getSession().getId() %>

<h1>Tomcat 2</h1>

</body>

</html>

 

       3 Browse http://localhost/index.jsp

 

 

 

 

 

posted on 2006-12-12 18:14 MingIsMe 阅读(115) 评论(0)  编辑  收藏 所属分类: 06 J2EE

 
Powered by:
BlogJava
Copyright © MingIsMe