说明
Strom版本: 0.9.5
每台机器上都有$STORM_HOME指向其安装目录。
storm的安装是从官网下载后直接解压即可。
1、配置文件
1.1 $STORM_HOME/conf/storm.yaml中加入或修改如下内容:
nimbus.host: "主节点hostname或ip"
nimbus.thrift.port: 8627
nimbus.childopts: "-Xmx1024m"
storm.zookeeper.port: 8184
storm.zookeeper.root: "/storm"
storm.zookeeper.servers:
- "zooHost1"
- "zooHost2"
- "zooHost3"
ui.host: 0.0.0.0
ui.port: 8080
ui.childopts: "-Xmx768m"
logviewer.port: 8000
logviewer.childopts: "-Xmx128m"
supervisor.childopts: "-Xmx256m"
supervisor.slots.ports:
- 8701
- 8702
- 8703
- 8704
- 8705
- 8706
worker.childopts: "-Xmx768m"
其中,出supervisor开头的选项外,其他配置项在各个节点上的配置都可以相同。
1.2 $STORM_HOME/logback/cluster.xml中的内容定义storm如何记录日志,是logback的格式。
1.3 屏蔽storm的ui的kill功能(有时在线上部署storm的时候,希望能屏蔽掉拓扑的kill按钮,避免有人误操作)
在各服务器上修改一个文件(该服务器是启动了ui进程的服务器),以屏蔽storm的ui的kill功能
修改的文件名:$STORM_HOME/public/templates/topology-page-template.html
修改此文件中的“<script id="topology-actions-template" type="text/html">”部分,用“<!-- -->”注释掉其中的4行全部内容,如下所示。
<input {{activateStatus}} οnclick="confirmAction('{{encodedId}}', '{{name}}', 'activate', false, 0)" type="button" value="Activate">
<input {{deactivateStatus}} οnclick="confirmAction('{{encodedId}}', '{{name}}', 'deactivate', false, 0)" type="button" value="Deactivate">
<input {{rebalanceStatus}} οnclick="confirmAction('{{encodedId}}', '{{name}}', 'rebalance', true, {{msgTimeout}})" type="button" value="Rebalance">
<input {{killStatus}} οnclick="confirmAction('{{encodedId}}', '{{name}}', 'kill', true, 30)" type="button" value="Kill">
2、相关命令
- 启动主节点:
启动时机:ui(http://主节点ip:ui端口/)访问首页出错,新部署的拓扑无法启动等。主节点一般都是不需要重启的,除非进程不存在了。 ps -ef|grep nimbus 如果结果中有相关进程,说明已启动;如需重启,可直接kill掉现有进程 nohup $STORM_HOME/bin/storm nimbus > $STORM_HOME/logs/nimbus.out 2>&1 & 执行完成后,通过安装目录下的logs目录中的nimbus.log文件查看是否有错误,并通过ps命令查看进程是否存在。
- 启动UI节点:
启动时机:ui无法通过浏览器访问“http://主节点ip:ui端口/” ps -ef|grep ui.core 如果结果中有相关进程,说明已启动;如需重启,可直接kill掉现有进程 nohup $STORM_HOME/bin/storm ui > $STORM_HOME/logs/ui.out 2>&1 & 执行完成后,通过安装目录下的logs目录中的ui.log文件查看是否有错误,并通过ps命令查看进程是否存在。
- 启动supervisor:在所有安装storm节点的机器上都需要执行
启动时机:ui(http://主节点ip:ui端口/)中显示的“Supervisor summary”列表中的host列中会有每台机器的主机名 如果某一台没有,则重启该服务。
-
ps -ef|grep daemon.supervisor 如果结果中有相关进程,说明已启动;如需重启,可直接kill掉该进程 nohup $STORM_HOME/bin/storm supervisor > $STORM_HOME/logs/supervisor.out 2>&1 & 执行完成后,通过安装目录下的logs目录中的supervisor.log文件查看是否有错误,并通过ps命令查看进程是否存在
- kill脚本(kill某个拓扑):
$STORM_HOME/bin/killTopology.sh 内容如下,使用方式为“killTopology.sh topologyName”: echo "trying to exucute '$STORM_HOME/bin/storm kill $1'" $STORM_HOME/bin/storm kill $1; i=1; while [ $i -gt 0 ] do echo "tying to test whether topology has been killed" echo "command is: $STORM_HOME/bin/storm list"; $STORM_HOME/bin/storm list > listResult$1.log i=`grep $1 listResult$1.log | wc -l` if [ $i -gt 0 ] then echo "$1 has not been killed!"; fi done echo "$1 killed!"
提交jar(写好的storm任务)到storm:在主节点上执行
$STORM_HOME/bin/storm jar jar文件位置 主类名称 主类的main方法参数;
- kill脚本(kill某个拓扑):promise_kafka_storm4320
$STORM_HOME/bin/killTopology.sh 内容如下: echo "trying to exucute '$STORM_HOME/bin/storm kill $1'" $STORM_HOME/bin/storm kill $1; i=1; while [ $i -gt 0 ] do echo "tying to test whether topology has been killed" echo "command is: $STORM_HOME/bin/storm list"; $STORM_HOME/bin/storm list > listResult$1.log i=`grep $1 listResult$1.log | wc -l` if [ $i -gt 0 ] then echo "$1 has not been killed!"; fi done echo "$1 killed!"