Java 停止风暴:正确的方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19926548/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 21:35:26  来源:igfitidea点击:

Stopping Storm: the right way

javaapache-storm

提问by zenbeni

Is there a clean way to stop storm without killing it with "kill XXX" where XXX is the PID?

有没有一种干净的方法来阻止风暴而不用“杀死XXX”来杀死它,其中XXX是PID?

I run "storm kill topology-name" to kill the topology, but after that, is there a clean way to shutdown workers, nimbus, supervisor and ui?

我运行“storm kill topology-name”来终止拓扑,但是在那之后,有没有一种干净的方法来关闭工作人员、nimbus、主管和用户界面?

I didn't find any command which corresponds to this from the documentation: https://github.com/nathanmarz/storm/wiki/Command-line-client

我没有从文档中找到与此对应的任何命令:https: //github.com/nathanmarz/storm/wiki/Command-line-client

采纳答案by user2720864

Command to kill a topology (as you rightly mentioned):

杀死拓扑的命令(正如您正确提到的):

storm kill topology-name

To shutdown the cluster you need to run the following command on each node:

要关闭集群,您需要在每个节点上运行以下命令:

sudo service supervisord stop

Note:give supervisorda few seconds to shutdown all processes. Note that trying to run supervisorctlwhen supervisord itself is stopped will result in an error message (this appears to be a known user interface issue in supervisord 2.x)

注意:supervisord几秒钟时间关闭所有进程。请注意,supervisorctl在 supervisord 本身停止时尝试运行将导致错误消息(这似乎是 supervisord 2.x 中的已知用户界面问题)

From thisdocumentation

这个文档

How to kill ALL Storm processes including worker processes? Any worker threads (launched by the Supervisor daemons on the slave nodes) that happen to be running when you are stopping the cluster will continue to run. This is a deliberate design decision of Storm because it means that crashing/restarting Nimbus and Supervisor daemons will not affect any running topologies in Storm. The downside is that you have to put some extra effort into fully stopping all Storm-related processes in a cluster.

如何杀死包括工作进程在内的所有 Storm 进程?当您停止集群时碰巧正在运行的任何工作线程(由从节点上的 Supervisor 守护程序启动)将继续运行。这是 Storm 的一个深思熟虑的设计决定,因为这意味着崩溃/重启 Nimbus 和 Supervisor 守护进程不会影响 Storm 中任何正在运行的拓扑。缺点是你必须付出一些额外的努力来完全停止集群中所有与 Storm 相关的进程。

If you want to kill ALL processes follow this procedure on the slave nodes:

如果要终止所有进程,请在从节点上执行以下步骤:

$ sudo supervisorctl stop storm-supervisor
$ sudo pkill -TERM -u storm -f 'backtype.storm.daemon.worker'

回答by Stephen C

From the page that you linked to:

从您链接到的页面:

kill

Syntax: storm kill topology-name [-w wait-time-secs]

Kills the topology with the name topology-name. Storm will first deactivate the topology's spouts for the duration of the topology's message timeout to allow all messages currently being processed to finish processing. Storm will then shutdown the workers and clean up their state. You can override the length of time Storm waits between deactivation and shutdown with the -w flag.

语法:storm kill topology-name [-w wait-time-secs]

终止名为topology-name 的拓扑。Storm 将首先在拓扑的消息超时期间停用拓扑的 spout,以允许当前正在处理的所有消息完成处理。Storm 然后将关闭工人并清理他们的状态。您可以使用 -w 标志覆盖 Storm 在停用和关闭之间等待的时间长度。

As you can see, this is designed to give you a "clean" shutdown. The kill command shuts down the workers.

如您所见,这旨在为您提供“干净”的关机。kill 命令关闭工作进程。

回答by Sam

Well if you have started storm as ./storm nimbus & ./storm supervisor & ./storm ui then

好吧,如果你已经开始风暴作为 ./storm nimbus & ./storm supervisor & ./storm ui 那么

after that you may forgot the process id's in that case you can use jps tool to find out pid's then kill them as

之后您可能会忘记进程ID,在这种情况下您可以使用jps工具找出pid然后将它们杀死

$JAVA_HOME/bin/jps

$JAVA_HOME/bin/jps

3201 ConsoleConsumer

3201 控制台消费者

7528 Jps

7528 日元

2966 Kafka

2966 卡夫卡

3680 nimbus

3680 灵气

3681 supervisor

3681主管

6749 Launcher

6749 发射器

2669 QuorumPeerMain

第2669章

killing nimbus first

先杀死灵气

$ sudo kill 3681

$ sudo 杀死 3681

$ sudo kill 3680

$ sudo 杀死 3680