先说问题
我看了很多博客,也看了jk的官网设置
配置成功,启动没报错。当启动3个tomcat的时候,远程或者本地访问都是访问tomcat1 2、3只有在1关闭的情况才会去访问
我2、3的lbfactor的权重配置都比1高。不知道为啥。
apache2.4 jk也是官网下载的。求高手帮忙,找出问题
我的项目中Tomcat7/conf/Catalina/中配置了多个host指向Root.xml
也用了druid数据库连接池
求兄弟们帮忙看下为啥
worker.properties配置
worker.list=controller,status
#========apache-tomcat-1========
worker.tomcat1.port=9009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
#========apache-tomcat-2========
worker.tomcat2.port=11009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=2
#========apache-tomcat-3========
worker.tomcat3.port=11009
worker.tomcat3.host=192.168.2.227
worker.tomcat3.type=ajp13
worker.tomcat3.lbfactor=10
#========controller========
worker.controller.type=lb
worker.controller.balance_workers=tomcat1,tomcat2,tomcat3
worker.status.type=status
#worker.controller.sticky_session=true
#worker.controller.sticky_session_force=false
apache的httpd.conf
G:/apache-tomcat-7.0.57/conf/workers.properties
G:/apache-tomcat-7.0.57/conf/server.xml
<?xmlversion='1.0'encoding='utf-8'?><!--LicensedtotheApacheSoftwareFoundation(ASF)underoneormorecontributorlicenseagreements.SeetheNOTICEfiledistributedwiththisworkforadditionalinformationregardingcopyrightownership.TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0(the"License");youmaynotusethisfileexceptincompliancewiththeLicense.YoumayobtainacopyoftheLicenseathttp://www.apache.org/licenses/LICENSE-2.0Unlessrequiredbyapplicablelaworagreedtoinwriting,softwaredistributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.SeetheLicenseforthespecificlanguagegoverningpermissionsandlimitationsundertheLicense.--><!--Note:A"Server"isnotitselfa"Container",soyoumaynotdefinesubcomponentssuchas"Valves"atthislevel.Documentationat/docs/config/server.html--><Serverport="8005"shutdown="SHUTDOWN"><ListenerclassName="org.apache.catalina.startup.VersionLoggerListener"/><!--Securitylistener.Documentationat/docs/config/listeners.html<ListenerclassName="org.apache.catalina.security.SecurityListener"/>--><!--APRlibraryloader.Documentationat/docs/apr.html--><ListenerclassName="org.apache.catalina.core.AprLifecycleListener"SSLEngine="on"/><!--InitializeJasperpriortowebappsareloaded.Documentationat/docs/jasper-howto.html--><ListenerclassName="org.apache.catalina.core.JasperListener"/><!--Preventmemoryleaksduetouseofparticularjava/javaxAPIs--><ListenerclassName="org.apache.catalina.core.JreMemoryLeakPreventionListener"/><ListenerclassName="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/><ListenerclassName="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/><!--GlobalJNDIresourcesDocumentationat/docs/jndi-resources-howto.html--><GlobalNamingResources><!--EditableuserdatabasethatcanalsobeusedbyUserDatabaseRealmtoauthenticateusers--><Resourcename="UserDatabase"auth="Container"type="org.apache.catalina.UserDatabase"description="Userdatabasethatcanbeupdatedandsaved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml"/></GlobalNamingResources><!--A"Service"isacollectionofoneormore"Connectors"thatshareasingle"Container"Note:A"Service"isnotitselfa"Container",soyoumaynotdefinesubcomponentssuchas"Valves"atthislevel.Documentationat/docs/config/service.html--><Servicename="Catalina"><!--Theconnectorscanuseasharedexecutor,youcandefineoneormorenamedthreadpools--><!--<Executorname="tomcatThreadPool"namePrefix="catalina-exec-"maxThreads="150"minSpareThreads="4"/>--><!--A"Connector"representsanendpointbywhichrequestsarereceivedandresponsesarereturned.Documentationat:JavaHTTPConnector:/docs/config/http.html(blocking&non-blocking)JavaAJPConnector:/docs/config/ajp.htmlAPR(HTTP/AJP)Connector:/docs/apr.htmlDefineanon-SSLHTTP/1.1Connectoronport8080--><Connectorport="8080"protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443"/><!--A"Connector"usingthesharedthreadpool--><!--<Connectorexecutor="tomcatThreadPool"port="8080"protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443"/>--><!--DefineaSSLHTTP/1.1Connectoronport8443ThisconnectorusestheBIOimplementationthatrequirestheJSSEstyleconfiguration.WhenusingtheAPR/nativeimplementation,theOpenSSLstyleconfigurationisrequiredasdescribedintheAPR/nativedocumentation--><!--<Connectorport="8443"protocol="org.apache.coyote.http11.Http11Protocol"maxThreads="150"SSLEnabled="true"scheme="https"secure="true"clientAuth="false"sslProtocol="TLS"/>--><!--DefineanAJP1.3Connectoronport8009--><Connectorport="8009"protocol="AJP/1.3"redirectPort="8443"/><!--AnEnginerepresentstheentrypoint(withinCatalina)thatprocesseseveryrequest.TheEngineimplementationforTomcatstandaloneanalyzestheHTTPheadersincludedwiththerequest,andpassesthemontotheappropriateHost(virtualhost).Documentationat/docs/config/engine.html--><!--YoushouldsetjvmRoutetosupportload-balancingviaAJPie:<Enginename="Catalina"defaultHost="localhost"jvmRoute="jvm1">--><Enginename="Catalina"defaultHost="localhost"><!--Forclustering,pleasetakealookatdocumentationat:/docs/cluster-howto.html(simplehowto)/docs/config/cluster.html(referencedocumentation)--><!--<ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>--><!--UsetheLockOutRealmtopreventattemptstoguessuserpasswordsviaabrute-forceattack--><RealmclassName="org.apache.catalina.realm.LockOutRealm"><!--ThisRealmusestheUserDatabaseconfiguredintheglobalJNDIresourcesunderthekey"UserDatabase".AnyeditsthatareperformedagainstthisUserDatabaseareimmediatelyavailableforusebytheRealm.--><RealmclassName="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/></Realm><Hostname="localhost"appBase="webapps"unpackWARs="true"autoDeploy="true"><!--SingleSignOnvalve,shareauthenticationbetweenwebapplicationsDocumentationat:/docs/config/valve.html--><!--<ValveclassName="org.apache.catalina.authenticator.SingleSignOn"/>--><!--Accesslogprocessesallexample.Documentationat:/docs/config/valve.htmlNote:Thepatternusedisequivalenttousingpattern="common"--><ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="logs"prefix="localhost_access_log."suffix=".txt"pattern="%h%l%u%t"%r"%s%b"/></Host></Engine></Service></Server>上面是主的tomcat 配置。
后面的其他tomcat的 workers.properties就改成这个就行了
workers.tomcat_home="G:\apache-tomcat-7.0.57\"#让mod_jk模块知道Tomcat的安装路径workers.java_home="C:\ProgramFiles\Java\jdk1.7.0_13\"#让mod_jk模块知道jdk路径worker.list=ajp13#这里是关键,名字要和httpd.conf的一致。如果这里改了httpd.conf也要改。worker.ajp13.port=8009#工作端口,tomcat的jk监听端口,可以查看Server.xml中有port="8009"worker.ajp13.host=127.0.0.1#Tomcat所在机器,如果安装在与apache不同的机器则需要设置IPworker.ajp13.type=ajp13#类型,好像不能改,会出问题worker.ajp13.lbfactor=1#负载平衡因子@红薯编辑器有点坑呀
@红薯 看一下你的编辑器问题,看上面的截图http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.htmltomcat可以自己配置VirtualHosting和apacheHttpd有啥区别呢
apache的httpd.conf
G:/apache-tomcat-7.0.57/conf/workers.properties
G:/apache-tomcat-7.0.57/conf/server.xml
<?xmlversion='1.0'encoding='utf-8'?><!--LicensedtotheApacheSoftwareFoundation(ASF)underoneormorecontributorlicenseagreements.SeetheNOTICEfiledistributedwiththisworkforadditionalinformationregardingcopyrightownership.TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0(the"License");youmaynotusethisfileexceptincompliancewiththeLicense.YoumayobtainacopyoftheLicenseathttp://www.apache.org/licenses/LICENSE-2.0Unlessrequiredbyapplicablelaworagreedtoinwriting,softwaredistributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.SeetheLicenseforthespecificlanguagegoverningpermissionsandlimitationsundertheLicense.--><!--Note:A"Server"isnotitselfa"Container",soyoumaynotdefinesubcomponentssuchas"Valves"atthislevel.Documentationat/docs/config/server.html--><Serverport="8005"shutdown="SHUTDOWN"><ListenerclassName="org.apache.catalina.startup.VersionLoggerListener"/><!--Securitylistener.Documentationat/docs/config/listeners.html<ListenerclassName="org.apache.catalina.security.SecurityListener"/>--><!--APRlibraryloader.Documentationat/docs/apr.html--><ListenerclassName="org.apache.catalina.core.AprLifecycleListener"SSLEngine="on"/><!--InitializeJasperpriortowebappsareloaded.Documentationat/docs/jasper-howto.html--><ListenerclassName="org.apache.catalina.core.JasperListener"/><!--Preventmemoryleaksduetouseofparticularjava/javaxAPIs--><ListenerclassName="org.apache.catalina.core.JreMemoryLeakPreventionListener"/><ListenerclassName="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/><ListenerclassName="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/><!--GlobalJNDIresourcesDocumentationat/docs/jndi-resources-howto.html--><GlobalNamingResources><!--EditableuserdatabasethatcanalsobeusedbyUserDatabaseRealmtoauthenticateusers--><Resourcename="UserDatabase"auth="Container"type="org.apache.catalina.UserDatabase"description="Userdatabasethatcanbeupdatedandsaved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml"/></GlobalNamingResources><!--A"Service"isacollectionofoneormore"Connectors"thatshareasingle"Container"Note:A"Service"isnotitselfa"Container",soyoumaynotdefinesubcomponentssuchas"Valves"atthislevel.Documentationat/docs/config/service.html--><Servicename="Catalina"><!--Theconnectorscanuseasharedexecutor,youcandefineoneormorenamedthreadpools--><!--<Executorname="tomcatThreadPool"namePrefix="catalina-exec-"maxThreads="150"minSpareThreads="4"/>--><!--A"Connector"representsanendpointbywhichrequestsarereceivedandresponsesarereturned.Documentationat:JavaHTTPConnector:/docs/config/http.html(blocking&non-blocking)JavaAJPConnector:/docs/config/ajp.htmlAPR(HTTP/AJP)Connector:/docs/apr.htmlDefineanon-SSLHTTP/1.1Connectoronport8080--><Connectorport="8080"protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443"/><!--A"Connector"usingthesharedthreadpool--><!--<Connectorexecutor="tomcatThreadPool"port="8080"protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443"/>--><!--DefineaSSLHTTP/1.1Connectoronport8443ThisconnectorusestheBIOimplementationthatrequirestheJSSEstyleconfiguration.WhenusingtheAPR/nativeimplementation,theOpenSSLstyleconfigurationisrequiredasdescribedintheAPR/nativedocumentation--><!--<Connectorport="8443"protocol="org.apache.coyote.http11.Http11Protocol"maxThreads="150"SSLEnabled="true"scheme="https"secure="true"clientAuth="false"sslProtocol="TLS"/>--><!--DefineanAJP1.3Connectoronport8009--><Connectorport="8009"protocol="AJP/1.3"redirectPort="8443"/><!--AnEnginerepresentstheentrypoint(withinCatalina)thatprocesseseveryrequest.TheEngineimplementationforTomcatstandaloneanalyzestheHTTPheadersincludedwiththerequest,andpassesthemontotheappropriateHost(virtualhost).Documentationat/docs/config/engine.html--><!--YoushouldsetjvmRoutetosupportload-balancingviaAJPie:<Enginename="Catalina"defaultHost="localhost"jvmRoute="jvm1">--><Enginename="Catalina"defaultHost="localhost"><!--Forclustering,pleasetakealookatdocumentationat:/docs/cluster-howto.html(simplehowto)/docs/config/cluster.html(referencedocumentation)--><!--<ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>--><!--UsetheLockOutRealmtopreventattemptstoguessuserpasswordsviaabrute-forceattack--><RealmclassName="org.apache.catalina.realm.LockOutRealm"><!--ThisRealmusestheUserDatabaseconfiguredintheglobalJNDIresourcesunderthekey"UserDatabase".AnyeditsthatareperformedagainstthisUserDatabaseareimmediatelyavailableforusebytheRealm.--><RealmclassName="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/></Realm><Hostname="localhost"appBase="webapps"unpackWARs="true"autoDeploy="true"><!--SingleSignOnvalve,shareauthenticationbetweenwebapplicationsDocumentationat:/docs/config/valve.html--><!--<ValveclassName="org.apache.catalina.authenticator.SingleSignOn"/>--><!--Accesslogprocessesallexample.Documentationat:/docs/config/valve.htmlNote:Thepatternusedisequivalenttousingpattern="common"--><ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="logs"prefix="localhost_access_log."suffix=".txt"pattern="%h%l%u%t"%r"%s%b"/></Host></Engine></Service></Server>上面是主的tomcat 配置。
后面的其他tomcat的 workers.properties就改成这个就行了
workers.tomcat_home="G:\apache-tomcat-7.0.57\"#让mod_jk模块知道Tomcat的安装路径workers.java_home="C:\ProgramFiles\Java\jdk1.7.0_13\"#让mod_jk模块知道jdk路径worker.list=ajp13#这里是关键,名字要和httpd.conf的一致。如果这里改了httpd.conf也要改。worker.ajp13.port=8009#工作端口,tomcat的jk监听端口,可以查看Server.xml中有port="8009"worker.ajp13.host=127.0.0.1#Tomcat所在机器,如果安装在与apache不同的机器则需要设置IPworker.ajp13.type=ajp13#类型,好像不能改,会出问题worker.ajp13.lbfactor=1#负载平衡因子@红薯编辑器有点坑呀
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。