Storm 的安装
java6 SDK以上版本
python 2.6以上版本
每台机器的/et/hosts文件修改:
# vi /etc/hosts
10.24.1.40 HOSTMASTER
10.24.1.170 HOST1
10.24.1.171 HOST2
每台安装ZeroMQ,目前只能用2.1.7版本:
# tar -zxvf zeromq-2.1.7.tar.gz
# cd zeromq-2.1.7
# ./configure
# make
# make install
每台安装JZMQ:
# unzip nathanmarz-jzmq-dd3327d.zip
# cd nathanmarz-jzmq-dd3327d
# ./autogen.sh
# ./configure
# make
# make install
库libjzmq.a和libjzmq.so安装在/usr/local/lib/目录下。
jar文件zmq.jar安装在/usr/local/share/java/目录下。
# ldconfig
# ldconfig -p|grep zmq
# ldconfig -v|grep zmq
选3到5台机器安装zookeeper:
# tar -zxvf zookeeper-3.3.3-cdh3u2.tar.gz
# cd zookeeper-3.3.3-cdh3u2
# vi conf/zoo.cfg
…
clientPort=2181
server.0=HOSTMASTER:2888:3888
server.1=HOST1:2888:3888
server.2=HOST2:2888:3888
# echo 0 > /var/zookeeper/myid (每台zookeeper机器不同:# echo 1 > /var/zookeeper/myid 或者# echo 2 > /var/zookeeper/myid)
# bin/zkServer.sh start (每台zookeeper机器都要执行)
# echo “stat” | nc HOSTMASTER 2181
Zookeeper version: 3.3.3-cdh3u2–1, built on 10/14/2011 03:25 GMT
Clients:
/10.24.1.40:53237[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 8
Sent: 7
Outstanding: 0
Zxid: 0x0
Mode: follower
Node count: 4
# echo “conf” | nc HOSTMASTER 2181
clientPort=2181
dataDir=/var/zookeeper/version-2
dataLogDir=/var/zookeeper/version-2
tickTime=2000
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=0
initLimit=10
syncLimit=5
electionAlg=3
electionPort=3888
quorumPort=2888
peerType=0
# echo “dump” | nc HOSTMASTER 2181
SessionTracker dump:
org.apache.zookeeper.server.quorum.LearnerSessionTracker@77addb59
ephemeral nodes dump:
Sessions with Ephemerals (0):
# echo “wchs” | nc HOSTMASTER 2181
0 connections watching 0 paths
Total watches:0
# echo “ruok” | nc HOSTMASTER 2181
imok
# bin/zkCli.sh stat /
WatchedEvent state:SyncConnected type:None path:null
cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1
# bin/zkCli.sh ls /
WatchedEvent state:SyncConnected type:None path:null<input type=”button” >
[zookeeper]
每台安装Storm:
# unzip storm-0.5.4.zip
# cd storm-0.5.4
# vi conf/storm.yaml
storm.zookeeper.servers:
– “HOSTMASTER”
– “HOST1”
– “HOST2”
storm.zookeeper.port: 2181
storm.local.dir: “/mnt/storm”
java.library.path: /usr/local/lib:/opt/local/lib:/usr/lib
nimbus.host: “HOSTMASTER”
supervisor.slots.ports:
– 6700
– 6701
– 6702
– 6703
…
上面storm.local.dir表示storm需要用到的本地目录,比如topology的jar文件保存,它用到的zookeeper的数据保存。
上面supervisor.slots.ports表示supervisor节点的槽数,就是最多能跑几个worker进程(每个sprout或bolt默认只启动一个worker,但是可以通过conf修改成多个)。
主节点(nimbus节点):
# bin/storm nimbus
# bin/storm ui
从节点(supervisor节点):
# bin/storm supervisor
查看状态:
# vi logs/nimbus.log
# vi logs/supervisor.log
# vi logs/ui.log
注意默认log4j配置文件storm.log.properties里面的logs目录不是绝对路径,而是相对于当前执行storm命令所在路径的logs/路径。
http://XXX:8080 (必须UI已经启动)
执行storm-starter例子:
下载安装Leiningen:
# wget https://raw.github.com/technomancy/leiningen/stable/bin/lein
# mv lein /bin
# chmod +x /bin/lein
# lein self_install
它会下载自己的jar文件到该位置:
~/.lein/self-installs/leiningen-1.6.2-standalone.jar
下载storm-starter:
# tar -zxvf nathanmarz-storm-starter-3b815c3.tar.gz
# cd nathanmarz-storm-starter-3b815c3
# LEIN_ROOT=root lein deps
# LEIN_ROOT=root lein compile
# LEIN_ROOT=root lein uberjar
# export STORM_HOME=/root/storm-0.5.4
# ln -s $STORM_HOME/conf/storm.yaml ~/.storm/storm.yaml
# $STORM_HOME/bin/storm jar storm-starter-0.0.1-SNAPSHOT-standalone.jar storm.starter.ExclamationTopology Exclamation_1
# $STORM_HOME/bin/storm jar storm-starter-0.0.1-SNAPSHOT-standalone.jar storm.starter.WordCountTopology WordCount_1
这里最后一个参数会显示在UI里面,就是topology的名字,不加的话表示本地运行(就是只有一台机器的调试模式),加的话表示分布式运行。