zookeeper集群一主两丛搭建

环境准备:zookeeper 安装包,linux 环境,包括关闭 linux 防火墙

1.添加hosts 文件地址

vim /etc/hosts

添加机器地址

并且其他三台机器的host文件都修改为这三个地址,保存退出

2.上传zookeeper 安装包服务器,按个人习惯,我是新建了一个zk用户,然后上传到服务器,上传后解压可以看到一个文件夹,如图所示,解压压缩包

tar -zxvf apache-zookeeper-3.6.1-bin

3.进入到文件夹下面修改conf文件

cp zoo_sample.cfg  zoo.cfg

复制一份文件为 zoo.cfg。修改文件,下面是我的配置文件,其实需要注意的是,日志输出的位置,可以自定义也可以默认,

然后就是,配置的zk地址

这里说一下

2888端口号是zookeeper服务之间通信的端口。

3888端口是zookeeper与其他应用程序通信的端口。

2181端口是zookeeper客户端请求接口。

这里配置的zk-node1 需要与你hosts 文件配置的ip映射关系对应,其他两个相同可以直接复制过去,保存后直接退出

#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=/home/zk/apache-zookeeper-3.6.1-bin/data
dataLogDir=/home/zk/apache-zookeeper-3.6.1-bin/dataLog
# 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

server.1=zk-node1:2888:3888
server.2=zk-node2:2888:3888
server.3=zk-node3:2888:3888

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
"zoo.cfg" 42L, 1309C                                                                                                          27,1          Top

4.创建上面日志输出的文件夹,如上,一个为data 一个为dataLog

mkdir data dataLog 

5.进入到data文件下

创建 myid文件,并且写入相应的id,如下图所示;

另外两台机器,分别为 2, 和 3,保存后直接退出

4.启动

./zkServer.sh start 

5.查看zk状态

第二台机器:

第三台机器:

一主两丛

总结一下:

搭建的不走其实和简单,第一步修改映射IP地址,第二步上传下载好的安装包,第三步修改配置文件,添加映射地址

第四步添加myid文件添加id,第五步启动zk完成搭建

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值