在干净的 ubuntu server 12.04 中设置 2 个 tomcat6 实例集群时,我有点困惑。我没有安装默认的,tomcat6
我使用tomcat6-user
'stomcat6-instance-create
创建了 2 个实例。我正在使用博客教程,不幸的是我还没有遇到任何使用 ubuntu 的教程,了解如何apache2
像 ubuntu 12.o4 那样配置。我的意思是,sites-available/enabled
文件夹的结构以及mods-available/enabled
ubuntu 使用的结构。
我已经安装libapache2-mod-jk
并mods-enabled
有 jk.load、jk.conf。
server instance-1 uses port 8081 for http, port 8009 for ajp with jvmRoute="worker1" and instance-2 uses port 8082 for http, port 8010 for ajp with jvmRoute="worker2"
#/etc/apache2/workers.propeties
worker.list=loadbalancer,jk-status
#setup instance-1
worker.instance-1.port=8009
worker.instance-1.host=localhost
worker.instance-1.type=ajp13
#worker.instance-1.lbfactor=50
#setup instance-2
worker.instance-2.port=8010
worker.instance-2.host=localhost
worker.instance-2.type=ajp13
#worker.instance-2.lbfactor=100
#setup the load-balancer
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=instance-1,instance-2
worker.loadbalancer.sticky_session=True
#worker.loadbalancer.sticky_session_force=True
# Status worker for managing load balancer
worker.status.type=jk-status
这是 /etc/apache2/mods-available/jk.conf
<IfModule jk_module>
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkShmFile /var/log/apache2/jk-runtime-status
JkWatchdogInterval 60
<Location /jk-status>
# Inside Location we can omit the URL in JkMount
JkMount jk-status
Order deny,allow
Deny from all
Allow from 127.0.0.1 xxx.xxx.xxx.xxx
</Location>
<Location /jk-manager>
# Inside Location we can omit the URL in JkMount
JkMount jk-manager
Order deny,allow
Deny from all
Allow from 127.0.0.1 xxx.xxx.xxx.xxx
</Location>
# Example for Mounting a context to the worker "balancer"
# The URL syntax "a|b" instantiates two mounts at once,
# the first one is "a", the second one is "ab".
# JkMount /myapp|/* balancer
# Example for UnMounting requests for all workers
# using a simple URL pattern
# Since: 1.2.26
# JkUnMount /myapp/static/* *
# Example for UnMounting requests for a named worker
# JkUnMount /myapp/images/* balancer
# Example for UnMounting requests using regexps
# SetEnvIf REQUEST_URI "\.(htm|html|css|gif|jpg|js)$" no-jk
# Example for setting a reply timeout depending on the requets URL
# Since: 1.2.27
# SetEnvIf Request_URI "/transactions/" JK_REPLY_TIMEOUT=600000
# Example for disabling reply timeouts for certain request URLs
# Since: 1.2.27
# SetEnvIf Request_URI "/reports/" JK_REPLY_TIMEOUT=0
</IfModule>
这是我的虚拟主机
<VirtualHost *:80>
ServerAdmin [email protected]
ServerAlias live.myserver.com
#DocumentRoot /var/www
ServerName go2.myserver.com
JkMount /* loadbalancer
JkMount /status/* jk-status
JkMount /jk-manager/* jk-status
#Loglevel warn
ErrorLog /var/log/apache2/go.myserver_error_log
CustomLog /var/log/apache2/go.myserver_access_log combined
</VirtualHost>
编辑:经过几个小时的努力,负载平衡本身似乎已经起作用了。只是我无法通过xxx.xxx.xxx.xxx/jk-status
nor访问负载平衡器管理器页面。文件xxx.xxx.xxx.xxx/jk-manager
中还有这些条目mod_jk.log
[Mon May 06 13:34:48.633 2013] [9845:139723554592576] [info] init_jk::mod_jk.c (3252): mod_jk/1.2.32 () initialized
[Mon May 06 13:34:48.633 2013] [9845:139723554592576] [error] uri_worker_map_ext::jk_uri_worker_map.c (506): Could not find worker with name 'jk-manager' in uri map post processing.
[Mon May 06 13:34:48.633 2013] [9845:139723554592576] [error] uri_worker_map_ext::jk_uri_worker_map.c (506): Could not find worker with name 'jk-status' in uri map p/var/log/apache2/mod_jk.log
问题 1:我遗漏了什么?为什么它不起作用?
问题2:#DocumentRoot /var/www
真的有必要吗?
问题 3: jk.conf 文件JkMount
中的和中的有什么区别IfModule
JkMount
virtualhost
请帮助我正确设置。谢谢