zookeeper小白,不知道配置文件错哪了,谢谢了

[root@itcast conf]# vim zoo.cfg

#
tickTime=2000
#
initLimit=10
#
syncLimit=5

dataDir=/root/zookeeper-3.4.6/data

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
~
~
~
~
~
~
~
~
~
~
~
~
~
"zoo.cfg" 25L, 618C 已写入
报的错
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /zoo2
网上说是配置文件的原因但我不知道错哪了

ZK至少需要三台机器(或者虚拟机),我的机器分别为slave1,slave2,slave3。我自己搭建的过程如下:
1、在salve1中操作,我的ZK目录为 ~/soft/zookeeper-3.4.5,首先复制一份配置文件
cd ~/solf/zookeeper-3.4.5/conf
cp zoo__sample.cfg zoo.cfg
2、修改zoo.cfg,其他的配置默认就行
nano zoo.cfg
修改
dataDir=/home/ubuntu/solf/zookeeper-3.4.5/tmp
文件末尾添加
server.1=slave1:2888:3888
server.2=slave2:2888:3888
server.3=slave3:2888:3888
3、创建tmp文件
cd ~/solf/zookeeper-3.4.5
mkdir tmp
cd tmp
touch myid
echo 1 > myid
查看
cat myid
1
表示配置成功
4、将配置好的zookeeper-3.4.5发送至slave2、slave3
cd ~/solf
scp -r zookeeper-3.4.5 ubuntu@slave2:~/solf
scp -r zookeeper-3.4.5 ubuntu@slave3:~/solf

修改myid
slave2下:
echo 2 > myid

slave3下:
echo 3 > myid

整个hadoop ha模式的搭建可参考我的博客
hadoop搭建