CentOS6.5安装ZooKeeper3.4.6并设置开机启动

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35213388/article/details/81839605

一.上传zookeeper-3.4.6.tar.gz到/usr/soft文件夹

二.解压文件到/usr/local

tar -xvf zookeeper-3.4.6.tar.gz -C /usr/local

三.进入zookeeper-3.4.6目录,创建data文件夹

mkdir data

四.进入conf文件夹,复制zoo_sample.cfg取名为zoo.cfg,里面可以配置端口号,是否启用集群

cp zoo_sample.cfg zoo.cfg

五.修改zoo.cfg里的dataDir路径为之前创建的data文件夹的路径

dataDir=/usr/local/zookeeper-3.4.6/data

六.进入bin目录,启动zookeeper相关

1.启动zookeeper

./zkServer.sh start

2.查看启动状态

./zkServer.sh status

3.停止zookeeper

./zkServer.sh stop

七.关闭防火墙,并配置开机不启动防火墙

service iptables stop

chkconfig iptables off

PS:如果不能成功启动zookeeper,需要删除data目录下的zookeeper_server.pid文件。

八.设置zookeeper开机启动

1.进入/etc/rc.d修改rc.local文件,需要指定jdk路径以及zookeeper启动路径

#!/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/jdk1.8.0_121 #自身jdk路径
/usr/local/apache-tomcat-8.0.52/bin/startup.sh start #tomcat路径
/usr/local/zookeeper-3.4.6/bin/zkServer.sh start

2.重启系统,然后查看zookeeper启动状态

./zkServer.sh status

 

猜你喜欢

转载自blog.csdn.net/qq_35213388/article/details/81839605