1. 进入到启动目录
cd /etc/rc.d/init.d/
2. 新建zookeeper
touch zookeeper
3. 添加内容
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
export JAVA_HOME=/usr/local/jdk
case $1 in
start) /usr/local/zookeeper/bin/zkServer.sh start;;
stop) /usr/local/zookeeper/bin/zkServer.sh stop;;
status) /usr/local/zookeeper/bin/zkServer.sh status;;
restart) /usr/local/zookeeper/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
4. 授权
chmod a+x zookeeper
5. 服务控制
service zookeeper start
6. 开机自启动
chkconfig zookeeper on
=================================
简易办法
vim /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/local/jdk
/usr/local/zookeeper/zkServer.sh start
cd /etc/rc.d/init.d/
2. 新建zookeeper
touch zookeeper
3. 添加内容
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
export JAVA_HOME=/usr/local/jdk
case $1 in
start) /usr/local/zookeeper/bin/zkServer.sh start;;
stop) /usr/local/zookeeper/bin/zkServer.sh stop;;
status) /usr/local/zookeeper/bin/zkServer.sh status;;
restart) /usr/local/zookeeper/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
4. 授权
chmod a+x zookeeper
5. 服务控制
service zookeeper start
6. 开机自启动
chkconfig zookeeper on
=================================
简易办法
vim /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/local/jdk
/usr/local/zookeeper/zkServer.sh start