Install Confluent Platform using Systemd on Ubuntu and Debian¶
This topic provides instructions for installing a production-ready Confluent Platform configuration in a multi-node Ubuntu or Debian environment.
With this installation method, you connect to every node manually to run the Confluent Platform installation commands.
Looking for a fully managed cloud-native service for Apache Kafka®?
Sign up for Confluent Cloud and get started for free using the Cloud quick start.
Prerequisites¶
- You must complete these steps for each node in your cluster.
- Before installing Confluent Platform, your environment must meet the prerequisites as described in software and hardware requirements.
Get the software¶
The APT repositories provide packages for Debian-based Linux distributions such as Debian and Ubuntu. You can install
individual Confluent Platform packages or the entire platform. For a list of available packages, see the documentation
or you can search the repository (apt-cache search <package-name>
).
Tip
You can install the entire platform or the individual component packages. For a listing of packages, see Confluent Platform Packages.
Install the Confluent public key. This key is used to sign the packages in the APT repository.
wget -qO - https://packages.confluent.io/deb/7.7/archive.key | sudo apt-key add -
Add the repository to your
/etc/apt/sources.list
by running this command:Attention
After Confluent Platform 8.0, the librdkafka, Avro, and libserdes C/C++ client packages will NOT be available from the
https://packages.confluent.io/deb
location. You will need to obtain those client packages fromhttps://packages.confluent.io/clients
after the Confluent Platform 8.0 release.For the
clients
repository, you must obtain your Debian distribution’s release “Code Name”, such asbuster
,focal
, etc. You can do this by callinglsb_release -cs
. The following example makes this call with$(lsb_release -cs)
, which should work in most cases. If it does not, you must pick the closest Debian or Ubuntu code name for your Debian Linux distribution that matches the supported Debian & Ubuntu Operating Systems supported by Confluent Platform.sudo add-apt-repository "deb https://packages.confluent.io/deb/7.7 stable main" sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
Update
apt-get
and install the entire Confluent Platform platform.Confluent Platform:
sudo apt-get update && sudo apt-get install confluent-platform
Confluent Platform with RBAC:
sudo apt-get update && \ sudo apt-get install confluent-platform && \ sudo apt-get install confluent-security
Confluent Platform using only Confluent Community components:
sudo apt-get update && sudo apt-get install confluent-community-2.13
Configure Confluent Platform¶
Tip
You can store passwords and other configuration data securely by using the confluent secret commands. For more information, see Manage Secrets in Confluent Platform.
Configure Confluent Platform with the individual component properties files. By default these are located in CONFLUENT_HOME/etc/
.
You must minimally configure the following components.
ZooKeeper¶
These instructions assume you are running ZooKeeper in replicated mode. A minimum of three servers are required for replicated mode, and you must have an odd number of servers for failover. For more information, see the ZooKeeper documentation.
Important
As of Confluent Platform 7.5, ZooKeeper is deprecated for new deployments. Confluent recommends KRaft mode for new deployments. For more information, see KRaft Overview for Confluent Platform.
Navigate to the ZooKeeper properties file (
/etc/kafka/zookeeper.properties
) file and modify as shown.tickTime=2000 dataDir=/var/lib/zookeeper/ clientPort=2181 initLimit=5 syncLimit=2 server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 autopurge.snapRetainCount=3 autopurge.purgeInterval=24
This configuration is for a three node ensemble. This configuration file should be identical across all nodes in the ensemble.
tickTime
,dataDir
, andclientPort
are all set to typical single server values. TheinitLimit
andsyncLimit
govern how long following ZooKeeper servers can take to initialize with the current leader and how long they can be out of sync with the leader. In this configuration, a follower can take 10000 ms to initialize and can be out of sync for up to 4000 ms based on thetickTime
being set to 2000ms.The
server.*
properties set the ensemble membership. The format isserver.<myid>=<hostname>:<leaderport>:<electionport>
myid
is the server identification number. There are three servers that each have a differentmyid
with values1
,2
, and3
respectively. Themyid
is set by creating a file namedmyid
in thedataDir
that contains a single integer in human readable ASCII text. This value must match one of themyid
values from the configuration file. You will see an error if another ensemble member is already started with a conflictingmyid
value.leaderport
is used by followers to connect to the active leader. This port should be open between all ZooKeeper ensemble members.electionport
is used to perform leader elections between ensemble members. This port should be open between all ZooKeeper ensemble members.
The
autopurge.snapRetainCount
andautopurge.purgeInterval
have been set to purge all but three snapshots every 24 hours.Navigate to the ZooKeeper log directory (e.g.,
/var/lib/zookeeper/
) and create a file namedmyid
. Themyid
file consists of a single line that contains the machine ID in the format<machine-id>
. When the ZooKeeper server starts up, it knows which server it is by referencing themyid
file. For example, server 1 will have amyid
value of1
.
Kafka in KRaft mode¶
If you are using Kafka in KRaft mode, you must configure a node to be a broker or a controller. In addition, you must create a unique cluster ID and format the log directories with that ID.
Typically in a production environment, you should have a minimum of three brokers and three controllers.
Navigate to the Kafka properties file for KRaft (find example KRaft configuration files under
/etc/kafka/kraft/
) and customize the following:Configure the
process.roles
,node.id
andcontroller.quorum.voters
for each node.For
process.roles
, set whether the node will be abroker
or acontroller
.combined
mode, meaningprocess.roles
is set tobroker,controller
, is currently not supported for production workloads.Set a system-wide unique ID for the
node.id
for each broker/controller.controller.quorum.voters
should be a comma-separated list of controllers in the formatnodeID@hostname:port
############################# Server Basics ############################# # The role of this server. Setting this puts us in KRaft mode process.roles=broker # The node id associated with this instance's roles node.id=2 # The connect string for the controller quorum controller.quorum.voters=1@controller1:9093,3@controller3:9093,5@controller5:9093
Configure how brokers and clients communicate with the broker using
listeners
, and where controllers listen withcontroller.listener.names
.listeners
: Comma-separated list of URIs and listener names to listen on in the formatlistener_name://host_name:port
controller.listener.names
: Comma-separated list oflistener_name
entries for listeners used by the controller.
For more information, see KRaft Configuration for Confluent Platform.
Before you start Kafka, you must use the kafka-storage tool with the
random-uuid
command to generate a cluster ID for each new cluster. You only need one cluster ID, which you will use to format each node in the cluster.bin/kafka-storage random-uuid
This results in output like the following:
q1Sh-9_ISia_zwGINzRvyQ
Then use the cluster ID to format storage for each node in the cluster with the
kafka-storage
tool that is provided with Confluent Platform, and theformat
command like the following example, specifying the properties file for a controller.bin/kafka-storage format -t q1Sh-9_ISia_zwGINzRvyQ -c etc/kafka/kraft/controller.properties
Previously, Kafka would format blank storage directories automatically and generate a new cluster ID automatically. One reason for the change is that auto-formatting can sometimes obscure an error condition. This is particularly important for the metadata log maintained by the controller and broker servers. If a majority of the controllers were able to start with an empty log directory, a leader might be able to be elected with missing committed data. To configure the log directory, either set
metadata.log.dir
orlog.dirs
. For more information, see Listeners and logs.Configure security for your environment.
- For general security guidance, see Manage Security in Confluent Platform.
- For role-based access control (RBAC), see Configure Metadata Service (MDS) in Confluent Platform.
Kafka in ZooKeeper mode¶
If you are using ZooKeeper for cluster metadata management, use the following guidelines.
During startup in ZooKeeper mode, Kafka brokers register themselves in ZooKeeper to become a member of the cluster.
In a production environment, multiple brokers are required.
To configure brokers, navigate to the Apache Kafka® properties file (/etc/kafka/server.properties
) and customize the following:
Connect to the same ZooKeeper ensemble by setting the
zookeeper.connect
in all nodes to the same value. Replace all instances oflocalhost
to the hostname or FQDN (fully qualified domain name) of your node. For example, if your hostname iszookeeper
:zookeeper.connect=zookeeper:2181
Configure the broker IDs for each node in your cluster using one of these methods.
Dynamically generate the broker IDs: add
broker.id.generation.enable=true
and comment outbroker.id
. For example:############################# Server Basics ############################# # The ID of the broker. This must be set to a unique integer for each broker. #broker.id=0 broker.id.generation.enable=true
Manually set the broker IDs: set a unique value for
broker.id
on each node.
Configure how other brokers and clients communicate with the broker using
listeners
, and optionallyadvertised.listeners
.listeners
: Comma-separated list of URIs and listener names to listen on.advertised.listeners
: Comma-separated list of URIs and listener names for other brokers and clients to use. Theadvertised.listeners
parameter ensures that the broker advertises an address that is accessible from both local and external hosts.
For more information, see Production Configuration Options.
Configure security for your environment.
- For general security guidance, see Manage Security in Confluent Platform.
- For role-based access control (RBAC), see Configure Metadata Service (MDS) in Confluent Platform.
- For TLS encryption, SASL authentication, and authorization, see Enable Security for a ZooKeeper-Based Cluster in Confluent Platform.
Control Center¶
Navigate to the Control Center properties file (
/etc/confluent-control-center/control-center-production.properties
) and customize the following:# host/port pairs to use for establishing the initial connection to the Kafka cluster bootstrap.servers=<hostname1:port1,hostname2:port2,hostname3:port3,...> # location for Control Center data confluent.controlcenter.data.dir=/var/lib/confluent/control-center # the Confluent license confluent.license=<your-confluent-license>
If running any clusters in ZooKeeper mode, configure ZooKeeper.
# ZooKeeper connection string with host and port of a ZooKeeper servers zookeeper.connect=<hostname1:port1,hostname2:port2,hostname3:port3,...>
This configuration is for a three node multi-node cluster. For more information, see Control Center configuration details. For information about Confluent Platform licenses, see Manage Confluent Platform Licenses Using Control Center.
Navigate to the Kafka server configuration file and enable Confluent Metrics Reporter.
##################### Confluent Metrics Reporter ####################### # Confluent Control Center and Confluent Auto Data Balancer integration # # Uncomment the following lines to publish monitoring data for # Confluent Control Center and Confluent Auto Data Balancer # If you are using a dedicated metrics cluster, also adjust the settings # to point to your metrics Kafka cluster. metric.reporters=io.confluent.metrics.reporter.ConfluentMetricsReporter confluent.metrics.reporter.bootstrap.servers=localhost:9092 # # Uncomment the following line if the metrics cluster has a single broker confluent.metrics.reporter.topic.replicas=1
Add these lines to the Kafka Connect properties file (
/etc/kafka/connect-distributed.properties
) to add support for the interceptors.# Interceptor setup consumer.interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor producer.interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor
Schema Registry¶
Navigate to the Schema Registry properties file (/etc/schema-registry/schema-registry.properties
)
and specify the following properties:
# Specify the address the socket server listens on, e.g. listeners = PLAINTEXT://your.host.name:9092
listeners=http://0.0.0.0:8081
# The host name advertised in ZooKeeper. This must be specified if your running Schema Registry
# with multiple nodes.
host.name=192.168.50.1
# List of Kafka brokers to connect to, e.g. PLAINTEXT://hostname:9092,SSL://hostname2:9092
kafkastore.bootstrap.servers=PLAINTEXT://hostname:9092,SSL://hostname2:9092
This configuration is for a three node multi-node cluster. For more information, see Deploy Schema Registry in Production on Confluent Platform.
Start Confluent Platform¶
Start Confluent Platform and its components using systemd service unit files. You can start immediately by using the
systemctl start
command or enable for automatic startup by using the systemctl enable
command. These instructions
use the syntax for immediate startup.
Tip
In ZooKeeper mode, ZooKeeper must be started first. Kafka, and Schema Registry must be started in this order, and must be started after ZooKeeper, if you are using it, and before any other components.
For ZooKeeper mode, start ZooKeeper. For KRaft mode, skip to step 2. .. include:: ../../includes/zk-deprecation.rst
sudo systemctl start confluent-zookeeper
Start Kafka.
Confluent Platform:
sudo systemctl start confluent-server
Confluent Platform using only Confluent Community components:
sudo systemctl start confluent-kafka
Start Schema Registry.
sudo systemctl start confluent-schema-registry
Start other Confluent Platform components as desired.
Control Center
sudo systemctl start confluent-control-center
Kafka Connect
sudo systemctl start confluent-kafka-connect
Confluent REST Proxy
sudo systemctl start confluent-kafka-rest
ksqlDB
sudo systemctl start confluent-ksqldb
Tip
You can check service status with this command: systemctl status confluent*
. For more information
about the systemd service unit files, see Use Confluent Platform systemd Service Unit Files.
Uninstall¶
Run this command to remove Confluent Platform, where <component-name>
is either confluent-platform
(Confluent Platform) or confluent-community-2.13
(Confluent Platform using only Confluent Community components).
sudo apt-get remove <component-name>
For example, run this command to remove Confluent Platform:
sudo apt-get remove confluent-platform