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
$ systemctl daemon-reload
- $ systemctl start zookeeper
- $ systemctl status zookeeper
- $ systemctl restart zookeeper
3. 开机自启动
$ systemctl enable zookeeper