首页 > 代码库 > zookeoper在root下设置开机启动

zookeoper在root下设置开机启动

1 准备工作

1) 切换到/etc/rc.d/init.d/目录下

2) 创建zookeeper文件:touch zookeeper

3)更新权限:chmod +777 zookeeper

4)编辑文件,在zookeeper里面输入如下内容

#!/bin/bash#chkconfig:2345 20 90#description:zookeeper#processname:zookeeper#export JAVA_HOME=/usr/local/jdk8#export PATH=$JAVA_HOME/bin:$PATHcase $1 in         start) /usr/local/zookeeper3.5.2/bin/zkServer.sh start;;         stop) /usr/local/zookeeper3.5.2/bin/zkServer.sh stop;;         status) /usr/local/zookeeper3.5.2/bin/zkServer.sh status;;         restart) /usr/local/zookeeper3.5.2/bin/zkServer.shrestart;;         *)  echo "requirestart|stop|status|restart"  ;;esac

2 设置等级:chkconfig --level zookeeper on

3 验证:chkconfig --add zookeeper

4:以后就可以使用

    servicezookeeper start/stop

  来启动停止zookeeper服务

注:chkconfig命令普及

chkconfig命令用法语法:chkconfig --list [name]chkconfig --add namechkconfig --del namechkconfig [--level levels] name <on|off|reset>chkconfig [--level levels] name

 

zookeoper在root下设置开机启动