CentOS 6.4单机环境下安装配置Storm

Storm是一个分布式的、高容错的实时计算系统,在实时性要求比较强的应用场景下,可以用它来处理海量数据。我们尝试着搭建Storm平台,来实现实时计算。下面,我们在CentOS 6.4上安装配置Storm系统。

安装配置

安装配置过程,按照如下步骤进行:

1、安装配置sunjdk
下载sunjdk,并安装Java运行环境:

1 wget http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin
2 chmod +x jdk-6u45-linux-x64-rpm.bin
3 ./jdk-6u45-linux-x64.bin

配置Java运行时环境:

1 vi ~/.bashrc
2 export JAVA_HOME=/usr/java/jdk1.6.0_45/
3 export PATH=$PATH:$JAVA_HOME/bin
4 export CLASSPATH=$JAVA_HOME/lib/*.jar:$JAVA_HOME/jre/lib/*.jar
5 . ~/.bashrc
6 java -version

2、安装zeromq
执行如下命令,进行下载配置安装:

1 wget http://download.zeromq.org/zeromq-2.2.0.tar.gz
2 tar -zvxf zeromq-2.2.0.tar.gz
3 cd zeromq-2.2.0/
4 ./configure
5 sudo make
6 sudo make install

3、安装jzmq
安装jzmq需要使用Git下载源码,从源代码编译安装:

1 sudo yum install git
2 git clone git://github.com/nathanmarz/jzmq.git
3 cd jzmq/
4 sudo make
5 sudo make install

4、安装Storm
下载解压缩Storm软件包即可:

1 wget http://cloud.github.com/downloads/nathanmarz/storm/storm-0.8.1.zip
2 tar -xvzf storm-0.8.1.zip

然后配置环境变量:

1 cd storm-0.8.1/
2 vi ~/.bashrc
3 export STORM_HOME=/home/shirdrn/programs/storm-0.8.1
4 export PATH=$PATH:$STORM_HOME/bin
5 . ~/.bashrc

5、安装构建storm-starter
首先需要下载代码,并使用Maven构建:

1 git clone https://github.com/nathanmarz/storm-starter.git
2 cd storm-starter/
3 mvn -f m2-pom.xml package

如果需要把Storm的示例代码导入到Eclipse环境中,需要执行如下命令:

1 cd storm-starter/
2 cp m2-pom.xml pom.xml
3 mvn eclipse:eclipse

6、配置Storm
修改配置文件conf/storm.yaml内容如下所示:

01 storm.zookeeper.servers:
02 - "nn"
03 storm.zookeeper.port: 2181
04 nimbus.host: "nn"
05 storm.local.dir: "/home/shirdrn/programs/storm-0.8.1/tmp"
06 supervisor.slots.ports:
07 - 6700
08 - 6701
09 - 6702
10 - 6703

启动运行

1、启动Storm相关服务

  • 启动ZooKeeper
1 bin/zkServer.sh start
  • 启动Nimbus
1 bin/storm nimbus

查看日志,确定Nimbus启动是否成功:

1 [shirdrn@nn storm-0.8.1]$ tail -100f logs/nimbus.log
  • 启动Supervisor
1 bin/storm supervisor

查看日志,确定Supervisor启动是否成功:

1 [shirdrn@nn storm-0.8.1]$ tail -100f logs/supervisor.log

2、提交一个Topology
上面,已经使用Maven构建storm-starter工程,在target目录下生成一个jar文件,然后将该storm-starter工程中的WordCountTopology提交到Nimbus,执行如下命令:

1 bin/storm jar ../storm-starter/target/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.WordCountTopology myFirstStormApp

上面myFirstStormApp是提交的Topology的名称,可以看到提交Topology的日志信息:

1 0 [main] INFO backtype.storm.StormSubmitter - Jar not uploaded to master yet. Submitting jar...
2 12 [main] INFO backtype.storm.StormSubmitter - Uploading topology jar ../storm-starter/target/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar to assigned location: /home/shirdrn/programs/storm-0.8.1/tmp/nimbus/inbox/stormjar-0ae68c15-130d-46f9-a46a-69dd4de29a99.jar
3 119 [main] INFO backtype.storm.StormSubmitter - Successfully uploaded topology jar to assigned location: /home/shirdrn/programs/storm-0.8.1/tmp/nimbus/inbox/stormjar-0ae68c15-130d-46f9-a46a-69dd4de29a99.jar
4 119 [main] INFO backtype.storm.StormSubmitter - Submitting topology myFirstStormApp in distributed mode with conf {"topology.workers":3,"topology.debug":true}
5 423 [main] INFO backtype.storm.StormSubmitter - Finished submitting topology: myFirstStormApp

这时,可以通过查看worker的日志,来确定我们提交的Topology的执行情况:

1 [shirdrn@nn storm-0.8.1]$ tail -100f logs/worker-6700.log
2 [shirdrn@nn storm-0.8.1]$ tail -100f logs/worker-6701.log
3 [shirdrn@nn storm-0.8.1]$ tail -100f logs/worker-6702.log
4 [shirdrn@nn storm-0.8.1]$ tail -100f logs/worker-6703.log

worker日志文件名称的后缀正好对应于我们在配置文件conf/storm.yaml中配置supervisor.slots.ports中的端口号。
如果只是上面的命令不带参数,表示虚拟测试该程序,如下所示:

1 bin/storm jar ../storm-starter/target/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.WordCountTopology

可以看到具体模拟执行的情况,它并不将这个Topology提交给Nimbus。

3、Storm管理命令
可以通过如下命令查看Storm的管理操作命令:

1 bin/storm help

下面,给出一些常用的命令:

  • 查询当前运行的Topology
1 bin/storm list
  • 杀掉运行中的Topology
1 bin/storm kill myFirstStormApp

问题说明

在安装Storm的过程中,有关一些依赖安装包的问题,不像在Ubuntu系统下,可以模糊指定软件包名称,然后会给出一些提示信息,CentOS需要明确地指定软件包名称,记录下一下在安装过程中遇到的问题及其解决办法。

1、出现错误:configure: error: Unable to find a working C++ compiler
需要安装g++编译器:

1 sudo yum install gcc-c++

2、出现错误:configure: error: cannot link with -luuid, install uuid-dev.
需要安装软件包uuid-devel和libuuid-devel:

1 sudo yum install uuid-devel
2 sudo yum install libuuid-devel

3、出现错误:autogen.sh: error: could not find libtool. libtool is required to run autogen.sh.
需要安装libtool:

1 sudo yum install libtool
上一篇:多数据源并且数据库类型不同的情况下PageHelper的使用


下一篇:在E-MapReduce集群内运行Spark GraphX作业