Search code examples
ubuntuapache-kafkasystemdsystemctl

How to run multiple ExecStart in kafka.service for Multiple brokers in Kafka?


I want to run multiple ExecStart in one service.

I configure like this,

[Unit]
Description=Apache Kafka Server
Documentation=http://kafka.apache.org/documentation.html
Requires=zookeeper.service

[Service]
Type=oneshot
Environment="JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64"
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server-1.properties
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server-2.properties
ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh

[Install]
WantedBy=multi-user.target

But, When I run, It execute first ExecStart. It does not execute the next two ExecStart.

How do I achieve it?


Solution

  • You cannot. You could use multiple systemd scripts that depend on each other or wrap all three in one command (for example, docker-compose -f kafka-cluster.yaml up)

    FWIW, in no way is this fault tolerant, or really a good idea unless you have at least 18G memory (giving 6G RAM each) and at least a factor of 3 available mechanical HDDs on that machine (three or more pools of JBOD for log.dirs) and at least 3 separate CPU.

    Note: ExecStop is also only stopping one of the broker processes