当前位置: 代码网 > 服务器>服务器>云虚拟主机 > Docker ZooKeeper3.4.10集群安装配置过程

Docker ZooKeeper3.4.10集群安装配置过程

2024年05月22日 云虚拟主机 我要评论
一. 服务器规划主机ip端口备注b-mid-24172.16.0.242181, 2888, 38882181:对cline端提供服务3888:选举leader使用2888:集群内机器通讯使用(lea

一. 服务器规划

主机

ip

端口

备注

b-mid-24

172.16.0.24

2181, 2888, 3888

2181:对cline端提供服务

3888:选举leader使用

2888:集群内机器通讯使用(leader监听此端口)

b-mid-25

172.16.0.25

2181, 2888, 3888

b-mid-26

172.16.0.26

2181, 2888, 3888

二. 集群部署

注:以下步骤需要分别在三台主机操作

1. 配置

1.1 创建宿主机映射目录

mkdir /data/docker/zookeeper-home/{conf,data,logs,datalog} -p

1.2. 创建配置文件(3台zk节点配置文件一样)

vi /data/docker/zookeeper-home/conf/zoo.cfg :

# 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=/data
datalogdir=/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.24=172.16.0.24:2888:3888
server.25=172.16.0.25:2888:3888
server.26=172.16.0.26:2888:3888

1.3. 配置zookeeper主机id,每个机器id不能相同,需要对应配置文件server后面的值:

echo "24" > /data/docker/zookeeper-home/data/myid
echo "25" > /data/docker/zookeeper-home/data/myid
echo "26" > /data/docker/zookeeper-home/data/myid

1.4 修改 zookeeper-home 目录及子目录所属用户为 yunwei :

chown -r yunwei:yunwei /data/docker/zookeeper-home

2. 启动

2.1 开启端口

firewall-cmd --permanent --add-port=2181/tcp
firewall-cmd --permanent --add-port=2888/tcp
firewall-cmd --permanent --add-port=3888/tcp
firewall-cmd --reload
firewall-cmd --list-all

2.2 启动服务(用 yunwei 账号执行)

拉取镜像:

docker pull zookeeper:3.4.10

启动服务:

docker run -d \
--name zookeeper \
--network host \
--restart=unless-stopped \
-v /data/docker/zookeeper-home/data:/data \
-v /data/docker/zookeeper-home/conf:/conf \
-v /data/docker/zookeeper-home/datalog:/datalog \
-v /data/docker/zookeeper-home/logs:/logs \
-v /etc/localtime:/etc/localtime \
zookeeper:3.4.10

2.3 查看服务器状态

docker exec -it zookeeper bash
zkserver.sh status
echo mntr | nc 127.0.0.1 2181
zkcli.sh -server 127.0.0.1:2181
ls /

到此这篇关于docker zookeeper3.4.10集群安装配置过程的文章就介绍到这了,更多相关docker zookeeper集群内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com