LoginSignup
4
6

More than 5 years have passed since last update.

Apache Storm に関するメモ (概念編+α)

Last updated at Posted at 2017-02-25

公式ページ

公式ページによるとApache Stormは'distributed realtime computation system',分散リアルタイム計算システム。記事の執筆時点(2017年2月)でv1.0.3が最新バージョン。以下,基本的に公式ページの内容に沿って書いていく。

Rationale

MapReduceやHadoopなどの違いはリアルタイム処理が可能なこと。(以前はバッチ処理のみ)
特徴は次の通り。

  • 幅広いユースケース
  • スケーラブル。スケールさせるためにはマシンを増やすだけ。
  • データロスがない。
  • 堅牢性
  • Fault-tolerant (耐障害性)
  • Programming language agnostic (プログラム言語非依存)

コンセプト

  1. トポロジー
  2. ストリーム
  3. スパウト (spout)
  4. ボルト (bolt)
  5. ストリームグループ
  6. 信頼性 (Reliability)
  7. タスク
  8. ワーカー (Workers)

トポロジー

トポロジーはスパウトとボルトのつながりのこと。

topology.png

ストリーム

Streams are defined with a schema that names the fields in the stream's tuples. 
デフォルトで次の型がある。

integers, longs, shorts, bytes, strings, doubles, floats, booleans, and byte arrays.

スパウト

スパウトはトポロジーにおいてストリームの源。(Spoutは水などの噴出しのこと)
スパウトには reliable か unreliableがある. reliable spoutは処理に失敗したら再送機能がある。 whereas an unreliable spout forgets about the tuple as soon as it is emitted.

storm-flow.png

ボルト

すべての計算はボルトの中で行われる
例えば,filtering, functions, aggregations, joins, talking to databases,

複雑なトポロジーではボルトは複数段になってもかまわない。
ボルトは複数のストリームに出力してもかまわない。declareStream method を使って複数のストリームを定義することができる。

ストリームグループ

ストリームグループはストリームがタスクの間でどのように分割されるのか?を定義する)

topology-tasks.png

8種類のストリームグループが存在する。
1. Shuffle grouping : タプルがランダムにタスクに分配される。
2. Fields grouping
3. Partial Key grouping
4. All grouping : ストリームがすべてのタスクに複製される。注意して使うこと。
5. Global grouping
6. None grouping : 現時点ではShuffle groupingと同じ。
7. Direct grouping
8. Local or shuffle grouping

信頼性

Storm guarantees that every spout tuple will be fully processed by the topology. (すべてのスパウトはトポロジーにより完全に処理される)
Every topology has a "message timeout" associated with it. If Storm fails to detect that a spout tuple has been completed within that timeout, then it fails the tuple and replays it later.(すべてのトポロジーはタイムアウト時間がある。Stormがタイムアウトを検出すると,後に再送する)

タスク

Each spout or bolt executes as many tasks across the cluster.

ワーカー

Each worker process is a physical JVM and executes a subset of all the tasks for the topology.

API

REST API

http://<ui-host>:<ui-port>/api/v1/...

Trident

Trident is a high-level abstraction for doing realtime computing on top of Storm.
Storm のコントローラー?ラッパーみたいなもの?Javaプログラム。

セットアップ

  1. Set up a Zookeeper cluster
  2. Install dependencies on Nimbus and worker machines
  3. Download and extract a Storm release to Nimbus and worker machines
  4. Fill in mandatory configurations into storm.yaml
  5. Launch daemons under supervision using "storm" script and a supervisor of your choice

ZooKeeper

StormではZooKeeperはクラスタの調整のみに使用される。メッセージ処理には利用されない。

Nimbusとworkerマシンの前提をインストール

Java7 and Python 2.6.6
(これ以外のバージョンでは動くかもしれないし,動かないかもしれない。。。)

Stormのダウンロード・解凍

ここからダウンロード
https://github.com/apache/storm/releases

storm.yamlファイルの編集

設定ファイルはconf/storm.yaml
設定項目は,
1 storm.zookeeper.servers (zookeeperサーバーのIP),storm.zookeeper.port(同じくポート番号)

conf/storm.yaml
storm.zookeeper.servers:
  - "111.222.333.444"
  - "555.666.777.888"

2 storm.local.dir (デーモンが使う場所)

conf/storm.yaml
storm.local.dir: "/mnt/storm"

3 nimbus.seeds : The worker nodes need to know which machines are the candidate of master in order to download topology jars and confs.

conf/storm.yaml
nimbus.seeds: ["111.222.333.44"]

4 supervisor.slots.ports (workerが使うポート)

conf/storm.yaml
supervisor.slots.ports:
    - 6700
    - 6701
    - 6702
    - 6703

起動

最後のステップはデーモンの起動。Stormは状態を持たないので,いつでも安全に停止できる。
デーモンの起動方法

  1. Nimbus : "bin/storm nimbus" under supervision on the master machine.
  2. Supervisor : "bin/storm supervisor" under supervision on each worker machine
  3. UI : "bin/storm ui" under supervision. http://{ui host}:8080.

storm-cluster.png

次読むもの

Tutorial

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6