Storm 概念
- 什么是Spout:从外部数据数据源获取数据,可以是文件、MQ、数据库等等
- 什么是Bolt:Spout将tuple发送到Bolt,Bolt负责处理具体的业务逻辑,Bolt处理完数据后,可以继续将tuple发送个其他Bolt
- 什么是Topology:有若干个Spout和Bolt组成
- 什么的Tuple:Spout与Bolt发送数据的最小单位为为Tuple
- 什么是Stream:Spoout
Storm集群搭建
准备工作
-
服务器三台
- ip修改为静态:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
- 关闭防火墙:
systemctl stop firewalld
(关闭)systemctl disable firewalld
(设置为开机不可见)systemctl status firewalld
(查看防火墙状态)
- 修改主机名:
vim /etc/hostname
(保证三台服务器主机名不一致即可)hostname
(查看主机名)
- 配置hosts:
- ip修改为静态:
-
zookeeper集群搭建:
-
mkdir /opt/soft
(创建安装目录) -
tar -zxvf apache-zookeeper-3.6.1.tar.gz -C /opt/soft
(解压) -
cd /opt/soft/apache-zookeeper-3.6.1/conf
-
mkdir /opt/soft/apache-zookeeper-3.6.1/zkData
-
mv zoo_sample.cfg zoo.cfg
(给配置文件重命名,此步骤务必执行,否则有可能导致错误) -
touch /opt/soft/apache-zookeeper-3.6.1/zkData/myId
(存储zk在集群中的节点编号) -
vim myid
-
vim zoo.cfg
(修改配置)dataDir=/opt/soft/apache-zookeeper-3.6.1/zkData` server.1=stormNode1:2888:3888 server.2=stormNode2:2888:3888 server.3=stormNode3:2888:3888
-
scp /opt/soft/apache-zookeeper-3.6.1 root@192.168.187.12:/opt/sotf
-
scp /opt/soft/apache-zookeeper-3.6.1 root@192.168.187.13:/opt/sotf
-
storm集群搭建:
-
tar -zxvf apache-storm-2.2.0.tar.gz -C /opt/soft
-
cd /opt/soft
-
mv apache-storm-2.2.0 storm
-
cd storm
-
mkdir data
-
vim /opt/soft/storm/conf/storm.yaml
storm.zookeeper.servers: - "stormNode1" - "stormNode2" - "stormNode3" storm.zookeeper.port: 12181 ui.port: 17010 nimbus.host: "stormNode1" storm.local.dir: "/opt/sotf/storm/data" supervisor.slots.ports: - 6700 - 6701 - 6702 - 6703 - 6704 - 6705
-
vim /etc/profile
#STORM_HOME export STORM_HOME=/opt/soft/storm export PATH=$PATH:$STORM_HOME/bin
-
source /etc/profile
-
scp /opt/soft/storm root@192.168.187.12:/opt/sotf
-
scp /opt/soft/storm root@192.168.187.12:/opt/sotf
-
jdk安装
启动zk&&storm集群启动
- zookeeper集群启动
bin/zkServer.sh start
(三台机器都要执行此命令)bin/zkServer.sh status
(查看zookeeper状态)
- storm集群启动
bin/storm nimbus &
(启动nimbus三台机器都要执行此命令)bin/storm supervisor &
(启动supervisor三台机器都要执行此命令)bin/storm ui
(启动storm UI—Strom nimbus节点启动即可)
Storm 实战
Topology 提交到Storm集群(在Nimbus节点操作即可)
storm jar storm jar storm-1.0-SNAPSHOT.jar org.eden.pv.PVMain PVTopology
(启动Topology)storm kill PVTopology
(杀死Topology)storm deactivate WebTopology
(禁用Topology)storm activate WebTopology
(激活Topology)