zookeeper安装运行(docker)

拉取镜像
docker pull zookeeper:latest

获取镜像基本信息
docker inspect zookeeper

mkdir /opt/zookeeper -p

vim /opt/zookeeper/Dockerfile

FROM alpine
FROM zookeeper:latest
EXPOSE 2181
EXPOSE 2888
EXPOSE 3888
EXPOSE 8080

单机
vim /opt/zookeeper/conf/zoo.cfg

dataDir=/data
dataLogDir=/datalog
clientPort=2181
4lw.commands.whitelist=*
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
standaloneEnabled=true
admin.enableServer=true

vim /opt/zookeeper/docker-compose.yml

version: ‘3.6‘
services:
  zookeeper:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
      - "28080:8080"
    volumes:
      - "./data:/data"
      - "./datalog:/datalog"
      - "./logs:/logs"

伪集群

集群模式必须设置clientPort的值

mkdir vim /opt/zookeeper/node1/conf -p
vim /opt/zookeeper/node1/conf/zoo.cfg

dataDir=/data
dataLogDir=/datalog
clientPort=2181
4lw.commands.whitelist=*
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
admin.enableServer=true
server.1=192.168.1.101:2881:3881
server.2=192.168.1.101:2882:3882
server.3=192.168.1.101:2883:3883

mkdir vim /opt/zookeeper/node2/conf -p
vim /opt/zookeeper/node2/conf/zoo.cfg

dataDir=/data
dataLogDir=/datalog
clientPort=2182
4lw.commands.whitelist=*
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
admin.enableServer=true
server.1=192.168.1.101:2881:3881
server.2=192.168.1.101:2882:3882
server.3=192.168.1.101:2883:3883

mkdir vim /opt/zookeeper/node3/conf -p
vim /opt/zookeeper/node3/conf/zoo.cfg

dataDir=/data
dataLogDir=/datalog
clientPort=2183
4lw.commands.whitelist=*
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
admin.enableServer=true
server.1=192.168.1.101:2881:3881
server.2=192.168.1.101:2882:3882
server.3=192.168.1.101:2883:3883

vim /opt/zookeeper/docker-compose.yml

version: ‘3.6‘
services:
  zookeeper1:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper1
    network_mode: "host"
    ports:
      - "2181:2181"
      - "2881:2881"
      - "3881:3881"
      - "8081:8080"
    user: root
    privileged: true
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=192.168.1.101:2881:3881 server.2=192.168.1.101:2882:3882 server.3=192.168.1.101:2883:3883
    volumes:
      - "./node1/conf/zoo.cfg:/conf/zoo.cfg"
      - "./node1/data/:/data/"
      - "./node1/datalog/:/datalog/"
      - "./node1/logs/:/logs/"
  zookeeper2:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper2
    network_mode: "host"
    ports:
      - "2182:2182"
      - "2882:2882"
      - "3882:3882"
      - "8082:8080"
    user: root
    privileged: true
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=192.168.1.101:2881:3881 server.2=192.168.1.101:2882:3882 server.3=192.168.1.101:2883:3883
    volumes:
      - "./node2/conf/zoo.cfg:/conf/zoo.cfg"
      - "./node2/data/:/data/"
      - "./node2/datalog/:/datalog/"
      - "./node2/logs/:/logs/"
  zookeeper3:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper3
    network_mode: "host"
    ports:
      - "2183:2183"
      - "2883:2883"
      - "3883:3883"
      - "8083:8080"
    user: root
    privileged: true
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=192.168.1.101:2881:3881 server.2=192.168.1.101:2882:3882 server.3=192.168.1.101:2883:3883
    volumes:
      - "./node3/conf/zoo.cfg:/conf/zoo.cfg"
      - "./node3/data/:/data/"
      - "./node3/datalog/:/datalog/"
      - "./node3/logs/:/logs/"

集群

集群模式必须设置clientPort的值

服务器1、2、3:

vim /opt/zookeeper/conf/zoo.cfg

dataDir=/data
dataLogDir=/datalog
clientPort=2181
4lw.commands.whitelist=*
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
admin.enableServer=true
server.1=192.168.1.101:2888:3888
server.2=192.168.1.102:2888:3888
server.3=192.168.1.103:2888:3888

服务器1:

vim /opt/zookeeper/docker-compose.yml

version: ‘3.6‘
services:
  zookeeper:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper
    network_mode: "host"
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
      - "28080:8080"
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=192.168.1.101:2888:3888 server.2=192.168.1.102:2888:3888 server.3=192.168.1.103:2888:3888
    volumes:
      - "./conf/zoo.cfg:/conf/zoo.cfg"
      - "./data:/data"
      - "./datalog:/datalog"
      - "./logs:/logs"

服务器2:

vim /opt/zookeeper/docker-compose.yml

version: ‘3.6‘
services:
  zookeeper:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper
    network_mode: "host"
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
      - "28080:8080"
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=192.168.1.101:2888:3888 server.2=192.168.1.102:2888:3888 server.3=192.168.1.103:2888:3888
    volumes:
      - "./conf/zoo.cfg:/conf/zoo.cfg"
      - "./data:/data"
      - "./datalog:/datalog"
      - "./logs:/logs"

服务器3:

