zookeeper3.4.13安装

zookeeper安装

  • 安装步骤
    • 解压安装包
  • 创建data和logs目录
  • 新建zoo.cfg
    • 复制zookeeper主目录到其余两节点
    • 设置myid
  • 三节点启动zookeeper
    • 查看三节点状态

安装步骤

本文是针对Zookeeper3.4.13的3节点hadoop集群安装!
注意:必须把zookeeper安装在奇数个节点上,具体原因自行百度!
下载链接:http://mirrors.shu.edu.cn/apache/

解压安装包

[hadoop@master ~]$ tar -zxvf zookeeper-3.4.13.tar.gz

创建data和logs目录

在主目录下创建data和logs两个目录用于存储数据和日志

[hadoop@master ~]$ cd zookeeper-3.4.13/
[hadoop@master zookeeper-3.4.13]$ mkdir -p data logs

新建zoo.cfg

在conf目录下新建zoo.cfg,写入以下内容并保存

[hadoop@master ~]$ vi /home/hadoop/zookeeper-3.4.13/conf/zoo.cfg
tickTime=2000
dataDir=/home/hadoop/zookeeper-3.4.13/data
dataLogDir=/home/hadoop/zookeeper-3.4.13/logs
clientPort=2181
initLimit=5
syncLimit=2
server.1=169.254.1.100:2888:3888
server.2=169.254.1.101:2888:3888
server.3=169.254.1.102:2888:3888

2888端口号是zookeeper服务之间通信的端口,而3888是zookeeper与其他应用程序通信的端口。

复制zookeeper主目录到其余两节点

[hadoop@master ~]$ scp -r /home/hadoop/zookeeper-3.4.13/ 169.254.1.101:/home/hadoop/
[hadoop@master ~]$ scp -r /home/hadoop/zookeeper-3.4.13/ 169.254.1.102:/home/hadoop/

设置myid

在节点1上设置myid为1,节点2上设置myid为2,节点3上设置myid为3

[hadoop@master ~]$ vi /home/hadoop/zookeeper-3.4.13/data/myid
1
[slave01@master ~]$ vi /home/hadoop/zookeeper-3.4.13/data/myid
2
[slave02@master ~]$ vi /home/hadoop/zookeeper-3.4.13/data/myid
3

三节点启动zookeeper

进入bin目录启动zookeeper

[hadoop@master ~]$ cd zookeeper-3.4.13/bin/
[hadoop@master bin]$ ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.13/bin/…/conf/zoo.cfg
Starting zookeeper … STARTED

[hadoop@slave01 ~]$ cd zookeeper-3.4.13/bin/
[hadoop@slave01 bin]$ ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.13/bin/…/conf/zoo.cfg
Starting zookeeper … STARTED

[hadoop@slave02 ~]$ cd zookeeper-3.4.13/bin/
[hadoop@slave02 bin]$ ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.13/bin/…/conf/zoo.cfg
Starting zookeeper … STARTED

查看三节点状态

[hadoop@master bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.13/bin/…/conf/zoo.cfg
Mode: follower

[hadoop@slave01 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.13/bin/…/conf/zoo.cfg
Mode: follower

[hadoop@slave02 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/hadoop/zookeeper-3.4.13/bin/…/conf/zoo.cfg
Mode: leader

可以看出,目前slave02(169.254.1.102)目前是选出的leader节点
其他命令:

./zkServer.sh start # 启动
./zkServer.sh stop # 停止
./zkServer.sh restart # 重启
./zkServer.sh status # 查看节点状态及集群角色

你可能感兴趣的:(大数据)