me小怪兽

导航

zookeeper添加系统服务


vim  /lib/systemd/system/zookeeper.service  添加服务

[Unit]
Description=zookeeper
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/jdk1.8.0_141/bin"
ExecStart=/home/kafka/bin/zookeeper-server-start.sh -daemon /home/kafka/config/zookeeper.properties
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/home/kafka/bin/zookeeper-server-stop.sh stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

备注:
[service]
Type 服务启动类型 forking:后台启动
Environment 为依赖的环境,“/home/jdk1.8.0_141/bin”是自己jdk的安装路径
ExecStart 定义启动的命令,“/home/kafka/” 为自己的zookeeper安装路径,“-daemon”:台启动
ExecReload 定义重启命令,“/bin/kill -s HUP $MAINPID” 通用重启命令
ExecStop 定义停止命令
PrivateTmp 是否分配独立空间

4、刷新配置
systemctl daemon-reload
5、启动zookeeper服务
#启动
systemctl start zookeeper
#查看状态
systemctl status zookeeper 
#停止
systemctl stop zookeeper
6、将zookeeper加入开机服务
systemctl enable zookeeper


注意:kafka服务一定要放在zookeeper服务之后启动


posted on 2022-08-30 10:12  me小怪兽  阅读(175)  评论(0编辑  收藏  举报