Linux下设置zookeeper开机自启动 

一、以root用户登录系统:
二、进入init.d文件夹
cd /etc/init.d/
三、创建并打开zookeeper文件
vi zookeeper

四、zookeeper文件如下:  

#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
export JAVA_HOME=/usr/java/jdk1.7.0_79
export PATH=$JAVA_HOME/bin:$PATH
case $1 in
         start) su root /usr/zookeeper/bin/zkServer.sh start;;
         stop) su root /usr/zookeeper/bin/zkServer.sh stop;;
         status) su root /usr/zookeeper/bin/zkServer.sh status;;
         restart) su root /usr/zookeeper/bin/zkServer.shrestart;;
         *)  echo "requirestart|stop|status|restart"  ;;
esac

五、保存退出
:wq
六、加权限,把 zookeeper修改为可运行的文件,命令参考如下:

 chmod 755 apache
 chmod a+x tomcat 
七、使用chkconfig命令把 zookeeper命令加入到系统启动队列中:
chkconfig --add zookeeper
八、查看zookeeper的状态:
chkconfig --list zookeeper
九、测试
service zookeeper start
service zookeeper stop
service zookeeper restart
service zookeeper status

 

相关文章:

  • 2021-04-22
  • 2021-05-15
  • 2021-08-24
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-12-18
猜你喜欢
  • 2021-12-17
  • 2021-07-23
  • 2022-01-01
  • 2022-12-23
  • 2022-01-27
  • 2021-06-11
  • 2022-12-23
相关资源
相似解决方案