Zookeeper service and self-starting in Linux environment

1. Enter the service root directory

cd /etc/rc.d/init.d/

2. Create and edit service steps

vi zookeeper

The content is as follows:

#!/bin/bash

#chkconfig:2345 20 90

#description:zookeeper

#processname:zookeeper

export JAVA_HOME=/opt/jdk1.7.0_07

export PATH=$JAVA_HOME/bin:$PATH

case $1 in

         start) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh start;;

         stop) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh stop;;

         status) su root /usr/local/zookeeper-3.4.6/bin/zkServer.sh status;;

         restart) su root /usr/local/zookeeper-3.4.6/bin/zkServer.shrestart;;

         *)  echo "require start|stop|status|restart"  ;;

esac

Among them, the content marked in blue is the startup level of the service and the priority of opening and closing.

The operation commands marked in red are zookeeper

3. Give execute permission to the service file

chmod +x zookeeper

4. Add service, the service will start automatically after booting by default

chkconfig --add zookeeper

5. Verify

service zookeeper start
service zookeeper stop
service zookeeper restart
service zookeeper status

6. The switch-case syntax is used in the shell

 

echo "input type value:"
read type
case ${type} in
0) echo "type is 0"
;;
1) echo "type is 1"
;;
2|3)
echo "type is 2 or 3"
;;
*) echo "type error"
;;
esac

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326456479&siteId=291194637