开机自启:标签:systemctl,service,zookeeper,systemd,自启,usr,开机 From: https://www.cnblogs.com/tianyitest/p/17071818.html
(1)编辑zookeeper.service文件
vim /usr/lib/systemd/system/zookeeper.service
加入如下内容
复制代码
[Unit]
Description=zookeeper
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh start
ExecReload=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh restart
ExecStop=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target
复制代码
(2)生效
systemctl daemon-reload
(3)改变文件权限
chmod 777 /usr/lib/systemd/system/zookeeper.service
(4)systemctl开机启动zookeeper
systemctl enable /usr/lib/systemd/system/zookeeper.service
或
systemctl enable /usr/lib/systemd/system/zookeeper
(5)查看是否开机启动
systemctl is-enabled zookeeper.service
(6)systemctl取消开机启动redis
systemctl disable zookeeper.service