转载

zookeeper安装教程

zookeeper安装教程

集群配置

机器 IP地址
First 192.168.56.4
Second 192.168.56.5
Third 192.168.56.6

每台机器的配置

切换到zookeeper的配置目录, 我的是zookeeper-3.4.13/conf, 执行以下命令

#创建zoo.cfg
cp zoo_sample.cfg zoo.cfg

#修改zoo.cfg
vim zoo.cfg

zoo.cfg里面的内容,修改成如下

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/home/learn/hadoop/zookeeper-data

dataLogDir=/home/learn/hadoop/zookeeper-log
# the port at which the clients will connect

clientPort=2181

server.1=0.0.0.0:8888:7777
server.2=192.168.56.5:8888:7777
server.3=192.168.56.6:8888:7777

说明:

dataDir=/home/learn/hadoop/zookeeper-data, 修改成你自己的目录,dataLogDir亦是

另外,两个目录一定必须提前新建好

server.1=0.0.0.0:8888:7777
server.2=192.168.56.5:8888:7777
server.3=192.168.56.6:8888:7777

0.0.0.0指的是本台机器的ip, 所以上面的配置是针对First配置的,可以知道Second的配置是

server.1=192.168.56.4:8888:7777
server.2=0.0.0.0:8888:7777
server.3=192.168.56.6:8888:7777

最后在zookeeper-data目录(就是你配置的目录), 新建myid文件

Fisrt 填入 1

Second 填入 2

Third 填入 3

针对于上面的ip配置(server.1, server.2, server.3)

提醒

除了我特别指出来的ip配置myid配置, 其他机器配置均相同。

zookeeper的命令

切换到zookeeper的bin目录,我的是zookeeper-3.4.13/bin

#启动服务
./zkServer.sh start

#重启服务
./zkServer.sh restart

#停止服务
./zkServer.sh stop

在每台机器上,启动服务,过一会而,就出选举出leader, follower.

正文到此结束
本文目录