[Reprint] Storm Storm basic principles of the concept of the basic principles and fundamental concepts and basic use of use

Storm basic principles and basic concepts of use

 
https://www.cnblogs.com/swordfall/p/8821453.html

 

1. Background

1.1 What is off-line calculation

Off-line calculation: data acquiring bulk, bulk transfer of data is periodically calculated bulk data, display data;

Representative techniques: Sqoop bulk import data, HDFS bulk storage of data, MapReduce batch calculation data, Hive bulk data calculated

What is calculated flow 1.2

Flow calculated: generating real data, real-time data transmission, data is calculated in real time, real-time display

On behalf of technology: Flume real-time data acquisition, Kafka / metaq real-time data storage, Storm / JStorm real-time data calculation, Redis real-time results caching, persistent storage (mysql)

Sentence summary: Real-time data will be collected and generated a steady stream of real-time calculation, as fast as possible to get results

What is 1.3 Storm

Storm used for real-time processing data, features: low-latency, high-availability, distributed, scalable, data is not lost. It provides a simple interface to be readily understood, easy to develop.

Hadoop 1.4 and the difference between the Storm

1. Storm for real-time calculation, Hadoop for off-line calculation;

2. Storm processed data stored in memory, a steady stream; processing the data stored in Hadoop file system, batch to batch;

3. Storm incoming data transmission through the network; the Hadoop data stored in the disk;

4. Storm and Hadoop programming model similar;

2. Storm core components

Component Description Added:

Nimbus: responsible for resource allocation and task scheduling.

Supervisor: The mandate to accept nimbus assigned to start and stop the process of their own part of worker management. How many worker started by the supervisor current profile settings.

Worker: Run specific process logic processing components (in fact, a JVM). Task type Worker to run only two, one is Spout task, one is Bolt task.

Task: worker in each spout / bolt threads is called a task. After storm0.8, task no longer corresponds to the physical thread, different spout / bolt may share a task of physical thread that called the executor.

Zookeeper: save the task assignment information, heart rate information, metadata information.

Concurrency: a user-specified tasks that can be executed by multiple threads, the number equal to the number of concurrent threads. Multiple threads a task will be run on multiple Worker (JVM), there is a load balancing algorithm similar to the average policy. Minimize network IO, and truth in the local Hadoop MapReduce computation of the same.

3. Storm programming model

 

Component Description supplement :

DataSource: external data source.

Spout: receiving component external data source, the external data source is converted into internal data Storm, issued to Bolt Tuple of the basic transmission unit.

Bolt: Spout receiving data transmitted, or upstream data transmission Bolt. The service logic processing. Bolt sent to the next, or stored on some media. Media can Redis, can be Mysql, or else.

Tuple: Storm basic unit of data transmission in the interior, which encapsulates a List object, to store data.

StreamGrouping: data grouping strategy. Seven kinds, shuffleGrouping (Random Function), Non Grouping (Random Function), FieldGrouping (Hash modulo), Local or ShuffleGrouping, local or random, local priority.

Worker与Topology

一个worker只属于一个topology,每个worker中运行的task只能属于这个topology。反之,一个topology包含多个worker,其实就是这个topology运行在多个worker上。一个topology要求的worker数量如果不被满足,集群在任务分配时,根据现有的worker先运行topology。如果当前集群中worker数量为0,那么最新提交的topology将只会被标识active,不会运行。只有当集群有了空闲资源之后,才会被运行。

4. Storm常用操作命令

storm有许多简单且有用的命令可以用来管理拓扑,它们可以提交、杀死、禁用、再平衡拓扑。

4.1 提交任务命令

storm jar 【jar路径】【拓扑包名.拓扑类名】【拓扑名称】

storm  jar  examples/storm-starter/storm-starter-topologies-0.9.6.jar  storm.starter.WordCountTopology  wordcount

4.2 杀死任务命令

storm kill 【拓扑名称】 -w  10 (执行kill命令时可以通过-w [等待秒数] 指定拓扑停用以后的等待时间)

storm  kill  topology-name  -w  10

4.3 停用任务命令

storm  deactivte  【拓扑名称】

storm  deactivte  topology-name

我们能够挂起或停用运行中的拓扑。当停用拓扑时,所有已分发的元组都会得到处理,但是spouts的nextTuple方法不会被调用。销毁一个拓扑,可以使用kill命令。它会以一种安全的方式销毁一个拓扑,首先停用拓扑,在等待拓扑消息的时间段内允许拓扑完成当前的数据流。

4.4 启用任务命令

storm  activate  【拓扑名称】

storm  activate  topology-name

4.5 重新部署任务命令

storm  rebalance  【拓扑名称】

storm  rebalance  topology-name

再平衡使你重新分配集群任务。这是个很强大的命令。比如,你向一个运行中的集群增加了节点。再平衡命令将会停用拓扑,然后在相应超时时间之后重新分配工人,并重启拓扑。

