分布式安装zookeeper3.4.5

zookeeper官方下载地址http://www.apache.org/dyn/closer.cgi/zookeeper/

zookeeper安装时建议使用单数。

我的集群/etc/hosts文件(zookeeper安装各节点配置):

192.168.1.191 slave1

192.168.1.192 slave2

192.168.1.193 slave3

 首先配置slave1:

1、将下载的zookeeper-3.4.5.tar.gz包解压,我的解压目录为/opt下

2、打开zookeeper-3.4.5/conf目录,复制zoo_sample.cfg文件,改名为zoo.cfg,然后对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=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/home/zookeep/
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=slave1:2888:3888
server.2=slave2:2888:3888
server.3=slave3:2888:3888

3、在文件zoo.cfg中dataDir的配置目录下,新建一个myid文件,在文件中写入server.x对应的数字。每台服务器都需要配置。

1代表zoo.cfg文件中配置的server.1,也就是说myid文件中的内容x就是zoo.cfg文件中配置的server.x

如果不配置myid的话,在启动zookeeper时会报一个java.lang.IllegalArgumentException: /home/zookeep/myid file is missing的异常。

4、bin目录下执行zkServer.sh start就可以了。

 

 

分布式安装zookeeper3.4.5

上一篇:Hadoop namenode启动瓶颈分析


下一篇:华硕电脑笔记本科技公司品牌logo标志设计流程分享