zookeeper in linux boot from the start and registered as a service

1. Install jdk, zookeeper will not say, under their own search.

2. boot from the start and registered as a service.

(1) boot from the start: Edit the /etc/rc.d/rc.local file and add zkServer.sh path.

  we /etc/rc.d/rc.local

  #!/bin/sh

 # This script will be executed *after* all the other init scripts.
 # You can put your own initialization stuff in here if you don't
 # want to do the full Sys V style init stuff.

 touch /var/lock/subsys/local
 export JAVA_HOME=/usr/java/jdk1.8.0_221        --jdk的路径,自己安装的目录
 /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start   --zookeeper的zkServer.sh的路径

(2) registered as a service: Add to /etc/rc.d/init.d next directory, zookeeper script

  cd /etc/rc.d/init.d

  touch zookeeper

  ls -al - do not have permission to view, modify permissions

  chmod +x zookeeper

  vi zookeeper - Open zookeeper edit the script, the following is to be edited content

  #! /bin/bash

  export JAVA_HOME=/usr/java/jdk1.8.0_221

  case $1 in
    start) su root /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start;;
    stop) su root /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh stop;;
    status) su root /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh status;;
    restart) su /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh restart;;
    *) echo "require start|stop|status|restart" ;;
  esac

After adding a good save. test:

  service zookeeper start

After the successful launch of the service successfully added.

(3) add the service to boot.

  chkconfig --add zookeeper --zookeeper was just registered service

  chkconfig --list - See if you just added zookeeper success. There appears to succeed.

  

  

 

 

 


   


Guess you like

Origin www.cnblogs.com/xiangxinhouse/p/11318457.html