Use Confluent Platform systemd Service Unit Files

You can use Confluent Platform systemd service unit files to configure automatic startup and monitoring of services during system boot. These files provide a standardized method for starting Confluent Platform server components in the correct order on startup.

The systemd service unit files support staging and production deployments on Linux-based systems.

Components managed by systemd unit files

The RPM and Debian packages include systemd service unit files for these Confluent Platform components:

  • Apache Kafka® (kafka)

  • Kafka Connect (kafka-connect)

  • Confluent REST Proxy (kafka-rest)

  • ksqlDB (ksql)

  • Schema Registry (schema-registry)

Each component runs under its own user and a common confluent group set up during package installation. This configuration ensures proper security separation between components that are running on the same system. Usernames use the cp- prefix followed by the component name. For example, cp-kafka and cp-schema-registry.

For components with persistent storage, such as Kafka, the default component configuration file points to component-specific data directories /var/lib/<component>. For example, Kafka points to /var/lib/kafka.

Manage Confluent Platform services with systemd

Enable automatic startup during boot

To enable a Confluent Platform component to start automatically on boot but not immediately, run the following command. Component services are not enabled for automatic startup at install time, so you must enable each one explicitly.

sudo systemctl enable confluent-<component>

For example, you can enable the Confluent REST Proxy with the command:

sudo systemctl enable confluent-kafka-rest

Start service immediately

To start the service now, run the following command:

sudo systemctl start confluent-<component>

This command returns immediately, although the service has not yet started. The systemd daemon starts the service in the background.

Check service status

To check the status of a service, run the following command:

systemctl status confluent-<component>

Look for the Active: line, which should say active.

Stop a service

To stop a service, run the following command:

sudo systemctl stop confluent-<component>

Disable a service

To disable a service and prevent automatic startup on boot, run the following command:

sudo systemctl disable confluent-<component>

Logging

Each Confluent Platform component has its own log directory under /var/log/confluent/. For example, Schema Registry logs are located in /var/log/confluent/schema-registry.

The standard output of services is written to the log journal of a service. You can read the log journal with this command:

sudo journalctl -u confluent-<component>

To update the log4j file used for a component, set the <component>_LOG4J_OPTS environment variable.

To update the logging directory path used by the default log4j files, update the LOG_DIR environment variable.

For example, to change the log file directory for Schema Registry, use one of the following commands, then restart Schema Registry:

export Environment="LOG_DIR=/new/path/to/log/confluent/schema-registry"
export Environment="SCHEMA_REGISTRY_LOG4J_OPTS=-Dconfluent.schemaregistry.log.dir=/new/path/to/log/confluent/schema-registry"

Follow the log

To follow the log in real time, run the following command:

sudo journalctl -f -u confluent-<component>

Modify systemd configuration

Modify service unit configuration settings

To change a systemd service unit setting, add an override line with the new value. Do not edit existing lines, because that prevents clean upgrades to the base service unit files.

The systemd component configuration settings are minimal and only control how the component is started, run, and stopped. The component configuration is managed through its existing /etc/<component>/<component>.properties configuration file, for example /etc/kafka/broker.properties for a Kafka broker.

Modify the systemd component configuration

To modify the configuration settings for a service using the systemd builtin configuration editor, follow these steps:

  1. View the current systemd component configuration:

    systemctl cat confluent-<component>
    
  2. Run the edit command:

    sudo systemctl edit confluent-<component>
    
  3. Optional: Inspect the result.

    systemctl cat confluent-<component>
    
  4. Reload systemd configuration and restart the component.

    sudo systemctl reload
    sudo systemctl restart confluent-<component>
    

To reconfigure the Confluent Platform component, refer to the component documentation and its configuration file. The configuration files are located in <path-to-confluent>/etc/<component>/<component>.properties. After reconfiguring the component, restart it with the following command to have the changes take effect:

sudo systemctl restart confluent-<component>