Storm学习的HelloWorld
1、下载Storm-start(https://github.com/nathanmarz/storm-starter/archive/master.zip)
2、进入下载目录,对zip文件解压
3、进入解压后的文件目录,修改m2-pom.xml(将twitter4j-core和twitter4j-stream替换为下面的部分)
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.2,)</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>[2.2,)</version>
</dependency>
4、编译项目。转到项目根目录,使用mvn -f m2-pom.xml package 进行编译
5、复制storm-starter目录下的m2_pom.xml为pom.xml,放在与m2_pom.xml同一目录下
6、打jar包mvn jar:jar
如果还需要对工程代码进行修改可以导入eclipse
使用mvn eclipse:eclipse编译成eclipse工程
eclipse import project
7、提交运行
拷贝jar包到Storm所在机器上
编译无误后,在Storm-starter中target目录下
将storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar,拷贝到指定的目录下面
8、执行命令:
./storm jar /usr/soft/stormrun/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.WordCountTopology test
不加test参数时,就会运行local形式,会将所有运行信息打印到控制台上,将会看到storm运行的每一步打印信息。
5186 [Thread-26] INFO backtype.storm.daemon.executor - Processing received message source: spout:8, stream: default, id: {}, [four score and seven years ago]four score and seven years ago-------------------5194 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [four]5195 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [score]5196 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [and]5197 [Thread-22] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [and]5198 [Thread-22] INFO backtype.storm.daemon.task - Emitting: count default [and, 1]5198 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [seven]5199 [Thread-20] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [four]5200 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [years]5201 [Thread-18] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [seven]5201 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [ago]5201 [Thread-18] INFO backtype.storm.daemon.task - Emitting: count default [seven, 1]5205 [Thread-20] INFO backtype.storm.daemon.task - Emitting: count default [four, 1]5205 [Thread-20] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [score]5205 [Thread-20] INFO backtype.storm.daemon.task - Emitting: count default [score, 1]
9、查看UI http://ip:8080 (端口号默认为8080,可以修改,一般为9090)