Linux之zookeeper开机启动

1、用cd 命令切换到/etc/rc.d/init.d/目录下

[root@bogon ~]# cd /etc/rc.d/init.d

2、用touch zookeeper创建一个文件

[root@bogon init.d]# touch zookeeper

3、添加可执行权限

[root@bogon init.d]# chmod +x zookeeper

4、编辑zookeeper这个文件,添加以下内容

[root@bogon init.d]# vi zookeeper
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
case $1 in
          start) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh start;;
          stop) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh stop;;
          status) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh status;;
          restart) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh restart;;
          *)  echo "require start|stop|status|restart"  ;;
esac

5、使用wq保存并退出

6、启动/停止zookeeper服务

[root@bogon init.d]# service zookeeper start
JMX enabled by default
Using config: /usr/local/java/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

7、把zookeeper添加到开机启动里面

[root@bogon init.d]# chkconig --add zookeeper
原文地址:https://www.cnblogs.com/liukaifeng/p/10052652.html