From 877bd70c891fb1e58307b47653df84026d363ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BD=90=E6=99=A8?= <1303445410@qq.com> Date: Tue, 27 Sep 2022 17:21:38 +0800 Subject: [PATCH] [bitnami/zookeeper] add zookeeper peerType,observer (#7065) add zookeeper peerType,observer Signed-off-by: bimoQi <1303445410@qq.com> Signed-off-by: bimoQi <1303445410@qq.com> --- .../opt/bitnami/scripts/libzookeeper.sh | 20 +++++++++++++++---- .../opt/bitnami/scripts/zookeeper-env.sh | 2 ++ .../opt/bitnami/scripts/libzookeeper.sh | 20 +++++++++++++++---- .../opt/bitnami/scripts/zookeeper-env.sh | 2 ++ .../opt/bitnami/scripts/libzookeeper.sh | 20 +++++++++++++++---- .../opt/bitnami/scripts/zookeeper-env.sh | 2 ++ bitnami/zookeeper/README.md | 3 +++ 7 files changed, 57 insertions(+), 12 deletions(-) diff --git a/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh b/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh index b64814da76d8..92d24f1e945b 100644 --- a/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh +++ b/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh @@ -106,12 +106,12 @@ zookeeper_validate() { read -r -a zookeeper_servers_list <<<"${ZOO_SERVERS//[;, ]/ }" for server in "${zookeeper_servers_list[@]}"; do if is_boolean_yes "$server_id_with_jumps"; then - if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+::[[:digit:]]+$"; then - print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port::id. Example: zookeeper:2888:3888::1" + if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+(:observer|:participant)?::[[:digit:]]+$"; then + print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port::id. Example: zookeeper:2888:3888::1 zookeeper:2888:3888:observer::1" fi else - if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+$"; then - print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port. Example: zookeeper:2888:3888" + if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+(:observer|:participant)?$"; then + print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port. Example: zookeeper:2888:3888 zookeeper:2888:3888:observer" fi fi done @@ -120,6 +120,13 @@ zookeeper_validate() { check_multi_value "ZOO_TLS_CLIENT_AUTH" "none want need" check_multi_value "ZOO_TLS_QUORUM_CLIENT_AUTH" "none want need" + # ZooKeeper server peerType validations + if [[ -n "$ZOO_PEER_TYPE" ]]; then + if [[ "$ZOO_PEER_TYPE" != "observer" ]] && [[ "$ZOO_PEER_TYPE" != "participant" ]]; then + print_validation_error "The ZOO_PEER_TYPE environment ${ZOO_PEER_TYPE} should be one of [observer/participant]" + fi + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -165,6 +172,11 @@ zookeeper_initialize() { else info "Deploying ZooKeeper with persisted data..." fi + + # ZooKeeper set server peerType + if [[ -n "$ZOO_PEER_TYPE" ]]; then + zookeeper_conf_set "$ZOO_CONF_FILE" peerType "$ZOO_PEER_TYPE" + fi } ######################## diff --git a/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh b/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh index 614ddfe3b410..ace2f3a87ba0 100644 --- a/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh +++ b/bitnami/zookeeper/3.6/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh @@ -28,6 +28,7 @@ zookeeper_env_vars=( ZOO_SERVERS ZOO_ENABLE_ADMIN_SERVER ZOO_ADMIN_SERVER_PORT_NUMBER + ZOO_PEER_TYPE ZOO_TICK_TIME ZOO_INIT_LIMIT ZOO_SYNC_LIMIT @@ -106,6 +107,7 @@ export ZOO_SERVER_ID="${ZOO_SERVER_ID:-1}" export ZOO_SERVERS="${ZOO_SERVERS:-}" export ZOO_ENABLE_ADMIN_SERVER="${ZOO_ENABLE_ADMIN_SERVER:-yes}" export ZOO_ADMIN_SERVER_PORT_NUMBER="${ZOO_ADMIN_SERVER_PORT_NUMBER:-8080}" +export ZOO_PEER_TYPE="${ZOO_PEER_TYPE:-}" # ZooKeeper settings export ZOO_TICK_TIME="${ZOO_TICK_TIME:-2000}" diff --git a/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh b/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh index b64814da76d8..92d24f1e945b 100644 --- a/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh +++ b/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh @@ -106,12 +106,12 @@ zookeeper_validate() { read -r -a zookeeper_servers_list <<<"${ZOO_SERVERS//[;, ]/ }" for server in "${zookeeper_servers_list[@]}"; do if is_boolean_yes "$server_id_with_jumps"; then - if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+::[[:digit:]]+$"; then - print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port::id. Example: zookeeper:2888:3888::1" + if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+(:observer|:participant)?::[[:digit:]]+$"; then + print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port::id. Example: zookeeper:2888:3888::1 zookeeper:2888:3888:observer::1" fi else - if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+$"; then - print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port. Example: zookeeper:2888:3888" + if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+(:observer|:participant)?$"; then + print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port. Example: zookeeper:2888:3888 zookeeper:2888:3888:observer" fi fi done @@ -120,6 +120,13 @@ zookeeper_validate() { check_multi_value "ZOO_TLS_CLIENT_AUTH" "none want need" check_multi_value "ZOO_TLS_QUORUM_CLIENT_AUTH" "none want need" + # ZooKeeper server peerType validations + if [[ -n "$ZOO_PEER_TYPE" ]]; then + if [[ "$ZOO_PEER_TYPE" != "observer" ]] && [[ "$ZOO_PEER_TYPE" != "participant" ]]; then + print_validation_error "The ZOO_PEER_TYPE environment ${ZOO_PEER_TYPE} should be one of [observer/participant]" + fi + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -165,6 +172,11 @@ zookeeper_initialize() { else info "Deploying ZooKeeper with persisted data..." fi + + # ZooKeeper set server peerType + if [[ -n "$ZOO_PEER_TYPE" ]]; then + zookeeper_conf_set "$ZOO_CONF_FILE" peerType "$ZOO_PEER_TYPE" + fi } ######################## diff --git a/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh b/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh index 614ddfe3b410..ace2f3a87ba0 100644 --- a/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh +++ b/bitnami/zookeeper/3.7/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh @@ -28,6 +28,7 @@ zookeeper_env_vars=( ZOO_SERVERS ZOO_ENABLE_ADMIN_SERVER ZOO_ADMIN_SERVER_PORT_NUMBER + ZOO_PEER_TYPE ZOO_TICK_TIME ZOO_INIT_LIMIT ZOO_SYNC_LIMIT @@ -106,6 +107,7 @@ export ZOO_SERVER_ID="${ZOO_SERVER_ID:-1}" export ZOO_SERVERS="${ZOO_SERVERS:-}" export ZOO_ENABLE_ADMIN_SERVER="${ZOO_ENABLE_ADMIN_SERVER:-yes}" export ZOO_ADMIN_SERVER_PORT_NUMBER="${ZOO_ADMIN_SERVER_PORT_NUMBER:-8080}" +export ZOO_PEER_TYPE="${ZOO_PEER_TYPE:-}" # ZooKeeper settings export ZOO_TICK_TIME="${ZOO_TICK_TIME:-2000}" diff --git a/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh b/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh index b64814da76d8..92d24f1e945b 100644 --- a/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh +++ b/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh @@ -106,12 +106,12 @@ zookeeper_validate() { read -r -a zookeeper_servers_list <<<"${ZOO_SERVERS//[;, ]/ }" for server in "${zookeeper_servers_list[@]}"; do if is_boolean_yes "$server_id_with_jumps"; then - if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+::[[:digit:]]+$"; then - print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port::id. Example: zookeeper:2888:3888::1" + if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+(:observer|:participant)?::[[:digit:]]+$"; then + print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port::id. Example: zookeeper:2888:3888::1 zookeeper:2888:3888:observer::1" fi else - if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+$"; then - print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port. Example: zookeeper:2888:3888" + if ! echo "$server" | grep -q -E "^[^[:space:]]+:[[:digit:]]+:[[:digit:]]+(:observer|:participant)?$"; then + print_validation_error "Zookeeper server ${server} should follow the next syntax: host:port:port. Example: zookeeper:2888:3888 zookeeper:2888:3888:observer" fi fi done @@ -120,6 +120,13 @@ zookeeper_validate() { check_multi_value "ZOO_TLS_CLIENT_AUTH" "none want need" check_multi_value "ZOO_TLS_QUORUM_CLIENT_AUTH" "none want need" + # ZooKeeper server peerType validations + if [[ -n "$ZOO_PEER_TYPE" ]]; then + if [[ "$ZOO_PEER_TYPE" != "observer" ]] && [[ "$ZOO_PEER_TYPE" != "participant" ]]; then + print_validation_error "The ZOO_PEER_TYPE environment ${ZOO_PEER_TYPE} should be one of [observer/participant]" + fi + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -165,6 +172,11 @@ zookeeper_initialize() { else info "Deploying ZooKeeper with persisted data..." fi + + # ZooKeeper set server peerType + if [[ -n "$ZOO_PEER_TYPE" ]]; then + zookeeper_conf_set "$ZOO_CONF_FILE" peerType "$ZOO_PEER_TYPE" + fi } ######################## diff --git a/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh b/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh index 614ddfe3b410..ace2f3a87ba0 100644 --- a/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh +++ b/bitnami/zookeeper/3.8/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh @@ -28,6 +28,7 @@ zookeeper_env_vars=( ZOO_SERVERS ZOO_ENABLE_ADMIN_SERVER ZOO_ADMIN_SERVER_PORT_NUMBER + ZOO_PEER_TYPE ZOO_TICK_TIME ZOO_INIT_LIMIT ZOO_SYNC_LIMIT @@ -106,6 +107,7 @@ export ZOO_SERVER_ID="${ZOO_SERVER_ID:-1}" export ZOO_SERVERS="${ZOO_SERVERS:-}" export ZOO_ENABLE_ADMIN_SERVER="${ZOO_ENABLE_ADMIN_SERVER:-yes}" export ZOO_ADMIN_SERVER_PORT_NUMBER="${ZOO_ADMIN_SERVER_PORT_NUMBER:-8080}" +export ZOO_PEER_TYPE="${ZOO_PEER_TYPE:-}" # ZooKeeper settings export ZOO_TICK_TIME="${ZOO_TICK_TIME:-2000}" diff --git a/bitnami/zookeeper/README.md b/bitnami/zookeeper/README.md index 9840a6cd36e2..4b40d0c4c950 100644 --- a/bitnami/zookeeper/README.md +++ b/bitnami/zookeeper/README.md @@ -222,6 +222,7 @@ The configuration can easily be setup with the Bitnami Apache ZooKeeper Docker i - `ZOO_TLS_QUORUM_CLIENT_AUTH`: Specifies options to authenticate TLS connections from clients. Available values are: `none`, `want`, `need`. Default: **need** - `ZOO_ENABLE_ADMIN_SERVER`: Enable [admin server](https://zookeeper.apache.org/doc/r3.5.7/zookeeperAdmin.html#sc_adminserver). Default: **yes** - `ZOO_ADMIN_SERVER_PORT_NUMBER`: [Admin server](https://zookeeper.apache.org/doc/r3.5.7/zookeeperAdmin.html#sc_adminserver) port. Default: **8080** + - `ZOO_PEER_TYPE`: Zookeeper Node [Peer type](https://zookeeper.apache.org/doc/r3.6.3/zookeeperObservers.html). Default: No Defaults ```console $ docker run --name zookeeper -e ZOO_SERVER_ID=1 bitnami/zookeeper:latest @@ -331,6 +332,8 @@ A Apache ZooKeeper (https://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html) - `ZOO_SERVERS`: Comma, space or semi-colon separated list of servers.This can be done with or without specifying the ID of the server in the ensemble. No defaults. Examples: - without Server ID - zoo1:2888:3888,zoo2:2888:3888 - with Server ID - zoo1:2888:3888::1,zoo2:2888:3888::2 + - without Server ID And Observers - zoo1:2888:3888,zoo2:2888:3888:observer + - with Server ID And Observers - zoo1:2888:3888::1,zoo2:2888:3888:observer::2 For reliable Apache ZooKeeper service, you should deploy Apache ZooKeeper in a cluster known as an ensemble. As long as a majority of the ensemble are up, the service will be available. Because Apache ZooKeeper requires a majority, it is best to use an odd number of machines. For example, with four machines Apache ZooKeeper can only handle the failure of a single machine; if two machines fail, the remaining two machines do not constitute a majority. However, with five machines Apache ZooKeeper can handle the failure of two machines.