一:环境
centos
jdk1.6
zookeeper-3.4.3 下载
二:配置
将解压出来的zookeeper 复制三份,这里分别叫做 zookeeper-1,zookeeper-2和zookeeper-3。
1. zookeeper-1 配置:
创建data目录:/home/java2000_wl/hadoop/zookeeper-1/data 创建log目录:/home/java2000_wl/hadoop/zookeeper-1/logs 创建myid文件:/home/java2000_wl/hadoop/zookeeper-1/data/myid 内容: 1 创建/home/java2000_wl/hadoop/zookeeper-1/conf/zoo.cfg文件 内容: tickTime=2000 initLimit=10 syncLimit=5 dataDir=/home/java2000_wl/hadoop/zookeeper-1/data clientPort=2181 dataLogDir=/home/java2000_wl/hadoop/zookeeper-1/logs server.1=127.0.0.1:4000:5000 server.2=127.0.0.1:4001:5001
server.3=127.0.0.1:4002:5002
2.zookeeper-2 配置:
创建data目录:/home/java2000_wl/Hadoop/zookeeper-2/data 创建log目录:/home/java2000_wl/hadoop/zookeeper-2/logs 创建myid文件:/home/java2000_wl/hadoop/zookeeper-2/data/myid 内容: 2 创建/home/java2000_wl/hadoop/zookeeper-2/conf/zoo.cfg文件 内容: tickTime=2000 initLimit=10 syncLimit=5 dataDir=/home/java2000_wl/hadoop/zookeeper-2/data clientPort=2182 dataLogDir=/home/java2000_wl/hadoop/zookeeper-2/logs server.1=127.0.0.1:4000:5000 server.2=127.0.0.1:4001:5001 server.3=127.0.0.1:4002:5002
3.zookeeper-3 配置:
创建data目录:/home/java2000_wl/hadoop/zookeeper-3/data 创建log目录:/home/java2000_wl/hadoop/zookeeper-3/logs 创建myid文件:/home/java2000_wl/hadoop/zookeeper-3/data/myid 内容: 3 创建/home/java2000_wl/hadoop/zookeeper-3/conf/zoo.cfg文件 内容: tickTime=2000 initLimit=10 syncLimit=5 dataDir=/home/java2000_wl/hadoop/zookeeper-3/data clientPort=2183 dataLogDir=/home/java2000_wl/hadoop/zookeeper-3/logs server.1=127.0.0.1:4000:5000 server.2=127.0.0.1:4001:5001 server.3=127.0.0.1:4002:5002
三:启动服务
分别进入三个服务的bin目录 启动服务
bin/zkServer.sh start
四:客户端连接
成功启动zookeeper服务之后,输入下述命令,连接到zookeeper服务
./zkCli.sh -server 127.0.0.1:2181