Chapter 2. Getting started
2.1. AMQ Streams distribution
AMQ Streams is distributed as single ZIP file. This ZIP file contains all AMQ Streams components:
- Apache Zookeeper
- Apache Kafka
- Apache Kafka Connect
- Apache Kafka Mirror Maker
2.2. Downloading an AMQ Streams Archive
An archived distribution of AMQ Streams is available for download from the Red Hat website. You can download a copy of the distribution by following the steps below.
Procedure
- Download the AMQ Streams archive from the Customer Portal.
2.3. Installing AMQ Streams
Prerequisites
- Download the installation archive.
- Review the Section 1.2, “Supported Configurations”
Procedure
Add new
kafkauser and group.sudo groupadd kafka sudo useradd -g kafka kafka sudo passwd kafka
Create directory
/opt/kafka.sudo mkdir /opt/kafka
Create a temporary directory and extract the contents of the AMQ Streams ZIP file.
mkdir /tmp/kafka unzip kafka_y.y-x.x.x.zip -d /tmp/kafka
Move the extracted contents into
/opt/kafkadirectory and delete the temporary directory.sudo mv /tmp/kafka/kafka_y.y-x.x.x/* /opt/kafka/ rm -r /tmp/kafka
Change the ownership of the
/opt/kafkadirectory to thekafkauser.sudo chown -R kafka:kafka /opt/kafka
Create directory
/var/lib/zookeeperfor storing Zookeeper data and set its ownership to thekafkauser.sudo mkdir /var/lib/zookeeper sudo chown -R kafka:kafka /var/lib/zookeeper
Create directory
/var/lib/kafkafor storing Kafka data and set its ownership to thekafkauser.sudo mkdir /var/lib/kafka sudo chown -R kafka:kafka /var/lib/kafka
2.4. Running single node AMQ Streams cluster
This procedure will show you how to run a basic AMQ Streams cluster consisting of single Zookeeper and single Apache Kafka node both running on the same host. It is using the default configuration files for both Zookeeper and Kafka.
Single node AMQ Streams cluster does not provide realibility and high availability and is suitable only for development purposes.
Prerequisites
- AMQ Streams is installed on the host
Running the cluster
Edit the Zookeeper configuration file
/opt/kafka/config/zookeeper.properties. Set thedataDiroption to/var/lib/zookeeper/.dataDir=/var/lib/zookeeper/
Start Zookeeper.
su - kafka /opt/kafka/bin/zookeeper-server-start.sh -daemon /opt/kafka/config/zookeeper.properties
Make sure that Apache Zookeeper is running.
jcmd | grep zookeeper
Edit the Kafka configuration file
/opt/kafka/config/server.properties. Set thelog.dirsoption to/var/lib/kafka/.log.dirs=/var/lib/kafka/
Start Kafka.
su - kafka /opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties
Make sure that Kafka is running.
jcmd | grep kafka
Additional resources
- For more information about installing AMQ Streams, see Section 2.3, “Installing AMQ Streams”.
- For more information about configuring AMQ Streams, see Section 2.7, “Configuring AMQ Streams”.
2.5. Using the cluster
Prerequisites
- AMQ Streams is installed on the host
- Zookeeper and Kafka are up and running
Procedure
Start the Kafka console producer.
bin/kafka-console-producer.sh --broker-list <bootstrap-address> --topic <topic-name>
For example:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my-topic
- Type your message into the console where the producer is running.
- Press Enter to send.
- Press Ctrl+C to exit the Kafka console producer.
Start the message receiver.
bin/kafka-console-consumer.sh --bootstrap-server <bootstrap-address> --topic <topic-name> --from-beginning
For example:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my-topic --from-beginning
- Confirm that you see the incoming messages in the consumer console.
- Press Crtl+C to exit the Kafka console consumer.
2.6. Stopping the AMQ Streams services
You can stop the Kafka and Zookeeper services by running a script. All connections to the Kafka and Zookeeper services will be terminated.
Prerequisites
- AMQ Streams is installed on the host
- Zookeeper and Kafka are up and running
Procedure
Stop the Kafka broker.
su - kafka /opt/kafka/bin/kafka-server-stop.sh
Confirm that the Kafka broker is stopped.
jcmd | grep kafka
Stop Zookeeper.
su - kafka /opt/kafka/bin/zookeeper-server-stop.sh
2.7. Configuring AMQ Streams
Prerequisites
- AMQ Streams is downloaded and installed on the host
Procedure
Open Zookeeper and Kafka broker configuration files in a text editor. The configuration files are located at :
- Zookeeper
-
/opt/kafka/config/zookeeper.properties - Kafka
-
/opt/kafka/config/server.properties
Edit the configuration options. The configuration files are in the Java properties format. Every configuration option should be on separate line in the following format:
<option> = <value>
Lines starting with
#or!will be treated as comments and will be ignored by AMQ Streams components.# This is a comment
Values can be split into multiple lines by using
\directly before the newline / carriage return.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \ username="bob" \ password="bobs-password";- Save the changes
- Restart the Zookeeper or Kafka broker
- Repeat this procedure on all the nodes of the cluster.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.