天天看点

CentOS 7 zookeeper service 开机自启

先安装JDK(yum安装也可以,不需要配置JAVA_HOME)

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

[Unit]
Description=zookeeper.service
After=network.target
[Service]
Type=forking
Environment=/home/jiankunking/zookeeper
ExecStart=/home/jiankunking/zookeeper/bin/zkServer.sh start
ExecStop=/home/jiankunking/zookeeper/bin/zkServer.sh stop
ExecReload=/home/jiankunking/zookeeper/bin/zkServer.sh restart
[Install]
WantedBy=multi-user.target      

重新加载服务

systemctl daemon-reload      

重新加载配置信息:systemctl daemon-reload

启动zookeeper:systemctl start zookeeper.service

关掉zookeeper:systemctl stop zookeeper.service

查看进程状态及日志:systemctl status zookeeper.service

开机自启动:systemctl enable zookeeper.service

关闭自启动:systemctl disable zookeeper.service

查看zk的状态命令(可以看到当前节点是follower还是leader):

bin/zkServer.sh status      

个人微信公众号:

继续阅读