1.安装jdk,zookeeper就不说啦,自己搜索下。
2.开机自启动和注册为服务。
(1)开机自启动:编辑/etc/rc.d/rc.local文件,添加zkServer.sh路径。
vi /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)注册为服务:到/etc/rc.d/init.d目录下添加,zookeeper脚本
cd /etc/rc.d/init.d
touch zookeeper
ls -al --查看到没有执行权限,修改权限
chmod +x zookeeper
vi zookeeper -- 打开zookeeper编辑脚本,下面为要 编辑的内容
#! /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
添加好后保存。测试:
service zookeeper start
启动成功后则添加服务成功了。
(3)将服务添加为开机启动。
chkconfig --add zookeeper --zookeeper为刚才注册的服务
chkconfig --list --查看刚才添加的zookeeper是否成功。有显示为成功。