Ubuntu Zookeeper开机自启动服务

1、创建service文件

        在/lib/systemd/system目录下创建zookeeper.service文件

[Unit]
Description=Apache Zookeeper server
Documentation=http://zookeeper.apache.org
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
Environment="JAVA_HOME=/usr/local/programs/jdk-8u333-linux-x64/jdk1.8.0_333"
ExecStart=/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
ExecStop=/usr/local/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
Alias=zookeeper.service
 2. 启动服务并检查状态
$ systemctl daemon-reload
$ systemctl start zookeeper
$ systemctl status zookeeper
$ systemctl restart zookeeper

3. 开机自启动

$ systemctl enable zookeeper

你可能感兴趣的:(Ubuntu20,ubuntu,zookeeper,debian)