(转)apache+tomcat 负载均衡

xiaoxiao2021-03-01  1

1 需求: apache-tomcat-5.5.27 jdk1.6.0_10 tomcat-connectors-1.2.27 httpd-2.2.10 2 安装: 1) 分别在三台机器上安装 tomcat,路径为/var/apps/apache-tomcat-5.5.27 2) 分别在三台机器上配置JDK,JAVA_PATH=/var/apps/jdk1.6.0_10 3) 在其中一台机器上安装apache,路径为/var/apps/httpd-2.2.10 4) 配置生成mod_jk.so 进入tomcat-connectors-1.2.27/native 执行:./configure --with-apxs=/var/apps/httpd-2.2.10/bin/apxs make;make install 3 配置apache: httpd.conf: LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties 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]" # JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" # JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理 JkMount /servlet/* loadbalancer JkMount /*.jsp loadbalancer 注:也可以把配置文件写在mod_jk.conf 文件中,然后在httpd.conf中,加入include conf/mod_jk.conf workers.properties: (自tomcat-connectors-1.2.27/conf中复制到httpd-2.2.10/conf中) workers.tomcat_home=/var/apps/apache-tomcat-5.5.27 workers.java_home=/var/apps/jdk1.6.0_10 ps=/ # The workers that your plugins should create and work with # Add 'inprocess' if you want JNI connector worker.list=loadbalancer ---不是tomcat服务器的Engine的名字 # , inprocess #DEFAULT ajp12 WORKER DEFINITION worker.ajp12.port=8009 worker.ajp12.host=192.168.0.126 # worker.worker名字.type =<worker类型>,下面的ajp13是协议类型,ajp12太是名字. worker.ajp12.type=ajp13 # a load balancing worker.Low lbfactor means less work done by the worker worker.ajp12.lbfactor=1 #DEFAULT ajp13 WORKER DEFINITION worker.ajp13.port=8009 worker.ajp13.host=192.168.0.128 worker.ajp13.type=ajp13 worker.ajp13.lbfactor=1 # Specify the size of the open connection pool. #worker.ajp13.connection_pool_size worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=ajp12,ajp13 # DEFAULT JNI WORKER DEFINITION # Defining a worker named inprocess and of type jni # Note that the name and the type do not have to match. worker.inprocess.type=jni # CLASSPATH DEFINITION # Additional class path components. worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar # Setting the command line for tomcat. # Note: The cmd_line string may not contain spaces. worker.inprocess.cmd_line=start # Not needed, but can be customized. #worker.inprocess.cmd_line=-config #worker.inprocess.cmd_line=$(workers.tomcat_home)$(ps)conf$(ps)server.xml #worker.inprocess.cmd_line=-home #worker.inprocess.cmd_line=$(workers.tomcat_home) # The JVM that we are about to use # This is for Java2 # Windows worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll # IBM JDK1.3 #worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)libjvm.so # Unix - Sun VM or blackdown #worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)classic$(ps)libjvm.so # And this is for jdk1.1.X #worker.inprocess.jvm_lib=$(workers.java_home)$(ps)bin$(ps)javai.dll # Setting the place for the stdout and stderr of tomcat worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr # Setting the tomcat.home Java property #worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home) # Java system properties # worker.inprocess.sysprops=java.compiler=NONE # worker.inprocess.sysprops=myprop=mypropvalue # Additional path components. # worker.inprocess.ld_path=d:$(ps)SQLLIB$(ps)bin4 配置tomcat: apache服务器的tomcat:不需要做什么修改 tomcat服务器: ajp12: <Engine name="Catalina" defaultHost="localhost" jvmRoute="ajp12"> ajp13: <Engine name="Catalina" defaultHost="localhost" jvmRoute="ajp13"> 5 启动服务: 启动tomcat,apache的服务 p.s. 出现错误:org.apache.jk.common.MsgAjp processHeader 严重: BAD packet signature 256 解决方法:workers.properties文件中,tomcat服务器的协议类型错误,应都改为ajp13,即为ajp协议V13.
转载请注明原文地址: https://www.6miu.com/read-3650199.html

最新回复(0)