美文网首页
zookeeper开机启动

zookeeper开机启动

作者: 黑白蓝调 | 来源:发表于2021-07-10 12:43 被阅读0次
  1. cd /etc/init.d 进入目录
  2. 创建文件zookeeper,把下面内容粘贴进去
#!/bin/bash
#
#chkconfig: 345 63 37
#description: zookeeper
#processname: zookeeper

export NODE_HOME=/usr/local/node-v15.5.0-linux-x64
export JAVA_HOME=/usr/local/jdk1.8.0_271
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export NODE_PATH=$NODE_HOME/lib/node_modules
export PATH=$PWD/bin:/usr/local/openresty/nginx/sbin:$JAVA_HOME/bin:$NODE_HOME/bin:$PATH

ZK_HOME=/usr/local/zookeeper

case $1 in
  start)
    sh $ZK_HOME/bin/zkServer.sh start
    echo "zookeeper is started"

    ;;
  stop)
    sh $ZK_HOME/bin/zkServer.sh stop
    echo "zookeeper is stop"
    ;;
  restart)
    sh $ZK_HOME/bin/zkServer.sh stop
        echo "zookeeper is stopped"
    sleep 1
         sh $ZK_HOME/bin/zkServer.sh start
    echo "zookeeper is started"
    ;;
  *)
    echo "start|stop|restart"
    ;;
esac
exit 0

  1. 给脚本添加权限chmod 755 zookeeper
  2. 添加服务到开机项 chkconfig --add zookeeper
  3. 设置为开机启动 chkconfig zookeeper on
  4. 测试 service zookeeper start

相关文章

网友评论

      本文标题:zookeeper开机启动

      本文链接:https://www.haomeiwen.com/subject/kvjcpltx.html