ZooKeeper安装配置

 

 

1.安装JDK

 

tar -zxvf ./jdk-7u45-linux-i586.tar.gz  -C /usr/lib/jvm  
cd /usr/lib/jvm  

2.配置环境变量

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH  

3.下载zk

  wget mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz 

4.配置host

192.168.14.100   slave-01
192.168.14.105   slave-02
192.168.14.102   slave-03

5.zk配置,slave-01为例

 

# 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/storage/zookeeper
# the port at which the clients will connect
clientPort=2181

server.1=slave-01:2888:3888
server.2=slave-02:2888:3888
server.3=slave-03:2888:3888

 

 

6.scp复制到其他主机slave-02,slave-03

scp -r root@192.168.14.100:/usr/local/hadoop/zookeeper_3.4.6 . 从远程复制到本地
scp zookeeper-3.4.6.tar.gz root@192.168.14.102:/usr/local/hadoop 从本地复制到远程

7.设置myid

在我们配置的dataDir指定的目录下面,创建一个myid文件,里面内容为一个数字,用来标识当前主机,conf/zoo.cfg文件中配置的server.X中X为什么数字,则myid文件中就输入这个数字,例如:

slave-01:echo "1" > /home/hadoop/storage/zookeeper/myid  
slave-02:echo "2" > /home/hadoop/storage/zookeeper/myid  
slave-03:echo "3" > /home/hadoop/storage/zookeeper/myid

8.启动zk集群slave-01,slave-02,slave-03

bin/zkServer.sh start  

9.查看启动日志

tail -f zookeeper.out

 

10.验证安装成功

bin/zkServer.sh status

 

11 zk客户端连接

[root@linux-TestEnvironmentLog-14-102 zookeeper_3.4.6]# bin/zkCli.sh -server slave-01:2181

 

 

 主要:

参考:jdk7 http://www.cnblogs.com/waimai/p/3443385.html

参考: http://blog.csdn.net/shirdrn/article/details/7183503

其他:

参考 :http://www.cnblogs.com/sunddenly/p/4018459.html

参考:http://my.oschina.net/vbird/blog/384043

参考:http://www.cnblogs.com/haippy/archive/2012/07/19/2599989.html

 

 
 
 
 
 
posted @ 2015-11-08 14:05  积淀  阅读(275)  评论(0编辑  收藏  举报