zookeeper installation, configuration, startup

download

 The download address on apache is: http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

configure

 Refer to the configuration documentation on the official website: https://zookeeper.apache.org/doc/trunk/zookeeperStarted.html

step1: Create a new data and logs directory under the unzipped folder

step2: Copy zoo_sample.cfg in the conf directory and save it as zoo.cfg

Change setting

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

Note: If the directory of dataDir or dataLogDir does not exist, it will cause zookeeper to fail to start 20160621

 

start up

Zookeeper depends on jdk for startup, so you must install and configure jdk before starting zookeeper

Start under Windows Double-click zkServer.cmd 

Run zkServer.sh start under linux

 

./zkServer.sh status to view the startup status

Mode: standalone means that it has been started in stand-alone mode

You can also view the startup status through the port it is listening on: lsof -i:2181 You can view the processes occupying the port

 

To enable startup:

method one:

Add /usr/local/zookeeper-3.4.6/bin/zkServer.sh start to /etc/rc.local and restart the system after saving and exiting

Method Two:

Start zookeeper by adding services
step1: Go to the /etc/rc.d/init.d/ directory

cd /etc/rc.d/init.d

 
step2: Create a new zookeeper file

touch zookeeper

 
step3:给zookeeper添加可执行权限

chmod +x zookeeper

 
step4:编辑zookeeper 添加如下内容

#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
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.sh restart;;
 *)  echo "require start|stop|status|restart"  ;;
esac

 
step5:要添加服务

chkconfig --add zookeeper

 
step6:现在可以用下面命令来启动停止zookeeper服务

service zookeeper start/stop

 
step7:设置为开机启动

chkconfig zookeeper on

     

 按照上面的做法最后还是不能启动,停止倒是可以停止。为什么呢?2010313。不知道是不是因为自己安装jdk的时候自己手动设置了环境变量 和默认设置的环境变量不在一起的问题让zookeeper先启动所以失败了(直接用service zookeeper start 也启动不起来好像可以排除这个原因)。还是因为网络连接方式不是桥接方式导致的?

 

 

配置介绍:zoo.cfg配置文件介绍

tickTime:Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里
dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
clientPort: 这个端口就是客户端连接 Zookeeper 服务器的端口

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327072387&siteId=291194637