如何在 Eclipse 中调试 Apache Storm?
How to debug Apache Storm in Eclipse?
我们可以使用特定参数生成风暴 jar。但是,如果我们需要在本地和远程调试这个项目(实际上很远)?
如果是简单的jar,那我们就可以debug了。但是,这里我们使用以下命令部署 jar:
风暴罐project.jarmain_class_name
不知道如何部署storm topology,才能在调试模式下做storm项目?
请找到更新后的 yaml 文件如下:
# 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.
########### These MUST be filled in for a storm configuration
# storm.zookeeper.servers:
# - "server1"
# - "server2"
#
# nimbus.host: "nimbus"
#
#
# ##### These may optionally be filled in:
#
## List of custom serializations
# topology.kryo.register:
# - org.mycompany.MyType
# - org.mycompany.MyType2: org.mycompany.MyType2Serializer
#
## List of custom kryo decorators
# topology.kryo.decorators:
# - org.mycompany.MyDecorator
#
## Locations of the drpc servers
# drpc.servers:
# - "server1"
# - "server2"
## Metrics Consumers
# topology.metrics.consumer.register:
# - class: "backtype.storm.metric.LoggingMetricsConsumer"
# parallelism.hint: 1
# - class: "org.mycompany.MyMetricsConsumer"
# parallelism.hint: 1
# argument:
# - endpoint: "metrics-collector.mycompany.org"
worker.childopts:"-agentlib:jdwp=transport=dt_socket,server=y,address=8999,suspend=n"
如果要远程调试,需要在工作 JVM 中启用调试。请在此处查看正确的 Java 标志:Remote debugging a Java application
将 all/shared 主管 storm.yaml
中的此标志添加到条目 worker.childopts
(可能需要重新启动 Storm 集群)。 您需要确保每个主机只启动一个 worker! 否则,两个 JVM 想要打开同一个端口,一个当然会失败。
在 Eclipse 中,选择 Run -> Debug Configuration
并创建一个新的 Remote Java Application
。指定要调试的 运行 worker JVM 的主机和端口(端口必须与 worker.childopts
中指定的相同)。
要启用跨各种主管 VM 的调试,您只需编辑 storm.yaml 文件并将 worker.childopts 条目更新为类似以下内容:
worker.childopts: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5%ID%"
如果您的主管在端口 6700、6701、6702 等上,这将在 56700、56701、56702 等上创建一个调试端口。
我们可以使用特定参数生成风暴 jar。但是,如果我们需要在本地和远程调试这个项目(实际上很远)?
如果是简单的jar,那我们就可以debug了。但是,这里我们使用以下命令部署 jar: 风暴罐project.jarmain_class_name
不知道如何部署storm topology,才能在调试模式下做storm项目?
请找到更新后的 yaml 文件如下:
# 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.
########### These MUST be filled in for a storm configuration
# storm.zookeeper.servers:
# - "server1"
# - "server2"
#
# nimbus.host: "nimbus"
#
#
# ##### These may optionally be filled in:
#
## List of custom serializations
# topology.kryo.register:
# - org.mycompany.MyType
# - org.mycompany.MyType2: org.mycompany.MyType2Serializer
#
## List of custom kryo decorators
# topology.kryo.decorators:
# - org.mycompany.MyDecorator
#
## Locations of the drpc servers
# drpc.servers:
# - "server1"
# - "server2"
## Metrics Consumers
# topology.metrics.consumer.register:
# - class: "backtype.storm.metric.LoggingMetricsConsumer"
# parallelism.hint: 1
# - class: "org.mycompany.MyMetricsConsumer"
# parallelism.hint: 1
# argument:
# - endpoint: "metrics-collector.mycompany.org"
worker.childopts:"-agentlib:jdwp=transport=dt_socket,server=y,address=8999,suspend=n"
如果要远程调试,需要在工作 JVM 中启用调试。请在此处查看正确的 Java 标志:Remote debugging a Java application
将 all/shared 主管 storm.yaml
中的此标志添加到条目 worker.childopts
(可能需要重新启动 Storm 集群)。 您需要确保每个主机只启动一个 worker! 否则,两个 JVM 想要打开同一个端口,一个当然会失败。
在 Eclipse 中,选择 Run -> Debug Configuration
并创建一个新的 Remote Java Application
。指定要调试的 运行 worker JVM 的主机和端口(端口必须与 worker.childopts
中指定的相同)。
要启用跨各种主管 VM 的调试,您只需编辑 storm.yaml 文件并将 worker.childopts 条目更新为类似以下内容:
worker.childopts: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5%ID%"
如果您的主管在端口 6700、6701、6702 等上,这将在 56700、56701、56702 等上创建一个调试端口。