本集群搭建是基于之前的hadoop集群,有不明白之处可查看之前的hadoop集群搭建
1 在hadoop中的nn中: tar -zxvf zookeeper-3.4.12.tar.gz 解压zookeeper
2 进入解压后文件夹的conf目录
3 cp zoo_sample.cfg zoo.cfg 复制文件,并命名为zoo.cfg
4 vi zoo.cfg
1)dataDir=/home/hadoop/opt/tmp/zookeeper 新建数据目录:磁盘中保存数据的路径:需要更改
2)配置zookeeper集群所在的ip地址和端口
server.1=dn1:2888:3888
server.2=dn2:2888:3888
server.3=dn3:2888:3888
2888 ===》leader和follower通信用的 3888:用于投票
# 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=/tmp/zookeeper
dataDir=/home/hadoop/opt/tmp/zookeeper
# 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
#zookeeper服务所在的端口
server.1=dn1:2888:3888
server.2=dn2:2888:3888
server.3=dn3:2888:3888
5 将zookeeper-3.4.12压缩成zk.3.4.tar.gz文件
tar czf zk.3.4.tar.gz zookeeper-3.4.12/
6 将压缩文件复制到dn1,dn2,dn3中
1) scp zk.3.4.tar.gz dn1:~
1) scp zk.3.4.tar.gz dn1:~
1) scp zk.3.4.tar.gz dn1:~
7 进入dn1中: 将文件解压到opt下
tar zxf zk.3.4.tar.gz -C ~/opt
mkdir -p tmp/zookeeper 创建目录
echo 1 > myid
8
1)在dn 1中创建目录:dataDir=/home/hadoop/opt/tmp/zookeeper,并在目录中生成一个文件myid,内容为1.
2)在dn2 中创建目录:dataDir=/home/hadoop/opt/tmp/zookeeper,并在目录中生成一个文件myid,内容为2.
3)在dn3 中创建目录:dataDir=/home/hadoop/opt/tmp/zookeeper,并在目录中生成一个文件myid,内容为3.
9 bin/zkServer.sh start 启动命令
bin/zkServer.sh status 查看状态