我的zookeeper安装之旅

参考文章:

http://www.cnblogs.com/tonylovett/p/5227973.html

http://www.linuxidc.com/Linux/2015-05/117697.htm

1.下载zookeeper。

我在官网上下载的,下载地址:http://zookeeper.apache.org/releases.html#download,需要点击几次链接

最终下载地址:http://apache.fayea.com/zookeeper/

我下载的版本是3.4.10。

2.安装位置选定

我的安装用户为hadoop,安装目录为/home/hadoop/software/zookeeper-3.4.10

首先,将安装包zookeeper-3.4.10.tar.gz 用Secure CRT 拷贝到 /home/hadoop/software目录

然后,使用tar 命令直接解压,这样就在/home/hadoop/software目录下有一个zookeeper-3.4.10目录

然后,在zookeeper-3.4.10目录下创建zkdata和zkdatalog这2个文件夹

3.修改配置文件

cd  zookeeper-3.4.10/conf ,将zoo_sample.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=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/hadoop/software/zookeeper-3.4.10/zkdata
dataLogDir=/home/hadoop/software/zookeeper-3.4.10/zkdatalog
# the port at which the clients will connect
clientPort=2181
# 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
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

server.1=master1:2888:3888
server.2=slave02:2888:3888
server.3=slave03:2888:3888
server.4=slave04:2888:3888
server.5=slave05:2888:3888

配置文件说明:

在这里需要注意zoo.cfg的配置文件中的dataDir和dataLogDir的路径当中的文件夹必须要已存在,否则后面启动zkServer服务的时候会失败。

4、在dataDir对应的路径文件夹下(我这里是zkdata文件夹),创建一个myid的文件,并在该文件中输入对应集群各节点的id,我这里对应的是hadoop1对应的就是1,这个是与

server.1=hadoop1:2888:3888对应的。各个节点分别输入对应的id值即可。

5、启动zkServer

在各节点上执行:zkServer.sh start  并通过jps可以看到:启动了QuorumpeerMain进程。

6、此时可以通过zkServer.sh  status 命令来查看节点的启动状态。

这里需要注意点,只有当至少启动了三个节点之后,该命令才会产生结果。否则会显示:zookeeper Error contacting service. It is probably not running错误

当你启动了至少三个节点之后,执行该命令可以看到:  

至此,zookeeper的安装工作结束。

7、关闭zookeeper服务

  zkServer.sh stop  关闭

  zkServer.sh restart  重启

原文地址:https://www.cnblogs.com/kxxx/p/7275203.html