2. zk集群部署

简介

上一篇文章我们已经把环境准备好了,jdk也配置好了,下面我们开始把zk部署起来

hadoop环境准备

创建zk用户

useradd zk -d /home/zk
echo "1q1w1e1r"  | passwd --stdin zk

上传zk包

拷贝zk包到/home/zk目录,这里的zk版本为 3.6.3

scp zk.tar.gz zk@hadoop01:/home/zk
scp zk.tar.gz zk@hadoop02:/home/zk
scp zk.tar.gz zk@hadoop03:/home/zk

解压

tar -zxvf zk.tar.gz

创建文件夹

mkdir data logs

配置文件

修改zk配置文件

cd /home/zk/conf

vi zoo.cfg

配置如下

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/zk/data
dataLogDir=/home/zk/data
clientPort=2181
server.1=hadoop01:2888:3888
server.2=hadoop02:2888:3888
server.3=hadoop03:2888:3888
skipACL=yes

每台机器创建myid文件,分别写入 1,2,3

cd /home/zk/data

vi myid

启动zk

/home/zk/bin/zkServer.sh start

查看集群状态

# hadoop01
[zk@hadoop01 ~]$/home/zk/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/zk/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower

# hadoop02
[zk@hadoop02 ~]$ /home/zk/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/zk/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader

# hadoop03
[zk@hadoop03 ~]$ /home/zk/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/zk/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower

测试

在hadoop01进入客户端交互界面

/home/zk/bin/zkCli.sh -server hadoop01:2181

创建一个文件夹

[zk: hadoop01:2181(CONNECTED) 1] create /test
Created /test

进入hadoop02查看

/home/zk/bin/zkCli.sh -server hadoop02:2181
[zk: hadoop02:2181(CONNECTED) 0] ls /
[test, zookeeper]

总结

到此zk集群就已经搭建完毕,下节开始搭建hdfs


欢迎关注,学习不迷路!

你可能感兴趣的:(hadoop,hadoop,zookeeper)