一. 服务器规划

主机

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 /

  

最新文章

  1. Bzoj3450 Tyvj1952 Easy
  2. Codeforces713C Sonya and Problem Wihtout a Legend(DP)
  3. 关于Html与css的一些解释
  4. [整理]详记被忽略的Get与Post
  5. 嵌入式Linux应用程序开发详解------(创建守护进程)
  6. Android屏蔽返回键
  7. 2015-11-04 asp.net 弹出式日历控件 选择日期 Calendar控件
  8. 【Unity3D】场景转换与退出
  9. 转:理解 PHP 中的 Streams
  10. js模块加载之AMD和CMD
  11. Jni中C++和Java的参数传递(转)
  12. K:图相关的最小生成树(MST)
  13. android获取string.xml的值
  14. WEB学习笔记2-结构组织和文件命名
  15. Comment类型
  16. Tcp超时修改
  17. Python 爬虫实例(4)—— 爬取网易新闻
  18. Objective-C中的meta-class
  19. 深度优先搜索(DFS) — 20180926
  20. $("body").animate({"scrollTop":top})无效的问题

热门文章

  1. windows获取高精度时间戳 精度100ns
  2. 渗透:wesside-ng
  3. 167. Two Sum II - Input array is sorted - LeetCode
  4. DevOps之敏捷开发
  5. 记一次 JDK SPI 配置不生效的问题 → 这么简单都不会,还是回家养猪吧
  6. 从单例谈double-check必要性,多种单例各取所需
  7. CabloyJS自带工作流引擎的文档清单
  8. Bean Validator
  9. 【C++函数题目】重载完成Compare函数
  10. 浅析Kubernetes架构之workqueue