vim /opt/zookeeper/docker-compose.yml

version: ‘3.6‘
services:
  zookeeper:
    image: zookeeper:latest
    restart: always
    container_name: zookeeper
    network_mode: "host"
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
      - "28080:8080"
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=192.168.1.101:2888:3888 server.2=192.168.1.102:2888:3888 server.3=192.168.1.103:2888:3888
    volumes:
      - "./conf/zoo.cfg:/conf/zoo.cfg"
      - "./data:/data"
      - "./datalog:/datalog"
      - "./logs:/logs"

ZOO_SERVERS中的zookeeper为容器名

启动

cd /opt/zookeeper
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart

查看日志

docker logs --tail="500" zookeeper

备份配置文件

docker cp zookeeper:/conf/zoo.cfg /opt/zookeeper/conf/zoo_bak.cfg

进入容器

docker exec -it zookeeper /bin/bash

检查容器状态

docker exec -it zookeeper1 /bin/bash ./bin/zkServer.sh status

原文地址:https://www.cnblogs.com/wintersoft/p/11128484.html

时间: 2024-11-04 15:16:41

zookeeper安装运行(docker)的相关文章

kafka安装运行(docker)

zookeeper参照https://www.cnblogs.com/wintersoft/p/11128484.html mkdir /opt/kafka -pvim /opt/kafka/Dockerfile FROM wurstmeister/kafka:latest EXPOSE 9092 vim /opt/kafka/docker-compose.yml version: '2' services: kafka: image: v-kafka container_name: kafka

在阿里云CentOS 6.5 安装、运行Docker容器的方法与步骤

ssh登陆阿里云ssh [email protected] uname -a 查看linux内核版本,因为Docker推荐使用3.8以上内核,如果版本低可能会不稳定,因此需要选用yum方式升级内核. 导入 KEY ,安装软件源.在 YUM 的 ELRepo 源中,有mainline(3.13.1).long-term(3.10.28)这 2 个内核版本,考虑到 long-term 更稳定,会长期更新,所以选择这个版本.点击查看方法来源 导入public key:rpm --import http

windows使用docker运行mysql等工具(二)安装运行mysql

今天接着上一篇的内容继续来学习安装运行mysql.建议先阅读第一篇:windows安装docker 一 查看mysql版本 如果想知道mysql镜像具体有哪几个版本,需要去docker hub查看. 地址如下: https://hub.docker.com/r/library/ 二 拉取mysql镜像 命令如下: docker pull 镜像名称:版本号 打开命令窗口输入 docker pull mysql:8.0 等待几分钟就完成了,然后输入以下命令查看镜像 docker images 三 启

Docker 安装运行MySQL

1.镜像主页 https://hub.docker.com/_/mysql 2.拉取5.7版本 docker pull mysql:5.7 3.或者拉取最新8.x版本 docker pull mysql:latest 4.配置密码,后台运行 docker run --name develop-mysql -e MYSQL_ROOT_PASSWORD=xxxxxxxxxxx -p 3306:3306 -d mysql:5.7 切记配置端口号 5.查看是否运行成功 原文地址:https://www.

docker云方案——搭建Mesos+Zookeeper+Marathon的Docker管理平台

服务器架构 机器信息: 这里部属的机器为3个Master控制节点,3个slave运行节点,其中: zookeeper.Mesos-master.marathon运行在Master端:Mesos-slave和docker运行在Slave端:需要修改zk的内容来保证slave能够被发现和管理 构建环境 配置mesos-master(3台master节点都要操作) # 关闭selinux [[email protected] ~]# sed -i '/SELINUX/s/enforcing/disab

在windows下运行docker的问题【Error getting IP address: ***】

环境配置系统:windows 10docker:Docker Toolbox https://www.docker.com/products/docker-toolbox 问题描述windows下安装完Docker Toolbox后运行Docker Quickstart Terminal可能会看到如下错误 Creating Machine default... Running pre-create checks... Creating machine... Error creating mach

Zookeeper安装

Zookeeper简介 zookeeper:动物园管理员 ■  曾经是Hadoop子项目,现为顶级项目 ■  zookeeper是协同服务 ■  zookeeper为分布式应用提供服务 ■ zookeeper支持Java和C语言 zookeeper服务基于内存,服务器之间相互感知,数据同步 v zookeeper为分布式应用提供的服务 ■ 配置维护 ■ 名字服务 ■ 分布式同步 ■ 组服务等 角色: leader-领导  集群中只能有一个 follower-追随者   集群中可以有多个 v Zo

01.ZooKeeper安装和介绍

1.ZooKeeper安装和启动 1.下载解压ZooKeeper ZooKeeper官方地址:http://zookeeper.apache.org/ 下载当前稳定版本:zookeeper-3.4.6.tar.gz 解压如下: [[email protected] ZooKeeper]$ tar -zxvf zookeeper-3.4.6 ...... [[email protected] ZooKeeper]$ ll total 17292 drwxr-xr-x. 10 lizhiwei li

ZooKeeper学习第二期--ZooKeeper安装配置

一.Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式. ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境:■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例:■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个"集合体"(ensemble) Zookeeper通过复制来实现高可用性,只要集合体中半数以上的机器处于可用状态,它就能够保证服务继续.为什么一定要超过半数呢?这