Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
Create a Realtime Data Stream with Apache Storm
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Apache Storm is a distributed stream processing computation framework. It integrates with various systems and libraries, including Apache Kafka, Apache Cassandra, Redis, Amazon Kinesis, Kestrel, RabbitMQ/Advanced Message Queuing Protocol (AMQP), and Java Message Service (JMS).
This guide discusses key concepts and terminology associated with Apache Storm, and includes instructions for using it to create a real-time data stream.
Apache Storm Components & Terminology
Tuples: In Storm, tuples serve as the main data structure. Tuples are named lists that can contain any type of values and are dynamically typed. They have helper methods to retrieve field values without casting. By default, Storm can serialize tuple values for primitives, strings, and byte arrays, though a custom serializer is needed for other types.
Topologies: A Storm topology is the logical framework for a real-time application. It functions similarly to a MapReduce job, but is designed to run indefinitely. Topologies are composed of spouts and bolts connected by stream groupings, as illustrated in the diagram below:
Streams: A stream is a sequence of tuples processed in parallel, capable of containing various data types. Each stream has a defined schema that specifies the fields within its tuples and can be assigned a unique ID.
Spouts: A spout acts as a source of streams in a topology. It reads tuples from an external source and emits them into the topology. Spouts are categorized as either “reliable” or “unreliable”. Reliable spouts have the capability to replay a tuple if it fails to be processed, whereas unreliable spouts do not retain the tuple after it is emitted.
Bolts: Bolts perform the processing tasks in Storm, including filtering, aggregations, joins, and interactions with databases. Bolts can transform streams, and complex transformations often involve multiple bolts working together.
Nodes: Apache Storm consists of two primary types of nodes:
Nimbus (Master Node): The central component responsible for running Storm topologies. Nimbus analyzes the topology and determines which tasks to execute.
Supervisor (Worker Node): This node manages worker processes, monitors their health, ensures they are running correctly, and restarts them if necessary. It receives heartbeats from workers, reports to Nimbus, distributes tasks, and facilitates communication between workers and Nimbus. The Supervisor acts as a bridge between Nimbus and workers, ensuring tasks are executed correctly and keeping Nimbus updated on task status.
ZooKeeper: Apache ZooKeeper acts as a centralized server that helps manage and coordinate services for distributed applications. In this guide, ZooKeeper is installed on a separate, single node, however ZooKeeper clusters can be configured for larger workloads.
Before You Begin
Using the instructions in our Creating a Compute Instance guide and specifications below, create the four necessary instances to run an Apache Storm cluster (one for ZooKeeper, one for Nimbus, and two Storm Supervisors):
Images: Use the latest Long Term Support (LTS) version of Ubuntu available for all nodes. The examples in this guide use Ubuntu 24.04 LTS.
Region: Choose the geographic region best suited for your use case. The examples in this guide use the Miami (
us-mia
) region.Linode Plan: Below are the minimum specifications recommended for each node:
- ZooKeeper Node: Linode Shared 2 GB
- Nimbus Node: Linode Shared 4 GB
- Storm Supervisor Node 1: Linode Shared 4 GB
- Storm Supervisor Node 2: Linode Shared 4 GB
Linode Label: Enter a descriptive label for each instance. The examples in this guide use the following:
- ZooKeeper Node:
storm-zoo
- Nimbus Node:
storm-nimbus
- Storm Supervisor Node 1:
storm-super-1
- Storm Supervisor Node 2:
storm-super-2
- ZooKeeper Node:
Once deployed, follow our Setting Up and Securing a Compute Instance guide to update your system. You may also wish to set the timezone, configure your hostname, create a limited user account, and harden SSH access.
sudo
. If you’re not familiar with the sudo
command, see the Users and Groups guide.Install Java On All Nodes
Both Python and Java are prerequisites for Storm and ZooKeeper. Ubuntu 24.04 LTS comes with Python version 3.12.3 installed by default, but Java must be installed manually.
On each deployed instance, follow the steps below to install Java.
Install the Java Development Kit (JDK):
storm-zoo, storm-nimbus, storm-super-1, and storm-super-2sudo apt install default-jdk
Display the installed version to verify the Java installation:
storm-zoo, storm-nimbus, storm-super-1, and storm-super-2java --version
openjdk 21.0.4 2024-07-16 OpenJDK Runtime Environment (build 21.0.4+7-Ubuntu-1ubuntu224.04) OpenJDK 64-Bit Server VM (build 21.0.4+7-Ubuntu-1ubuntu224.04, mixed mode, sharing)
Install ZooKeeper
Follow the steps in this section to install ZooKeeper on the storm-zoo
instance.
Use
wget
to download the latest stable version of ZooKeeper available on the ZooKeeper release page. The examples in this guide use ZooKeeper version 3.8.4. If necessary, adjust the commands below according to your version:storm-zoowget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz
Unpack the ZooKeeper tarball:
storm-zootar -zxvf apache-zookeeper-3.8.4-bin.tar.gz
Create a
zoo.cfg
ZooKeeper configuration file:storm-zoonano ~/apache-zookeeper-3.8.4-bin/conf/zoo.cfg
Give the file the following content, and save your changes:
- File: /opt/zookeeper/conf/zoo.cfg
1 2 3
tickTime=2000 dataDir=~/apache-zookeeper-3.8.4-bin/data clientPort=2181
Create the
~/apache-zookeeper-3.8.4-bin/data
directory for data storage:storm-zoomkdir ~/apache-zookeeper-3.8.4-bin/data
Start ZooKeeper:
storm-zoo~/apache-zookeeper-3.8.4-bin/bin/zkServer.sh start
/usr/bin/java ZooKeeper JMX enabled by default Using config: /home/USERNAME/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
The single-server ZooKeeper instance in this guide is suitable for development and testing purposes. For production, it is recommended to upgrade to a replicated ZooKeeper cluster.
To help ZooKeeper detect failures and prevent issues, it is important to implement regular maintenance and supervision on each individual node. For example, this can help avoid problems like running out of storage due to old snapshots and log files.
Set Up Storm on Nimbus and Supervisor Instances
This section provides instructions for downloading and installing Apache Storm on the storm-nimbus
, storm-super-1
, and storm-super-2
instances.
Download the latest Storm release on each specified instance. This guide uses Storm version 2.7.0. If necessary, adjust the commands for your version of Storm.
storm-nimbus, storm-super-1, and storm-super-2wget https://dlcdn.apache.org/storm/apache-storm-2.7.0/apache-storm-2.7.0.tar.gz
Once the Storm tarballs are present, unpack them:
storm-nimbus, storm-super-1, and storm-super-2tar -zxvf apache-storm-2.7.0.tar.gz
Open your
.bashrc
file:storm-nimbus, storm-super-1, and storm-super-2nano ~/.bashrc
Append the following lines the end of the file to add Storm’s
bin
directory to your PATH. Save your changes when complete:- File: ~/.bashrc
1 2
#Set PATH for Storm export PATH="$HOME/apache-storm-2.7.0/bin:$PATH"
Apply the changes to
.bashrc
:storm-nimbus, storm-super-1, and storm-super-2source ~/.bashrc
Verify the Storm installation by checking the version:
storm-nimbus, storm-super-1, and storm-super-2storm version
Running: java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/home/USERNAME/apache-storm-2.7.0 -Dstorm.log.dir=/home/USERNAME/apache-storm-2.7.0/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib:/usr/lib64 -Dstorm.conf.file= -cp /home/USERNAME/apache-storm-2.7.0/*:/home/USERNAME/apache-storm-2.7.0/lib/*:/home/USERNAME/apache-storm-2.7.0/extlib/*:/home/USERNAME/apache-storm-2.7.0/extlib-daemon/*:/home/USERNAME/apache-storm-2.7.0/conf org.apache.storm.utils.VersionInfo Storm 2.7.0 URL https://TOKEN@github.com/apache/storm.git -r b95a7f25a114ae7fb9c23cbc2979d3cfff09fa73 Branch v2.7.0 Compiled by rui on 2024-10-11T17:28Z From source with checksum dcefb62616ea3f989d583d962257084
Edit the Storm Configuration on Nimbus and Supervisor Instances
The storm.yaml
configuration file specifies the local directory for Storm’s operation and defines the connection settings for ZooKeeper and Nimbus.
Open the
storm.yaml
file on thestorm-nimbus
,storm-super-1
, andstorm-super-2
instances:storm-nimbus, storm-super-1, and storm-super-2nano ~/apache-storm-2.7.0/conf/storm.yaml
Add the following lines to the end of the file. Replace storm-zoo_IP_ADDRESS with the IP address for your
storm-zoo
instance and storm-nimbus_IP_ADDRESS with the IP address for yourstorm-nimbus
instance.- File: conf/storm.yaml
1 2 3 4
storm.zookeeper.servers: - "storm-zoo_IP_ADDRESS" nimbus.seeds: ["storm-nimbus_IP_ADDRESS"] storm.local.dir: "~/apache-data"
This defines the IP addresses of the ZooKeeper and Nimbus instances and sets the
/var/storm
directory for Storm’s state and temporary files. Refer to the Storm Setup Guide for more details.When done, save your changes.
On your
storm-zoo
instance, create the~/storm-data
directory for Storm’s application data:storm-zoomkdir ~/storm-data
Start Storm
On the
storm-super-1
andstorm-super-2
instances, execute the following command to run Storm as a Supervisor daemon:storm-super-1 & storm-super-2storm supervisor &
On the
storm-nimbus
instance, execute the following commands to run Storm as a nimbus daemon and run the Storm UI web server:storm-nimbusstorm nimbus & storm ui &
Open a web browser on your local machine and navigate to port
8080
of thestorm-nimbus
instance’s public IP address:Local machinehttp://storm-nimbus_IP_ADDRESS:8080
The web site at that address shows the status of the cluster:
Create the Message Stream
The site above shows no topologies, and therefore has no message streams. The storm-starter
sample, located in the apache-storm-2.7.0/examples/
directory, can solve this. It contains a variety of Storm topologies, including one titled WordCount
that is used as an example below.
On the
storm-nimbus
instance, usewget
to download the latest version of Apache Maven. This guide uses Maven version 3.9.9.storm-nimbuswget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
Unpack the downloaded archive file:
storm-nimbustar xzvf apache-maven-3.9.9-bin.tar.gz
Open your
.bashrc
file:storm-nimbusnano ~/.bashrc
Add Maven’s
bin
directory to your PATH, and save your changes:- File: ~/.bashrc
1 2
#Set PATH for Maven export PATH="$HOME/apache-maven-3.9.9/bin:$PATH"
Apply the changes to
.bashrc
:storm-nimbussource ~/.bashrc
Verify the Maven installation by checking the version:
storm-nimbusmvn -v
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /home/USERNAME/apache-maven-3.9.9 Java version: 21.0.4, vendor: Ubuntu, runtime: /usr/lib/jvm/java-21-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.8.0-47-generic", arch: "amd64", family: "unix"
Issue the following commands to change into the
~/apache-storm-2.7.0/examples/storm-starter
directory and build a Storm “uber JAR”:storm-nimbuscd ~/apache-storm-2.7.0/examples/storm-starter mvn package
After a few minutes, you should see a success message towards the bottom of the output:
... [INFO] BUILD SUCCESS ...
The JAR file you built is located at
~/apache-storm-2.7.0/examples/storm-starter/target/storm-starter-2.7.0.jar
.
Submit the Example Topology
The storm jar
command allows you to choose a topology from the “uber JAR” and submit that to your cluster.
On the
storm-nimbus
instance, use the following command to submit theWordCount
topology:storm-nimbusstorm jar ~/apache-storm-2.7.0/examples/storm-starter/target/storm-starter-2.7.0.jar org.apache.storm.starter.WordCountTopology WordCount
On your local machine, return to your web browser and refresh the page located at port
8080
of thestorm-nimbus
instance:Local machinehttp://storm-nimbus_IP_ADDRESS:8080
The Storm UI page should now show WordCount under the Topology Summary section:
This page was originally published on