Tomcat负载均衡mod_jk.so

请结合集群进行部署
第一步
下载插件(以apache版本为主)
网址为:http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/
得到mod_jk.so文件




第二步
将mod_jk.so文件复制到 apache目录\modules 下




第三步
在 apache目录\conf 下创建 workers.properties 内容如下(保存为ANSI格式):
worker.list=controller,tomcat1,tomcat2,tomcat3
#========tomcat1=========
worker.tomcat1.port=7009 //端口
worker.tomcat1.host=127.0.0.1 //host
worker.tomcat1.type=ajp13 //类型
worker.tomcat1.lbfactor=1 //承重
#========tomcat2=========
worker.tomcat2.port=8009
worker.tomcat2.host=127.0.0.1
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
#========tomcat3=========
worker.tomcat3.port=9009
worker.tomcat3.host=127.0.0.1
worker.tomcat3.type=ajp13
worker.tomcat3.lbfactor=1
#========controller=========
worker.controller.type=lb //类型lb
worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3 //连接器
worker.controller.sticky_session=false //同步session方式(取消默认,可和多个节点交顾)




第四步
在 apache目录\conf 下创建 mod_jk.conf 内容如下:
LoadModule jk_module modules/mod_jk.so //加载文件目录
JkWorkersFile conf/workers.properties //配置文件路径
JkMount /* controller //将apache下所有的请求都交给controller处理




第五步
修改 apache目录\conf\httpd.conf 文本末尾追加一行
include conf/mod_jk.conf










测试
C:\o\Apache2.4\Apache24\bin>ab -n 1000 -c 20 http://127.0.0.1/TestCluster/index.jsp
属性说明
-n   设置为访问一千次
-c   设置并发访问量


This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests




Server Software:        Apache/2.4.17
Server Hostname:        127.0.0.1
Server Port:            80


Document Path:          /TestCluster/index.jsp
Document Length:        440 bytes


Concurrency Level:      20
Time taken for tests:   1.101 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      729000 bytes
HTML transferred:       440000 bytes
Requests per second:    908.26 [#/sec] (mean)
Time per request:       22.020 [ms] (mean)
Time per request:       1.101 [ms] (mean, across all concurrent requests)
Transfer rate:          646.61 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.8      0      10
Processing:     0   21  41.2     10     636
Waiting:        0   20  41.0     10     636
Total:          0   21  41.1     10     636


Percentage of the requests served within a certain time (ms)
  50%     10
  66%     20
  75%     20
  80%     30
  90%     30
  95%     50
  98%    130
  99%    190
 100%    636 (longest request)


如果一个服务器宕机(模拟关闭),其他会继续跑
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页