下面是自己安装和测试storm的一些笔记,比较乱,后续有时间在整理一篇。
storm jar all-my-code.jar com.storm.MyTopology arg1 arg2
这个命令会运行主类: com.strom.MyTopology, 参数是arg1, arg2。这个类的main函数定义这个topology并且把它提交给Nimbus。storm jar负责连接到Nimbus并且上传jar包。
activate和deactivate是在spout被activate或deactivate时被调用,这两个动作是由用户从外部触发的,Strom的命令行提供两个命令activate和deactivate,允许用户activate和deactivate一个Topology,当用户执行deactivate时,对应Topology的spout会被deactivate,产生影响就是spout的nextTuple此后将不会被调用,直到用户再调用activate。
Spout使用的collector是SpoutOutputCollector,Bolt使用的collector
Spout:拿数据,nextTuple()
Bolt:处理数据,execute()
本地安装Sorm:
查找ifconfig命令在哪个目录:whereis ifconfig
把ifconfig命令目录增加到环境变量:export PATH=$PATH:/sbin
ifconfig
切换root权限:su
chown -R admin tools
chmod -R 775 tools
vi /etc/yum.conf,增加代理:proxy=http://172.17.18.80:8080/
yum install unzip
su admin
tar -zxvf zookeeper-3.3.6.tar.gz
复制conf文件夹下的zoo_sample.cfg为zoo.cfg
tickTime=2000
dataDir=/home/admin/liusen/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=localstorm:2888:3888
vi /etc/sysconfig/network
HOSTNAME=localstorm
vi /etc/hosts
127.0.0.1 localhost.localdomain localhost ->127.0.0.1 localstorm localhost
hostname localstorm
cd到zookeeper的bin目录:./zkServer.sh start
查看Zookeeper状态:./zkServer.sh status
关闭Zookeeper:./zkServer.sh stop
查看哪个结点被选作leader或者followe:echo stat|nc 127.0.0.1 2181
测试是否启动了该Server,若回复imok表示已经启动:echo ruok|nc 127.0.0.1 2181
客户端连接:./zkCli.sh –server 127.0.0.1:2181
查看Zookeeper配置:echo conf |nc 127.0.0.1 2181
tar -xzf zeromq-2.1.7.tar.gz
cd zeromq-2.1.7
./configure
缺少包uuid-dev:sudo yum install e2fsprogs-devel
重新编译到制定位置:./configure --prefix=/home/admin/liusen/zeromq
make
make install
tar –jxvf Python-2.6.6.tar.bz2
./configure --prefix=/home/admin/liusen/python
make
make install
#cd /usr/bin
#ll |grep python //查看该目录下python
#rm -rf python
#ln -s /home/admin/liusen/python/bin/python ./python //建立对应的软链接
#python -V
unzip jzmq-master.zip
cd jzmq-master
./autogen.sh
./configure --prefix=/home/admin/liusen/jzmq
报错:configure: error: cannot find zmq.h
export CPPFLAGS=-I/home/admin/liusen/zeromq/include/
export LDFLAGS=-L/home/admin/liusen/zeromq/lib/
./configure --prefix=/home/admin/liusen/jzmq --with-pgm
make
make install
unzip storm-0.8.1.zip
conf/storm.yaml
storm.zookeeper.servers:
- "localstorm"
storm.local.dir: "/home/admin/liusen/storm/workdir"
java.library.path:”/usr/local/lib:/opt/local/lib:/usr/lib:/home/admin/liusen/zeromq:/home/admin/liusen/jzmq”
nimbus.host: "localstorm"
supervisor.slots.ports:
- 6700
- 6701
- 6702
- 6703
chown -R admin liusen
chmod -R 775 liusen
./storm nimbus >/dev/null 2>&1 &
./storm supervisor >/dev/null 2>&1 &
./storm ui >/dev/null 2>&1 &
(解析:dev启动一个记录日子文件,名为null, 2是标准输出,&1是错误输出, &结束)
vi /usr/bin/yum
修改头#!/usr/bin/python => #!/usr/bin/python2.4
yum remove system-config-network system-config-network-tui
yum install system-config-network system-config-network-tui
rpm -ivh system-config-network-tui-1.3.99.21-1.el5.noarch.rpm
rpm -ivh system-config-network-1.3.99.21-1.el5.noarch.rpm
yum search vim搜索vim
yum -y install vim* 安装vim等
find / -name rhpl.translate
ls -l 查看包括软链接地址
#rm -rf python
##ln -s /home/admin/liusen/python/bin/python ./python
#ln -s python2.4 ./python
neat 查看网络设置界面
/etc/init.d/network restart 重启网络配置
chkconfig iptables off
service iptables stop
vim /etc/sysconfig/iptables
/etc/init.d/iptables status
1.windows xp的字体一般存放在c:\windows\fonts目录下,copy你要的字体到linux下,也可以直接下载,不过看着乱码。。
2.把字体copy到/usr/share/fonts 目录下,然后执行以下命令:
mkfontscale
mkfontdir //这两条命令是生成字体的索引信息
fc-cache //更新字体缓存
cp /home/admin/liusen/tools/MSYHBD.TTF /usr/share/fonts
cp /home/admin/liusen/tools/MSYH.TTF /usr/share/fonts
关机:poweroff
shutdown –h now
storm jar /home/admin/liusen/tools/stormtest.jar com.DemoTopologyLocal
./storm jar /home/admin/liusen/tools/stormtest.jar com.DemoTopologyLocal
./storm jar /home/admin/liusen/testjar/ota-dip-et-1.0.0-SNAPSHOT.jar com.travelsky.topology.TopologyMain
storm kill storm-person
查看当前storm任务列表:storm list
jps
关闭nimbus相关进程:
kill `ps aux | egrep '(daemon\.nimbus)|(storm\.ui\.core)' | fgrep -v egrep | awk '{print $2}'`
干掉supervisor上的所有storm进程:
kill `ps aux | fgrep storm | fgrep -v 'fgrep' | awk '{print $2}'`
来自http://lawson.cnblogs.com