1. 背景介绍

1.1 离线计算是什么

离线计算:批量获取数据、批量传输数据、周期性批量计算数据、数据展示;

代表技术:Sqoop批量导入数据、HDFS批量存储数据、MapReduce批量计算数据、Hive批量计算数据

1.2 流式计算是什么

流式计算:数据实时产生、数据实时传输、数据实时计算、实时展示

代表技术:Flume实时获取数据、Kafka/metaq实时数据存储、Storm/JStorm实时数据计算、Redis实时结果缓存、持久化存储(mysql)

一句话总结:将源源不断产生的数据实时收集并实时计算,尽可能快的得到计算结果

1.3 Storm是什么

Storm用来实时处理数据,特点:低延迟、高可用、分布式、可扩展、数据不丢失。提供简单容易理解的接口,便于开发。

1.4 Storm与Hadoop的区别

1. Storm用于实时计算,Hadoop用于离线计算;

2. Storm处理的数据保存在内存中,源源不断;Hadoop处理的数据保存在文件系统中,一批一批;

3. Storm的数据通过网络传输进来;Hadoop的数据保存在磁盘中;

4. Storm与Hadoop的编程模型相似;

2. Storm核心组件

组件说明补充:

Nimbus:负责资源分配和任务调度。

Supervisor:负责接受nimbus分配的任务,启动和停止属于自己管理的worker进程。通过配置文件设置当前supervisor上启动多少个worker。

Worker:运行具体处理组件逻辑的进程(其实就是一个JVM)。Worker运行的任务类型只用两种,一种是Spout任务,一种是Bolt任务。

Task:worker中每一个spout/bolt的线程称为一个task。在storm0.8之后,task不再与物理线程对应,不同spout/bolt的task可能会共享一个物理线程,该线程称为executor。

Zookeeper:保存任务分配信息、心跳信息、元数据信息。

并发度:用户指定的一个任务,可以被多个线程执行,并发度的数量等于线程的数量。一个任务的多个线程,会被运行在多个Worker(JVM)上,有一种类似于平均算法的负载均衡策略。尽可能减少网络IO,和Hadoop中的MapReduce中的本地计算的道理一样。

3. Storm编程模型

 

组件说明补充

DataSource:外部数据源。

Spout:接收外部数据源的组件,将外部数据源转化成Storm内部的数据,以Tuple为基本的传输单元下发给Bolt。

Bolt:接收Spout发送的数据,或上游的Bolt发送的数据。根据业务逻辑进行处理。发送给下一个Bolt或者是存储到某种介质上。介质可以是Redis,可以是Mysql,或者其他。

Tuple:Storm内部中数据传输的基本单元,里面封装了一个List对象,用来保存数据。

StreamGrouping:数据分组策略。7种,shuffleGrouping(Random函数)、Non Grouping(Random函数)、FieldGrouping(Hash取模)、Local or ShuffleGrouping、本地或随机、优先本地。

Worker与Topology

一个worker只属于一个topology,每个worker中运行的task只能属于这个topology。反之,一个topology包含多个worker,其实就是这个topology运行在多个worker上。一个topology要求的worker数量如果不被满足,集群在任务分配时,根据现有的worker先运行topology。如果当前集群中worker数量为0,那么最新提交的topology将只会被标识active,不会运行。只有当集群有了空闲资源之后,才会被运行。

4. Storm常用操作命令

storm有许多简单且有用的命令可以用来管理拓扑,它们可以提交、杀死、禁用、再平衡拓扑。

4.1 提交任务命令

storm jar 【jar路径】【拓扑包名.拓扑类名】【拓扑名称】

storm  jar  examples/storm-starter/storm-starter-topologies-0.9.6.jar  storm.starter.WordCountTopology  wordcount

4.2 杀死任务命令

storm kill 【拓扑名称】 -w  10 (执行kill命令时可以通过-w [等待秒数] 指定拓扑停用以后的等待时间)

storm  kill  topology-name  -w  10

4.3 停用任务命令

storm  deactivte  【拓扑名称】

storm  deactivte  topology-name

我们能够挂起或停用运行中的拓扑。当停用拓扑时,所有已分发的元组都会得到处理,但是spouts的nextTuple方法不会被调用。销毁一个拓扑,可以使用kill命令。它会以一种安全的方式销毁一个拓扑,首先停用拓扑,在等待拓扑消息的时间段内允许拓扑完成当前的数据流。

4.4 启用任务命令

storm  activate  【拓扑名称】

storm  activate  topology-name

4.5 重新部署任务命令

storm  rebalance  【拓扑名称】

storm  rebalance  topology-name

再平衡使你重新分配集群任务。这是个很强大的命令。比如,你向一个运行中的集群增加了节点。再平衡命令将会停用拓扑,然后在相应超时时间之后重新分配工人,并重启拓扑。

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11923878.html