1.启动nimbus,进程名为nimbusjava
在nimbus虚拟机上去输入 : nohup storm nimbus &shell
2.启动supervisor,进程名为supervisorapache
在supervisor虚拟机上去输入 : nohup storm supervisor &编程
3.启动ui,进程名为corebash
在集群全部虚拟机上输入 : nohup storm ui &ssh
4.启动logoop
在集群全部虚拟机上输入 : nohup storm log &ui
5.上传topolua
storm jar storm_topo.jar com.cjun.MainTopology myTopospa
storm_topo.jar:项目的jar包
com.cjun.MainTopology:主类的路径
myTopo:此topo在storm ui中显示的名称
6.杀死storm进程
先用jps查看storm进程,而后用:kill -9 x,杀死对应的进程,x为对应进程的进程号。
提交Topologies
命令格式:storm jar 【jar路径】 【拓扑包名.拓扑类名】 【拓扑名称】
样例:storm jar /storm-starter.jar storm.starter.WordCountTopology wordcountTop
#提交storm-starter.jar到远程集群,并启动wordcountTop拓扑。
中止Topologies
命令格式:storm kill 【拓扑名称】
样例:storm kill wordcountTop
#杀掉wordcountTop拓扑。
启动nimbus后台程序
命令格式:storm nimbus
启动supervisor后台程序
命令格式:storm supervisor
启动drpc服务
命令格式:storm drpc
启动ui服务
命令格式:storm ui
启动REPL
REPL — read-evaluate-print-loop。
虽然clojure能够做为一种脚本语言内嵌在java里面,可是它的首选编程方式是使用REPL,这是一个简单的命令行接口,使用它你能够输入你的命令,执行,而后查看结果, 你能够如下面这个命令来启动REPL:
命令格式:storm repl
打印本地配置
命令格式:storm localconfvalue 【配置参数关键字】
举例:storm localconfvalue storm.zookeeper.servers
#根据指定参数打印本地配置的值。
打印远程配置
命令格式:storm remoteconfvalue 【配置参数关键字】
举例:storm remoteconfvalue storm.zookeeper.servers
#根据指定参数打印远程配置的值。
执行Shell脚本
命令格式:storm shell resourcesdir command args
打印CLASSPATH
命令格式:storm classpath
1、设置节点间无密码访问
为了实现批量启动和中止,须要提早配置好各节点间的无密码访问,具体方法详见我之前的帖子或者问度娘,这里再也不介绍。
2、(主节点)切换当前路径到storm的bin目录下,并建立如下脚本和文件。
cd /software/storm/apache-storm-0.9.2-incubating/bin touch start-supervisor.sh touch start-all.sh touch stop-supervisor.sh touch stop-all.sh touch supervisor-hosts
赋予以上脚本可执行权限
chmod +x *.sh
3、脚本编写
一、start-supervisor.sh
#!/bin/bash . /etc/profile # storm的bin目录 bin=/software/storm/apache-storm-0.9.2-incubating/bin supervisors=$bin/supervisor-hosts storm nimbus >/dev/null 2>&1 & storm ui >/dev/null 2>&1 & cat $supervisors | while read supervisor do echo $supervisor ssh $supervisor $bin/start-supervisor.sh & done
二、start-supervisor.sh
#!/bin/bash . /etc/profile storm supervisor >/dev/null 2>&1 &
三、stop-all.sh
#!/bin/bash . /etc/profile # storm的bin目录 bin=/software/storm/apache-storm-0.9.2-incubating/bin supervisors=$bin/supervisor-hosts kill -9 `ps -ef|grep daemon.nimbus| awk '{print $2}'` kill -9 `ps -ef|grep ui.core| awk '{print $2}'` cat $supervisors | while read supervisor do echo $supervisor ssh $supervisor $bin/stop-supervisor.sh & done
四、stop-supervisor.sh
#!/bin/bash . /etc/profile kill -9 `ps -ef|grep daemon.supervisor| awk '{print $2}'` # 这里我直接清理了storm的工做路径和log文件,根据自身须要来设置 rm -rf /software/storm/workdir/* rm -rf /software/storm/apache-storm-0.9.2-incubating/logs/*
五、supervisor-hosts
文件中写入全部节点的主机名或者ip,格式以下:
storm1 storm2 storm3
4、脚本的使用
脚本须要在主节点上使用。为了便于使用,请确保环境变量中已经加入storm的bin目录。
将上文编辑好的start-supervisor和stop-supervisor脚本复制到全部节点相同路径下。
scp *-supervisor.sh storm2:/software/storm/apache-storm-0.9.2-incubating/bin scp *-supervisor.sh storm3:/software/storm/apache-storm-0.9.2-incubating/bin
start-all.sh
stop-all.sh
5、设置开机自启
要实现storm开机自启,比较简单的方法就是开机自动运行下以前的start-all脚本,设置方法以下
vi /etc/rc.d/rc.local
添加执行脚本
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local sh /software/storm/apache-storm-0.9.2-incubating/bin/start-all.sh