找不到名为“ajp13_worker”的工人
Posted
技术标签:
【中文标题】找不到名为“ajp13_worker”的工人【英文标题】:Could not find worker with name 'ajp13_worker' 【发布时间】:2020-03-20 23:24:01 【问题描述】:我有一个带有 Apache 2 + Tomcat 9 的新 Debian 10 服务器。由于内部服务器错误,我无法运行 JSF 页面。我认为错误在于 Apache Tomcat 连接器 (libapache2-mod-jk) ..
我使用 OpenJDK v. 11,我还使用 APR 版本 [1.7.0] 的 Apache Tomcat Native 库 [1.2.23]。 Tomcat 和 Apache 定期运行。
这是我的workers.properties 文件:
# workers.properties -
#
# This file is a simplified version of the workers.properties supplied
# with the upstream sources. The jni inprocess worker (not build in the
# debian package) section and the ajp12 (deprecated) section are removed.
#
# As a general note, the characters $( and ) are used internally to define
# macros. Do not use them in your own configuration!!!
#
# Whenever you see a set of lines such as:
# x=value
# y=$(x)\something
#
# the final value for y will be value\something
#
# Normaly all you will need to do is un-comment and modify the first three
# properties, i.e. workers.tomcat_home, workers.java_home and ps.
# Most of the configuration is derived from these.
#
# When you are done updating workers.tomcat_home, workers.java_home and ps
# you should have 3 workers configured:
#
# - An ajp13 worker that connects to localhost:8009
# - A load balancer worker
#
#
# OPTIONS ( very important for jni mode )
#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/usr/share/tomcat9
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/lib/jvm/java-11-openjdk-amd64
#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/
#
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
#
#
#------ worker list ------------------------------------------
#---------------------------------------------------------------------
#
#
# The workers that your plugins should create and work with
#
worker.list=ajp13_worker
#
#------ ajp13_worker WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#
#
# Defining a worker named ajp13_worker and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp13_worker.lbfactor=1
#
# Specify the size of the open connection cache.
#worker.ajp13_worker.cachesize
#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#
#
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# workers.
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=ajp13_worker
这是我的 httpd-jk.conf 文件:
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Configuration Example for mod_jk
# used in combination with Apache 2.2.x
<IfModule jk_module>
# We need a workers file exactly once
# and in the global server
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
# Our JK error log
# You can (and should) use rotatelogs here
JkLogFile /var/log/apache2/mod_jk.log
# Our JK log level (trace,debug,info,warn,error)
JkLogLevel debug
# Our JK shared memory file
JkShmFile /var/log/apache2/jk-runtime-status
# Define a new log format you can use in any CustomLog in order
# to add mod_jk specific information to your access log.
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%Refereri\" \"%User-Agenti\" \"%Cookiei\" \"%Set-Cookieo\" %pidP %tidP %JK_LB_FIRST_NAMEn %JK_LB_LAST_NAMEn ACC %JK_LB_LAST_ACCESSEDn ERR %JK_LB_LAST_ERRORSn BSY %JK_LB_LAST_BUSYn %JK_LB_LAST_STATEn %D" extended_jk
# This option will reject all requests, which contain an
# encoded percent sign (%25) or backslash (%5C) in the URL
# If you are sure, that your webapp doesn't use such
# URLs, enable the option to prevent double encoding attacks.
# Since: 1.2.24
# JkOptions +RejectUnsafeURI
# After setting JkStripSession to "On", mod_jk will
# strip all ";jsessionid=..." from request URLs it
# does *not* forward to a backend.
# This is useful, if all links in a webapp use
# URLencoded session IDs and parts of the static
# content should be delivered directly by Apache.
# Of course you can also do it with mod_rewrite.
# Since: 1.2.21
# JkStripSession On
# Start a separate thread for internal tasks like
# idle connection probing, connection pool resizing
# and load value decay.
# Run these tasks every JkWatchdogInterval seconds.
# Since: 1.2.27
JkWatchdogInterval 60
# Configure access to jk-status and jk-manager
# If you want to make this available in a virtual host,
# either move this block into the virtual host
# or copy it logically there by including "JkMountCopy On"
# in the virtual host.
# Add an appropriate authentication method here!
<Location /jk-status>
# Inside Location we can omit the URL in JkMount
JkMount jk-status
Require ip 127.0.0.1
</Location>
<Location /jk-manager>
# Inside Location we can omit the URL in JkMount
JkMount jk-manager
Require ip 127.0.0.1
</Location>
# If you want to put all mounts into an external file
# that gets reloaded automatically after changes
# (with a default latency of 1 minute),
# you can define the name of the file here.
# JkMountFile conf/extra/uriworkermap.properties
# 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 request 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
# IMPORTANT: Mounts and virtual hosts
# If you are using VirtualHost elements, you
# - can put mounts only used in some virtual host into its VirtualHost element
# - can copy all global mounts to it using "JkMountCopy On" inside the VirtualHost
# - can copy all global mounts to all virtual hosts by putting
# "JkMountCopy All" into the global server
# Since: 1.2.26
</IfModule>
这是我的 mod_jk.log 日志文件(我用 www.mydomain.com 替换了我的真实域)
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] jk_set_time_fmt::jk_util.c (487): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S.000 %Y] '
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] dump_options::mod_jk.c (678): JkOption 'ForwardURIProxy' set in server 'www.mydomain.com [*:80]' (default)
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] dump_options::mod_jk.c (698): JkOption 'ForwardKeySize' set in server 'www.mydomain.com [*:80]' (default)
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_open::jk_uri_worker_map.c (898): rule map size is 1
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_add::jk_uri_worker_map.c (848): wildchar rule '/*=ajp13_worker' source 'JkMount' was added
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after map open: id=0, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [info] init_jk::mod_jk.c (3591): mod_jk/1.2.46 initialized
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] wc_get_worker_for_name::jk_worker.c (120): did not find a worker ajp13_worker
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [error] extension_fix::jk_uri_worker_map.c (580): Could not find worker with name 'ajp13_worker' in uri map post processing.
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after extension stripping: id=2, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
[Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_switch::jk_uri_worker_map.c (602): Switching uri worker map from index 0 to index 1
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] jk_set_time_fmt::jk_util.c (487): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S.000 %Y] '
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] dump_options::mod_jk.c (678): JkOption 'ForwardURIProxy' set in server 'www.mydomain.com [*:80]' (default)
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] dump_options::mod_jk.c (698): JkOption 'ForwardKeySize' set in server 'www.mydomain.com [*:80]' (default)
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_open::jk_uri_worker_map.c (898): rule map size is 1
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_add::jk_uri_worker_map.c (848): wildchar rule '/*=ajp13_worker' source 'JkMount' was added
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after map open: id=0, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
[Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [info] init_jk::mod_jk.c (3591): mod_jk/1.2.46 initialized
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] wc_get_worker_for_name::jk_worker.c (120): did not find a worker ajp13_worker
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [error] extension_fix::jk_uri_worker_map.c (580): Could not find worker with name 'ajp13_worker' in uri map post processing.
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after extension stripping: id=2, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
[Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_switch::jk_uri_worker_map.c (602): Switching uri worker map from index 0 to index 1
我的 Apache 是:
<VirtualHost *:80>
DocumentRoot "/var/www/vhosts/www.mydomain.com/ROOT"
ServerName www.mydomain.com
ServerAdmin info@mydomain.com
JkMount /* ajp13_worker
JkLogLevel debug
<Directory "/var/www/vhosts/www.mydomain.com/ROOT">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
Apache 好像找不到“ajp13_worker”worker..
为什么?
谢谢。
【问题讨论】:
【参考方案1】:您必须将 JK 配置文件从 httpd-jk.conf
重命名为 jk.conf
。
这对我有用:
$ sudo a2dismod jk
$ sudo mv /etc/apache2/mods-available/httpd-jk.conf /etc/apache2/mods-available/jk.conf
$ cd /etc/libapache2-mod-jk/
$ sudo ln -f -s ../apache2/mods-available/jk.conf httpd-jk.conf
$ sudo a2enmod jk
$ sudo apache2ctl configtest
$ sudo systemctl restart apache2
【讨论】:
sudo apache2ctl configtest AH00526:/etc/apache2/sites-enabled/example.com-le-ssl.conf 第 1 行的语法错误:仅在操作“configtest”失败后才允许 JkWorkersFile。 Apache 错误日志可能包含更多信息。 对不起,上面的评论是针对@Bernat 下面的解决方案,但是您的解决方案没有解决问题,仍然得到找不到工人姓名【参考方案2】:我遇到了这个问题。通过分析 Apache 日志(error.log),我注意到文件 /etc/apache2/mods-available/httpd-jk.conf(来自 /etc/libapache2-mod-jk/httpd-jk.conf 的符号链接)是未加载,因为 Apache 修复了日志文件的默认名称(JkLogFile 指令)。 然后只需复制 /etc/apache2/conf-available 下的 httpd-jk.conf 文件,然后将此副本的符号链接到目标 /etc/apache2/conf-enabled ,一切正常。
【讨论】:
【参考方案3】:您必须在您的 apache 文件中定义 JK 选项,在虚拟主机之前,而不是在。例如:
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkLogFile $APACHE_LOG_DIR/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JKWorkersFile 是必需的,其他是可选的。
【讨论】:
sudo apache2ctl configtest AH00526:/etc/apache2/sites-enabled/example.com-le-ssl.conf 第 1 行的语法错误:仅在操作“configtest”失败后才允许 JkWorkersFile。 Apache 错误日志可能包含更多信息。以上是关于找不到名为“ajp13_worker”的工人的主要内容,如果未能解决你的问题,请参考以下文章