# Zookeeper集群

作者:Odboy (opens new window)

本站地址:https://blog.odboy.cn (opens new window)

# 关键字说明

  • 绿色字体代表已完成
  • 红色字体代表待完成

# 实验明细

  • 配置
  • 运行
  • 集成

# docker-compose.yaml

# 可参考:https://hub.docker.com/_/zookeeper
version: '3'
services:
  zoo1:
    image: registry.cn-shanghai.aliyuncs.com/odboy/ops:zookeeper-3.8.4
    restart: unless-stopped
    hostname: zoo1
    volumes:
      - "./zookeeper-node_1/data:/data" # 数据
      - "./zookeeper-node_1/datalog:/datalog" # 事务日志
      - "./zookeeper-node_1/logs:/logs" # 普通日志
    ports:
      - "12181:2181"
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    privileged: true
  zoo2:
    image: registry.cn-shanghai.aliyuncs.com/odboy/ops:zookeeper-3.8.4
    restart: unless-stopped
    hostname: zoo2
    volumes:
      - "./zookeeper-node_2/data:/data"
      - "./zookeeper-node_2/datalog:/datalog"
      - "./zookeeper-node_2/logs:/logs"
    ports:
      - "12182:2181"
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    privileged: true
  zoo3:
    image: registry.cn-shanghai.aliyuncs.com/odboy/ops:zookeeper-3.8.4
    restart: unless-stopped
    hostname: zoo3
    volumes:
      - "./zookeeper-node_3/data:/data"
      - "./zookeeper-node_3/datalog:/datalog"
      - "./zookeeper-node_3/logs:/logs"
    ports:
      - "12183:2181"
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    privileged: true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

# 环境变量

名称 默认值 描述
ZOO_TICK_TIME Defaults to 2000. ZooKeeper's tickTime The length of a single tick, which is the basic time unit used by ZooKeeper, as measured in milliseconds. It is used to regulate heartbeats, and timeouts. For example, the minimum session timeout will be two ticks
ZOO_INIT_LIMIT Defaults to 5. ZooKeeper's initLimit Amount of time, in ticks (see tickTime), to allow followers to connect and sync to a leader. Increased this value as needed, if the amount of data managed by ZooKeeper is large.
ZOO_SYNC_LIMIT Defaults to 2. ZooKeeper's syncLimit Amount of time, in ticks (see tickTime), to allow followers to sync with ZooKeeper. If followers fall too far behind a leader, they will be dropped.
ZOO_MAX_CLIENT_CNXNS Defaults to 60. ZooKeeper's maxClientCnxns Limits the number of concurrent connections (at the socket level) that a single client, identified by IP address, may make to a single member of the ZooKeeper ensemble.
ZOO_STANDALONE_ENABLED Defaults to true. Zookeeper's standaloneEnabled Prior to 3.5.0, one could run ZooKeeper in Standalone mode or in a Distributed mode. These are separate implementation stacks, and switching between them during run time is not possible. By default (for backward compatibility) standaloneEnabled is set to true. The consequence of using this default is that if started with a single server the ensemble will not be allowed to grow, and if started with more than one server it will not be allowed to shrink to contain fewer than two participants.
ZOO_ADMINSERVER_ENABLED Defaults to true. Zookeeper's admin.enableServer The AdminServer is an embedded Jetty server that provides an HTTP interface to the four letter word commands. By default, the server is started on port 8080, and commands are issued by going to the URL "/commands/[command name]", e.g., http://localhost:8080/commands/stat
ZOO_AUTOPURGE_PURGEINTERVAL Defaults to 0. Zookeeper's autoPurge.purgeInterval The time interval in hours for which the purge task has to be triggered. Set to a positive integer (1 and above) to enable the auto purging. Defaults to 0.
ZOO_AUTOPURGE_SNAPRETAINCOUNT Defaults to 3. Zookeeper's autoPurge.snapRetainCount When enabled, ZooKeeper auto purge feature retains the autopurge.snapRetainCount most recent snapshots and the corresponding transaction logs in the dataDir and dataLogDir respectively and deletes the rest. Defaults to 3. Minimum value is 3.
ZOO_4LW_COMMANDS_WHITELIST Defaults to srvr. Zookeeper's 4lw.commands.whitelist A list of comma separated Four Letter Words commands that user wants to use. A valid Four Letter Words command must be put in this list else ZooKeeper server will not enable the command. By default the whitelist only contains "srvr" command which zkServer.sh uses. The rest of four letter word commands are disabled by default.
最近更新: 2024-10-11
2017 - 武林秘籍   |