首页 > 代码库 > zookeeper搭建

zookeeper搭建

1、解压

tar -zxf zookeeper-3.4.6.tar.gz

2、修改配置文件

[root@cluster3 hadoop]# cd zookeeper-3.4.6/conf/[root@cluster3 conf]# cp zoo_sample.cfg zoo.cfg[root@cluster3 conf]# vi zoo.cfg # The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takeinitLimit=10server.1=cluster1:2888:3888# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just# example sakes.dataDir=/usr/local/hadoop/zookeeper-3.4.6/datadataLogDir=/usr/local/hadoop/zookeeper-3.4.6/logs# the port at which the clients will connectclientPort=2181server.4=cluster4:2888:3888server.5=cluster5:2888:3888# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60## 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"zoo.cfg" 30L, 1011C written

3、修改myid

[root@cluster3 conf]# cd /usr/local/hadoop/zookeeper-3.4.6/data[root@cluster3 data]# vi myid3[root@cluster3 conf]# scp /usr/local/hadoop/zookeeper-3.4.6 root@cluster4:/usr/local/hadoop/[root@cluster3 data]# scp /usr/local/hadoop/zookeeper-3.4.6 root@cluster5:/usr/local/hadoop/[root@cluster4 conf]# cd /usr/local/hadoop/zookeeper-3.4.6/data[root@cluster4 data]# vi myid4[root@cluster5 conf]# cd /usr/local/hadoop/zookeeper-3.4.6/data[root@cluster5 data]# vi myid5

4、启动

在cluster4、cluster5启动[root@cluster4 bin]# ./zkServer.sh startJMX enabled by defaultUsing config: /usr/local/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfgStarting zookeeper ... STARTED[root@cluster5 bin]# ./zkServer.sh startJMX enabled by defaultUsing config: /usr/local/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfgStarting zookeeper ... STARTED

5、查看

[root@cluster5 bin]# ./zkServer.sh statusJMX enabled by defaultUsing config: /usr/local/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfgError contacting service. It is probably not running.这个可能是脚本问题,暂时不管。

 

zookeeper搭建