您现在的位置是:首页 > 技术人生 > 服务器相关服务器相关

Ubuntu 20.04 安装zookeeper 3.5.9 集群

高晓波2021-09-22【服务器相关】人已围观

简介安装zookeeper的三台机器分别为vm-10、vm-11、vm-12,已设置相应host文件。

1、下载zookeeper 3.5.9cd /usr/local/src/sudo wget https://archive.apache.org/dist/zookeepe

安装zookeeper的三台机器分别为vm-10、vm-11、vm-12,已设置相应host文件。

1、下载zookeeper 3.5.9
cd /usr/local/src/
sudo wget https://archive.apache.org/dist/zookeeper/zookeeper-3.5.9/apache-zookeeper-3.5.9-bin.tar.gz

2、解压
sudo tar -zxvf /usr/local/src/apache-zookeeper-3.5.9-bin.tar.gz -C /usr/local/
创建存储、日志文件夹
mkdir /usr/local/src/apache-zookeeper-3.5.9-bin/data
mkdir /usr/local/src/apache-zookeeper-3.5.9-bin/logs


3、设置配置文件
(1)复制一份默认配置,改为zoo.cfg
cp /usr/local/apache-zookeeper-3.5.9-bin/conf/zoo_sample.cfg /usr/local/apache-zookeeper-3.5.9-bin/conf/zoo.cfg

(2)修改zoo.cfg
vi /usr/local/apache-zookeeper-3.5.9-bin/conf/zoo.cfg
修改、添加配置
dataDir=/usr/local/apache-zookeeper-3.5.9-bin/data
dataLogDir=/usr/local/apache-zookeeper-3.5.9-bin/logs
#格式server.id,2888端口:集群内机器通讯使用(Leader监听此端口),3888端口:选举leader使用
server.1=vm-10:2888:3888
server.2=vm-11:2888:3888
server.3=vm-12:2888:3888
4、data目录下创建myid文件,myid文件中内容为当前server的id
touch /usr/local/src/apache-zookeeper-3.5.9-bin/data/myid
echo 1 > /usr/local/src/apache-zookeeper-3.5.9-bin/data/myid


5、每台机器逐一启动zookeeper
/usr/local/src/apache-zookeeper-3.5.9-bin/bin/zkServer.sh start

查看状态
/usr/local/apache-zookeeper-3.5.9-bin/bin/zkServer.sh status
vm-10:
hadoop@vm-10:~$ /usr/local/apache-zookeeper-3.5.9-bin/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.9-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
vm-11:
hadoop@vm-11:~$ /usr/local/apache-zookeeper-3.5.9-bin/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.9-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader
vm-12:
hadoop@vm-12:~$ /usr/local/apache-zookeeper-3.5.9-bin/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.9-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower

可以看到vm-11这台主机被选举为leader,其他两台为follower。

 

Tags:zookeeper

很赞哦! ()

文章评论