分布式环境ZooKeeper3.4.5安装

 

 

VirtualBox+Centos6.4搭建Hadoop1.1.2分布式环境http://mvplee.iteye.com/blog/2233435

 

确保集群内服务器时间一致

 

解压文件

[root@hadoop1 local]# tar -zxvf zookeeper-3.4.5.tar.gz 

配置home变量

[root@hadoop1 local]# more /etc/profile
export ZOOKEEPER_HOME=/usr/local/zookeer-3.4.5
PATH=.:$HADOOP_HOME/bin:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$PATH
[root@hadoop1 local]# source /etc/profile

 配置zookeeper配置文件,复制一副sample配置文件,对其进行修改

[root@hadoop1 conf]# pwd
/usr/local/zookeeper-3.4.5/conf
[root@hadoop1 conf]# mv zoo_sample.cfg zoo.cfg

 修改内容

[root@hadoop1 conf]# more zoo.cfg
dataDir=/usr/local/zookeeper-3.4.5/data
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888

 配置zookeeper节点

[root@hadoop1 zookeeper-3.4.5]# mkdir data
[root@hadoop1 data]# vim myid
[root@hadoop1 data]# more myid
0

 把hadoop1上所配置的复制到hadoop2、hadoop3上

[root@hadoop1 zookeeper-3.4.5]# scp /etc/profile hadoop2:/etc/profile
[root@hadoop1 zookeeper-3.4.5]# scp /etc/profile hadoop3:/etc/profile
[root@hadoop1 zookeeper-3.4.5]# scp -r /usr/local/zookeeper-3.4.5 hadoop2:/usr/local/
[root@hadoop1 zookeeper-3.4.5]# scp -r /usr/local/zookeeper-3.4.5 hadoop3:/usr/local/

 在hadoop2、hadoop3上修改zookeeper-3.4.5/conf/data/myid节点配置文件

 

在hadoop1上启动zookeeper

[root@hadoop1 bin]# pwd
/usr/local/zookeeper-3.4.5/bin
[root@hadoop1 bin]# zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 启动后会在目录下多出一个zookeeper.out文件,记录异常信息java.net.ConnectException:

[root@hadoop1 bin]# more zookeeper.out
2015-08-07 09:13:45,063 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@368] - Cannot open channel to 2 at election address hadoop
2/192.168.56.22:3888
java.net.ConnectException: Connection refused
2015-08-07 09:14:36,271 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@368] - Cannot open channel to 3 at election address hadoop
3/192.168.56.23:3888
java.net.ConnectException: Connection refused

 原因是hadoop2、hadoop3还没启动,所以通信失败,启动hadoop2、hadoop3上的zookeeper

[root@hadoop2 bin]# zkServer.sh start
[root@hadoop3 bin]# zkServer.sh start

 zookeeper都启动会搞选举,查看选举结果

[root@hadoop1 bin]# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
[root@hadoop2 bin]# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: leader
[root@hadoop3 bin]# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

 

 

 

 

你可能感兴趣的:(zookeeper)