Zookeepr漫衍式集群搭建

不要下载源码的问下 下载bin的文件  源码有时候会找不到类

apache-zookeeper-3.6.0-bin.tar.gz

1.1 集群筹划

在linux1,linux2和linux3三个节点上陈设Zookeeper,三个节点都已安装jdk。

设置好ssh key免密登录

1.首先设置hosts文件

vim /etc/hosts

192.168.10.11 linux1 192.168.10.12 linux2 192.168.10.13 linux3

2.生成ssh rsa 

第一台呆板

[Hadoop@linux1 conf]$ ssh-keygen -t rsa

[hadoop@linux1 conf]$ ssh-copy-id linux2

[hadoop@linux1 conf]$ ssh-copy-id linux3

 

第二台呆板

 

[hadoop@linux2 conf]$ ssh-keygen -t rsa

[hadoop@linux2 conf]$ ssh-copy-id linux1

[hadoop@linux2 conf]$ ssh-copy-id linux3

 

第三台呆板

 

[hadoop@linux3 conf]$ ssh-keygen -t rsa

[hadoop@linux3 conf]$ ssh-copy-id linux1

[hadoop@linux3 conf]$ ssh-copy-id linux2

1.2 解压安装

tar -zxvf apache-zookeeper-3.6.0-bin.tar.gz  -C /opt/module/<br>mv /opt/module/apache-zookeeper-3.6.0-bin /opt/module/apache-zookeeper-3.6.0

在/opt/module/apache-zookeeper-3.6.0/这个目次下建设Data  

[hadoop@linux1 apache-zookeeper-3.6.0]$ mkdir Data

修改文件名称  

mv zoo_sample.cfg zoo.cfg

1.3 设置zoo.cfg文件

详细设置,修改dateDir,添加日志存放目次

ataDir=/opt/module/apache-zookeeper-3.6.0/Data

dataLogDir=/opt/module/apache-zookeeper-3.6.0/Data/logs

 在末端增加

server.1=linux1:2888:3888 server.2=linux2:2888:3888 server.3=linux3:2888:3888

1.4 集群设置

(1)在/opt/module/apache-zookeeper-3.6.0/Data目次下建设一个myid的文件

[hadoop@linux1 Data]$ touch myid

(2)编辑myid文件, 在文件中添加与server对应的编号:如 1   

[hadoop@linux1 Data]$ vi myid

Zookeepr分布式集群搭建

wq生存退出

[hadoop@linux1 module]$ scp -r apache-zookeeper-3.6.0/ hadoop@linux2:/opt/module/ [hadoop@linux1 module]$ scp -r apache-zookeeper-3.6.0/ hadoop@linux3:/opt/module/

别离配置linux1和linux2的myid文件

[hadoop@linux1 module]$ ssh linux2 Last login: Tue Mar 24 11:32:24 2020 from linux1 [hadoop@linux2 ~]$ echo 2 > /opt/module/apache-zookeeper-3.6.0/Data/myid [hadoop@linux2 ~]$ cat /opt/module/apache-zookeeper-3.6.0/Data/myid 2 [hadoop@linux2 ~]$ exit logout Connection to linux2 closed. [hadoop@linux1 module]$

 

 

[hadoop@linux1 module]$ ssh linux3 Last login: Mon Mar 23 14:15:50 2020 [hadoop@linux3 ~]$ echo 3 > /opt/module/apache-zookeeper-3.6.0/Data/myid [hadoop@linux3 ~]$ cat /opt/module/apache-zookeeper-3.6.0/Data/myid 3 [hadoop@linux3 ~]$ exit logout Connection to linux3 closed. [hadoop@linux1 module]$

1.5 启动集群

[hadoop@linux1 apache-zookeeper-3.6.0]$ ./bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /opt/module/apache-zookeeper-3.6.0/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [hadoop@linux1 apache-zookeeper-3.6.0]$ ssh linux2 Last login: Tue Mar 24 11:33:58 2020 from linux1 [hadoop@linux2 ~]$ /opt/module/apache-zookeeper-3.6.0/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /opt/module/apache-zookeeper-3.6.0/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [hadoop@linux2 ~]$ exit logout Connection to linux2 closed. [hadoop@linux1 apache-zookeeper-3.6.0]$ ssh linux 2 ssh: Could not resolve hostname linux: Name or service not known [hadoop@linux1 apache-zookeeper-3.6.0]$ ssh linux3 Last login: Tue Mar 24 11:35:38 2020 from linux1 [hadoop@linux3 ~]$ /opt/module/apache-zookeeper-3.6.0/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /opt/module/apache-zookeeper-3.6.0/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [hadoop@linux3 ~]$ exit logout Connection to linux3 closed. [hadoop@linux1 apache-zookeeper-3.6.0]$

1.6 设置情况变量

vi /etc/profile

export ZOOKEEPER_HOME=/opt/module/apache-zookeeper-3.6.0 export PATH=$PATH:$ZOOKEEPER_HOME/bin

source /etc/profile

1.7zoo.cfg设置参数解读

Server.A=B:C:D。

A是一个数字,暗示这个是第几号处事器;

B是这个处事器的ip地点;

C是这个处事器与集群中的Leader处事器互换信息的端口;

D是万一集群中的Leader处事器挂了,需要一个端口来从头举办选举,选出一个新的Leader,而这个端口就是用来执行选举时处事器彼此通信的端口。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsddpf.html