首页 > 代码库 > Ubuntu 安装zookeeper

Ubuntu 安装zookeeper

下载zookeeper   Zookeeper下载

下载以后将文件迁移到/home/Hadoop/文件夹下面

hongdada@ubuntu:~/Downloads$ sudo mv zookeeper-3.4.9.tar.gz /home/Hadoop

tar -zxvf解压

hongdada@ubuntu:/home/Hadoop$ sudo tar -zxvf zookeeper-3.4.9.tar.gz

将文件夹zookeeper-3.4.9改成zookeeper

hongdada@ubuntu:/home/Hadoop$ sudo mv zookeeper-3.4.9 zookeeper

 

解压以后conf文件夹中创建zoo_sample.cfg的副本zoo.cfg

hongdada@ubuntu:/home/Hadoop$ cd zookeeperhongdada@ubuntu:/home/Hadoop/zookeeper$ cd confhongdada@ubuntu:/home/Hadoop/zookeeper/conf$ mp zoo_sample.cfg zoo_cfgmp:未找到命令hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ cp zoo_sample.cfg zoo.cfgcp: 无法创建普通文件‘zoo.cfg‘: 权限不够hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ sudo cp zoo_sample.cfg zoo.cfghongdada@ubuntu:/home/Hadoop/zookeeper/conf$ sudo gedit zoo.cfg

原始的zoo.cfg:

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# 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=/tmp/zookeeper# the port at which the clients will connectclientPort=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

修改为:

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# 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=/home/Hadoop/zookeeper/data # 数据持久化路径dataLogDir=/home/Hadoop/zookeeper/log #日志保存路径server.1=192.168.1.203:2888:3888# the port at which the clients will connectclientPort=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

说明:

syncLimit=5 # Leader与Follower之间的最大响应时间单位,响应超过syncLimit*tickTime,Leader认为Follwer死掉,从服务器列表中删除Follwer。initLimit=10 # 投票选举新leader的初始化时间。tickTime=2000 # Zookeeper服务器心跳时间,单位毫秒clientPort=2181 # 连接端口dataDir=/home/Hadoop/zookeeper/data # 数据持久化路径dataLogDir=/home/Hadoop/zookeeper/log # 日志保存路径server.1=10.10.100.10:2888:3888

设置环境变量:

hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ export ZOOKEEPER_HOME=/home/Hadoop/zookeeperhongdada@ubuntu:/home/Hadoop/zookeeper/conf$ export PATH=$PATH:$ZOOKEEPER_HOME/bin

启动zookeeper:

hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ cd .hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ cd ../hongdada@ubuntu:/home/Hadoop/zookeeper$ cd binhongdada@ubuntu:/home/Hadoop/zookeeper/bin$ zkServer.sh startZooKeeper JMX enabled by defaultUsing config: /home/Hadoop/zookeeper/bin/../conf/zoo.cfgmkdir: 无法创建目录"/home/Hadoop/zookeeper/data # 数据持久化路径": 权限不够Starting zookeeper ... /home/Hadoop/zookeeper/bin/zkServer.sh: 行 140: ./zookeeper.out: 权限不够/home/Hadoop/zookeeper/bin/zkServer.sh: 行 149: /home/Hadoop/zookeeper/data # 数据持久化路径/zookeeper_server.pid: 没有那个文件或目录FAILED TO WRITE PIDhongdada@ubuntu:/home/Hadoop/zookeeper/bin$ sudo zkServer.sh start[sudo] hongdada 的密码: sudo: zkServer.sh:找不到命令hongdada@ubuntu:/home/Hadoop/zookeeper/bin$ sudo ./zkServer.sh startZooKeeper JMX enabled by defaultUsing config: /home/Hadoop/zookeeper/bin/../conf/zoo.cfgStarting zookeeper ... STARTED

启动是./zkServer.sh start

 

http://jingyan.baidu.com/article/456c463b60bd380a5931446f.html

http://blog.csdn.net/cruise_h/article/details/19046357

Ubuntu 安装zookeeper