您的位置:首页 > 理论基础 > 计算机网络

httpd+tomcat负载均衡

2015-12-03 14:30 645 查看

Windows Apache + Tomcat 负载均衡

环境准备

jdk 1.6

apache 2.2.* (解压版)

tomcat 6,7,8 (解压版)

设置java环境变量: JAVA_HOME='到bin目录之前的路径,不要有符号结尾'; PATH 前追加 '%JAVA_HOME%\bin;'解压版tomcat会用到这两个环境变量
[tomcat下载](http://tomcat.apache.org)选择 Deployer 版本 zip 下载, 解压后直接 运行 bin\startup.bat运行
[apache下载](http://httpd.apache.org/download.cgi)  apache(httpd)官方不提供windows版下载
可以网上查找 解压版本


apache + 1个 tomcat运行

apache整合tomcat必须要有Tomcat Connectors (mod_jk) 的支持 在tomcat官网Tomcat Connectors处下载 jakarta-tomcat-connectors-jk2.0.2-win32-apache1.3.27.zip 解压后将 mod_jk.so 文件拷贝到 apache modules目录下

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009


# The advanced router LB worker
worker.list=router
worker.router.type=lb
worker.router.balance_workers=worker1,worker2

# Define the first member worker
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
# Define preferred failover node for worker1
#worker.worker1.redirect=worker2

# Define the second member worker
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8010
# Disable worker2 for all requests except failover
#worker.worker2.activation=disabled


# Load mod_jk module
# Update this path to match your modules location
LoadModule    jk_module  C:\Apache22\modules\mod_jk.so
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile C:\Apache22\conf\workersBalancer.properties
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile     C:\Apache22\logs\mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount  /* router
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  httpd