httpd+tomcat负载均衡

来源:互联网 发布:javascript display 编辑:程序博客网 时间:2024/05/17 01:26

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 ajp13worker.list=worker1# Set properties for worker1 (ajp13)worker.worker1.type=ajp13worker.worker1.host=localhostworker.worker1.port=8009
# The advanced router LB workerworker.list=routerworker.router.type=lbworker.router.balance_workers=worker1,worker2# Define the first member workerworker.worker1.type=ajp13worker.worker1.host=localhostworker.worker1.port=8009# Define preferred failover node for worker1#worker.worker1.redirect=worker2# Define the second member workerworker.worker2.type=ajp13worker.worker2.host=localhostworker.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 locationLoadModule    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 formatJkLogStampFormat "[%a %b %d %H:%M:%S %Y] "# Send everything for context /examples to worker named worker1 (ajp13)JkMount  /* router
0 0