加载中...

zookeeper添加开机自启

本地jdk服务地址:/usr/local/jdk1.8.0_341/

本地zk服务地址:/usr/local/zookeeper/

vim /usr/lib/systemd/system/zookeeper.service
[Unit]
Description=Zookeeper service
After=network.target
[Service]
Type=simple
Environment="PATH=/usr/local/sbin:/usr/local/jdk1.8.0_341/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/jdk-16.0.1/bin"
User=root
Group=root
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start
#ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop
Restart=on-failure
[Install]
WantedBy=multi-user.target

启动并加入开机自启

systemctl start zookeeper.service
systemctl enable zookeeper.service

要是不行就试试修改下Type的类型

vim /usr/lib/systemd/system/zookeeper.service
[Unit]
Description=Zookeeper service
After=network.target
[Service]
Type=forking
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk1.8.0_341/bin"
User=root
Group=root
ExecStart=/data/zookeeper/bin/zkServer.sh start
ExecStop=/data/zookeeper/bin/zkServer.sh stop
Restart=on-failure
[Install]
WantedBy=multi-user.target

添加开机自启

systemctl restart zookeeper.service
systemctl enable zookeeper.service
posted @ 2023-01-17 17:16  沾沾自喜的混子  阅读(155)  评论(0编辑  收藏  举报