****************************************************************************************************
安装zookeeper
[root@a1 hadoop]# tar -zxvf zookeeper-3.3.5-cdh3u5.tar.gz
[root@a1 hadoop]# cd zookeeper-3.3.5-cdh3u5/
[root@a1 zookeeper-3.3.5-cdh3u5]# vi conf/zoo.cfg
#server.0=localhost:2888:3888(注销这行)
添加
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/hadoop/zookeeper-3.3.5-cdh3u5/data
dataLogDir=/home/hadoop/zookeeper-3.3.5-cdh3u5/log
server.1=192.168.92.151:2888:3888
server.2=192.168.92.152:2888:3888
server.3=192.168.92.153:2888:3888
安装zookeeper
[root@a1 hadoop]# tar -zxvf zookeeper-3.3.5-cdh3u5.tar.gz
[root@a1 hadoop]# cd zookeeper-3.3.5-cdh3u5/
[root@a1 zookeeper-3.3.5-cdh3u5]# vi conf/zoo.cfg
#server.0=localhost:2888:3888(注销这行)
添加
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/hadoop/zookeeper-3.3.5-cdh3u5/data
dataLogDir=/home/hadoop/zookeeper-3.3.5-cdh3u5/log
server.1=192.168.92.151:2888:3888
server.2=192.168.92.152:2888:3888
server.3=192.168.92.153:2888:3888
***2888端口号是zookeeper服务之间通信的端口,而3888是zookeeper与其他应用程序通信的端口
创建目录
[root@a1 zookeeper-3.3.5-cdh3u5]# mkdir -pv data log
拷贝给所有节点
[root@a1 zookeeper-3.3.5-cdh3u5]# scp -r zookeeper-3.3.5-cdh3u5/ h152:/home/hadoop/
[root@a1 zookeeper-3.3.5-cdh3u5]# scp -r zookeeper-3.3.5-cdh3u5/ h153:/home/hadoop/
[root@a1 zookeeper-3.3.5-cdh3u5]# scp -r zookeeper-3.3.5-cdh3u5/ h152:/home/hadoop/
[root@a1 zookeeper-3.3.5-cdh3u5]# scp -r zookeeper-3.3.5-cdh3u5/ h153:/home/hadoop/
改变所有节点所有者
[root@a1 zookeeper-3.3.5-cdh3u5]# chown hadoop.hadoop zookeeper-3.3.5-cdh3u5/ -R
[root@a2 jdk1.6.0_38]# chown hadoop.hadoop zookeeper-3.3.5-cdh3u5/ -R
[root@a3 hadoop-0.20.2-cdh3u5]# chown hadoop.hadoop /usr/local/zookeeper-3.3.5-cdh3u5/ -R
[root@a1 zookeeper-3.3.5-cdh3u5]# chown hadoop.hadoop zookeeper-3.3.5-cdh3u5/ -R
[root@a2 jdk1.6.0_38]# chown hadoop.hadoop zookeeper-3.3.5-cdh3u5/ -R
[root@a3 hadoop-0.20.2-cdh3u5]# chown hadoop.hadoop /usr/local/zookeeper-3.3.5-cdh3u5/ -R
切换用户为hadoop进行操作
在节点1上设置myid为1,节点2上设置myid为2,节点3上设置myid为3
[hadoop@a1 ~]$ vi zookeeper-3.3.5-cdh3u5/data/myid
1
在节点1上设置myid为1,节点2上设置myid为2,节点3上设置myid为3
[hadoop@a1 ~]$ vi zookeeper-3.3.5-cdh3u5/data/myid
1
[hadoop@a2 ~]$ vi zookeeper-3.3.5-cdh3u5/data/myid
2
2
[hadoop@a3 ~]$ vi zookeeper-3.3.5-cd0h3u5/data/myid
3
3
启动zookeeper (3个节点 都要配置)
[hadoop@a1 ~]$ cd zookeeper-3.3.5-cdh3u5/bin/
[hadoop@a1 bin]$ vi zkServer.sh
[hadoop@a1 ~]$ cd zookeeper-3.3.5-cdh3u5/bin/
[hadoop@a1 bin]$ vi zkServer.sh
编辑第100行
(1)if [[ -f $ZOOPIDFILE ]]; then (就是把这个注销掉,否则会报一个bugger
)
(1)if [[ -f $ZOOPIDFILE ]]; then (就是把这个注销掉,否则会报一个bugger
)
(2)
/var 目录有其他用户写权限(这个是必须做的 三台都转换成ROOT)
[root@a1 ~]# chmod 777 /var
[root@a1 ~]# chmod 777 /var
[hadoop@a1 bin]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.3.5-cdh3u5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
JMX enabled by default
Using config: /usr/local/zookeeper-3.3.5-cdh3u5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
分别在3个节点上查看状态
[hadoop@a1 bin]$ ./zkServer.sh status
测试
[hadoop@a1 bin]$ echo ruok |nc 192.168.8.91 2181
imok
[hadoop@a1 bin]$ echo ruok |nc 192.168.8.91 2181
imok