diff --git a/3.4.13/deps/zookeeper-docker/Dockerfile b/3.4.13/deps/zookeeper-docker/Dockerfile deleted file mode 100644 index 7d79145..0000000 --- a/3.4.13/deps/zookeeper-docker/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM zookeeper:3.4.13 - -ENV ZOO_LOG_DIR=/logs - -RUN set -ex; \ - mkdir -p "$ZOO_LOG_DIR"; \ - chown "$ZOO_USER:$ZOO_USER" "$ZOO_LOG_DIR" - -VOLUME [ "$ZOO_LOG_DIR" ] diff --git a/3.4.13/deps/zookeeper-rest-docker/Dockerfile b/3.4.13/deps/zookeeper-rest-docker/Dockerfile deleted file mode 100644 index 0ff9bbe..0000000 --- a/3.4.13/deps/zookeeper-rest-docker/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM dockerhub.qingcloud.com/qingcloud/zookeeper:3.4.13 - -ENV ZOO_REST_HOME=/zookeeper-3.4.13/contrib/rest - -RUN set -ex; \ - mv $ZOO_REST_HOME/conf/* $ZOO_CONF_DIR; \ - mv zookeeper-*.jar $ZOO_REST_HOME - -EXPOSE 9998/tcp -VOLUME ["$ZOO_CONF_DIR", "$ZOO_LOG_DIR"] - -COPY bin/zkRest.sh $ZOO_REST_HOME -ENV PATH=$PATH:$ZOO_REST_HOME - -WORKDIR $ZOO_REST_HOME - -ENTRYPOINT ["zkRest.sh"] -CMD ["start-foreground"] diff --git a/3.4.13/deps/zookeeper-rest-docker/bin/zkRest.sh b/3.4.13/deps/zookeeper-rest-docker/bin/zkRest.sh deleted file mode 100755 index a2a7141..0000000 --- a/3.4.13/deps/zookeeper-rest-docker/bin/zkRest.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# If this scripted is run out of /usr/bin or some other system bin directory -# it should be linked to and not copied. Things like java jar files are found -# relative to the canonical path of this script. -# - -# Only follow symlinks if readlink supports it -if readlink -f "$0" > /dev/null 2>&1 -then - ZKREST=`readlink -f "$0"` -else - ZKREST="$0" -fi -ZKREST_HOME=`dirname "$ZKREST"` - -if $cygwin -then - # cygwin has a "kill" in the shell itself, gets confused - KILL=/bin/kill -else - KILL=kill -fi - -ZKREST_CONF=/conf -ZKREST_LOG=/logs/zookeeper-rest.out - -if [ -z $ZKREST_PIDFILE ] - then ZKREST_PIDFILE=$ZKREST_HOME/server.pid -fi - -ZKREST_MAIN=org.apache.zookeeper.server.jersey.RestMain - -CLASSPATH="$ZKREST_CONF:$CLASSPATH" - -for i in "$ZKREST_HOME"/lib/*.jar -do - CLASSPATH="$i:$CLASSPATH" -done - -for i in "$ZKREST_HOME"/zookeeper-*.jar -do - CLASSPATH="$i:$CLASSPATH" -done - -case $1 in -start) - echo "Starting ZooKeeper REST Gateway ... " - java -cp "$CLASSPATH" $JVMFLAGS $ZKREST_MAIN >$ZKREST_LOG 2>&1 & - /bin/echo -n $! > "$ZKREST_PIDFILE" - echo STARTED - ;; -start-foreground) - echo "Starting ZooKeeper REST Gateway ... " - java -cp "$CLASSPATH" $JVMFLAGS $ZKREST_MAIN >$ZKREST_LOG 2>&1 - ;; -stop) - echo "Stopping ZooKeeper REST Gateway ... " - if [ ! -f "$ZKREST_PIDFILE" ] - then - echo "error: could not find file $ZKREST_PIDFILE" - exit 1 - else - $KILL -9 $(cat "$ZKREST_PIDFILE") - rm "$ZKREST_PIDFILE" - echo STOPPED - fi - ;; -restart) - shift - "$0" stop ${@} - sleep 3 - "$0" start ${@} - ;; -*) - echo "Usage: $0 {start|start-foreground|stop|restart}" >&2 - -esac diff --git a/3.4.13/vm-image/etc/confd/conf.d/common.sh.toml b/3.4.13/vm-image/etc/confd/conf.d/common.sh.toml deleted file mode 100644 index 927dbd1..0000000 --- a/3.4.13/vm-image/etc/confd/conf.d/common.sh.toml +++ /dev/null @@ -1,7 +0,0 @@ -[template] -src = "common.sh.tmpl" -dest = "/opt/zkapp/bin/common.sh" -keys = [ - "/", -] -reload_cmd = "bash -e /opt/zkapp/bin/app.sh restart" diff --git a/3.4.13/vm-image/etc/confd/conf.d/zoo.cfg.toml b/3.4.13/vm-image/etc/confd/conf.d/zoo.cfg.toml deleted file mode 100644 index 52ba56e..0000000 --- a/3.4.13/vm-image/etc/confd/conf.d/zoo.cfg.toml +++ /dev/null @@ -1,7 +0,0 @@ -[template] -src = "zoo.cfg.tmpl" -dest = "/opt/zkapp/conf/server/zoo.cfg" -keys = [ - "/", -] -reload_cmd = "bash -e /opt/zkapp/bin/app.sh restart" diff --git a/3.4.13/vm-image/etc/confd/templates/common.sh.tmpl b/3.4.13/vm-image/etc/confd/templates/common.sh.tmpl deleted file mode 100644 index 7fdc739..0000000 --- a/3.4.13/vm-image/etc/confd/templates/common.sh.tmpl +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -e - -zkVersion="{{getv "/env/zkVersion"}}" -zkClientPort="{{getv "/cluster/endpoints/client/port" "2181"}}" -zkAdminEnabled="{{getv "/env/zkAdminEnabled"}}" -zkAdminUsername="{{getv "/env/zkAdminUsername"}}" -zkAdminPassword="{{getv "/env/zkAdminPassword"}}" - -# Calculate available physical memory to allocate to JVM. -free=`grep MemFree /proc/meminfo | awk '{print $2}'` -buffer=`grep Buffers /proc/meminfo | awk '{print $2}'` -cache=`grep ^Cached /proc/meminfo | awk '{print $2}'` -freemem=`expr $free + $buffer + $cache` -total_free=`expr $freemem / 1024 - 90` -if [ $total_free -le 0 ] -then - total_free=20 -fi - -zkImage="dockerhub.qingcloud.com/qingcloud/zookeeper:${zkVersion}" -if [ "$zkAdminEnabled" = "true" ]; then - # Generate digest from format of "user:password->user:encrypted". - digest=`docker run -i --rm --network host ${zkImage} /usr/bin/java -cp lib/slf4j-api-1.7.25.jar:zookeeper-${zkVersion}.jar org.apache.zookeeper.server.auth.DigestAuthenticationProvider "${zkAdminUsername}:${zkAdminPassword}" 2> /dev/null | awk -F'->' '{print $2}'` - digestFlags="-Dzookeeper.DigestAuthenticationProvider.superDigest=${digest}" -fi - -LOGS_DIR=/data/zookeeper/logs - -function zkStart() { - echo "{{getv "/host/gsid"}}" > /data/zookeeper/myid - docker run -dit --rm --network host --name zkserver -v /opt/zkapp/conf/server:/conf -v /data/zookeeper:/data -v $LOGS_DIR:/logs -e SERVER_JVMFLAGS="$digestFlags" -e JVMFLAGS="-Xmx${total_free}m" -e ZOO_LOG_DIR=/logs -e ZOO_LOG4J_PROP="INFO,ROLLINGFILE" ${zkImage} -} - -function zkStop() { - if [ "$(docker ps -q -f name=zkserver)" ]; then - docker stop zkserver - fi -} - -function zkRestart() { - zkStop - zkStart -} - -function zkRestStart() { - docker run -dit --rm --network host --name zkrest -v /opt/zkapp/conf/rest:/conf -v /data/zookeeper/logs:/logs dockerhub.qingcloud.com/qingcloud/zookeeper-rest:${zkVersion} -} - -function zkRestStop() { - if [ "$(docker ps -q -f name=zkrest)" ]; then - docker stop zkrest - fi -} - -function zkRestRestart() { - zkRestStop - zkRestStart -} diff --git a/3.4.13/vm-image/etc/confd/templates/zoo.cfg.tmpl b/3.4.13/vm-image/etc/confd/templates/zoo.cfg.tmpl deleted file mode 100644 index bba1811..0000000 --- a/3.4.13/vm-image/etc/confd/templates/zoo.cfg.tmpl +++ /dev/null @@ -1,10 +0,0 @@ -tickTime={{getv "/env/tickTime" "2000"}} -initLimit={{getv "/env/initLimit" "10"}} -syncLimit={{getv "/env/syncLimit" "5"}} -dataDir=/data -clientPort={{getv "/cluster/endpoints/client/port" "2181"}} -maxClientCnxns={{getv "/env/maxClientCnxns" "1000"}} -autopurge.snapRetainCount={{getv "/env/autopurge.snapRetainCount" "3"}} -autopurge.purgeInterval={{getv "/env/autopurge.purgeInterval" "0"}} -{{range $nodeId := lsdir "/hosts"}}{{$gsidUrl := printf "/hosts/%s/gsid" $nodeId}}{{$gsid := getv $gsidUrl}}{{$ipUrl := printf "/hosts/%s/ip" $nodeId}}{{$ip := getv $ipUrl}}{{$myNodeId := getv "/host/instance_id"}} -server.{{$gsid}}={{if eq $nodeId $myNodeId}}0.0.0.0{{else}}{{$ip}}{{end}}:2888:3888{{end}} diff --git a/3.4.13/vm-image/lib/systemd/system/post-docker-start.service b/3.4.13/vm-image/lib/systemd/system/post-docker-start.service deleted file mode 100644 index 0d91a18..0000000 --- a/3.4.13/vm-image/lib/systemd/system/post-docker-start.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Post Docker start -After=docker.service -Requires=docker.service - -[Service] -Type=oneshot -ExecStart=/opt/zkapp/bin/network.sh post-docker-start -RemainAfterExit=true - -[Install] -WantedBy=multi-user.target diff --git a/3.4.13/vm-image/opt/zkapp/bin/app.sh b/3.4.13/vm-image/opt/zkapp/bin/app.sh deleted file mode 100755 index 8308a8c..0000000 --- a/3.4.13/vm-image/opt/zkapp/bin/app.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -source "$(dirname $0)"/common.sh - -function appStart() { - zkRestStop - zkStop - zkStart - zkRestStart -} - -function appStop() { - zkRestStop - zkStop -} - -function appRestart() { - # If common.sh is initialized by confd before zoo.cfg, then we just wait for another trigger when zoo.cfg is set up. - if [ -f /opt/zkapp/conf/server/zoo.cfg ]; then - zkRestStop - zkStop - zkStart - zkRestStart - fi -} - -case $1 in -start) - echo "Starting ZooKeeper app..." - appStart - echo "Started." - ;; -stop) - echo "Stopping ZooKeeper app..." - appStop - echo "Stopped." - ;; -restart) - echo "Restarting ZooKeeper app..." - appRestart - echo "Restarted." - ;; -*) - echo "Usage: $0 {start|stop|restart}" >&2 - -esac - diff --git a/3.4.13/vm-image/opt/zkapp/bin/healthcheck.sh b/3.4.13/vm-image/opt/zkapp/bin/healthcheck.sh deleted file mode 100755 index 02c9e08..0000000 --- a/3.4.13/vm-image/opt/zkapp/bin/healthcheck.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -echo srvr | nc -q 2 127.0.0.1 2181 | grep "Mode: " - -source "$(dirname $0)"/common.sh -curl http://127.0.0.1:9998 || zkRestRestart diff --git a/3.4.13/vm-image/opt/zkapp/bin/init.sh b/3.4.13/vm-image/opt/zkapp/bin/init.sh deleted file mode 100755 index 1a50ed9..0000000 --- a/3.4.13/vm-image/opt/zkapp/bin/init.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -LOGS_DIR=/data/zookeeper/logs -mkdir -p $LOGS_DIR -chown -R ubuntu.ubuntu $LOGS_DIR diff --git a/3.4.13/vm-image/opt/zkapp/bin/metrics.sh b/3.4.13/vm-image/opt/zkapp/bin/metrics.sh deleted file mode 100755 index 56f673d..0000000 --- a/3.4.13/vm-image/opt/zkapp/bin/metrics.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -data=`echo srvr | nc -q 2 127.0.0.1 2181` -mode=`echo "$data" | awk -F': ' '$1 == "Mode" {print toupper(substr($2, 0, 1))}'` -latency=`echo "$data" | awk -F': ' '$1 == "Latency min/avg/max" {print $2}'` -min=`echo "$latency" | awk -F'/' '{print $1}'` -avg=`echo "$latency" | awk -F'/' '{print $2}'` -max=`echo "$latency" | awk -F'/' '{print $3}'` -received=`echo "$data" | awk -F': ' '$1 == "Received" {print $2}'` -sent=`echo "$data" | awk -F': ' '$1 == "Sent" {print $2}'` -active=`echo "$data" | awk -F': ' '$1 == "Connections" {print $2}'` -outstanding=`echo "$data" | awk -F': ' '$1 == "Outstanding" {print $2}'` -znode=`echo "$data" | awk -F': ' '$1 == "Node count" {print $2}'` - -cat </dev/null 2>&1 -} - -function remove() -{ - ip link set dev docker0 down - ip link delete docker0 -} - -function postDocker() -{ - echo Removing docker0... - exists && remove -} - -case $1 in -post-docker-start) - echo "Preparing Docker network for ZK app..." - postDocker - ;; -*) - echo "Usage: $0 {post-docker-start}" >&2 - -esac diff --git a/3.4.13/vm-image/opt/zkapp/conf/rest/keys/README b/3.4.13/vm-image/opt/zkapp/conf/rest/keys/README deleted file mode 100644 index 085810a..0000000 --- a/3.4.13/vm-image/opt/zkapp/conf/rest/keys/README +++ /dev/null @@ -1,8 +0,0 @@ - -In order to generate .jks (java keystore files) you need to use keytool. - -The password for the existing .jks is "123456" (without quotes). - -Some tutorials: - - http://www.mobilefish.com/tutorials/java/java_quickguide_keytool.html - diff --git a/3.4.13/vm-image/opt/zkapp/conf/rest/keys/rest.cer b/3.4.13/vm-image/opt/zkapp/conf/rest/keys/rest.cer deleted file mode 100644 index 13e5aab..0000000 Binary files a/3.4.13/vm-image/opt/zkapp/conf/rest/keys/rest.cer and /dev/null differ diff --git a/3.4.13/vm-image/opt/zkapp/conf/rest/keys/rest.jks b/3.4.13/vm-image/opt/zkapp/conf/rest/keys/rest.jks deleted file mode 100644 index 539e8be..0000000 Binary files a/3.4.13/vm-image/opt/zkapp/conf/rest/keys/rest.jks and /dev/null differ diff --git a/3.4.13/vm-image/opt/zkapp/conf/server/log4j.properties b/3.4.13/vm-image/opt/zkapp/conf/server/log4j.properties deleted file mode 100644 index 8de27cf..0000000 --- a/3.4.13/vm-image/opt/zkapp/conf/server/log4j.properties +++ /dev/null @@ -1,60 +0,0 @@ -# Define some default values that can be overridden by system properties -zookeeper.root.logger=INFO, CONSOLE, ROLLINGFILE -zookeeper.console.threshold=INFO -zookeeper.log.dir=/logs -zookeeper.log.file=zookeeper.log -zookeeper.log.threshold=INFO -zookeeper.tracelog.dir=/logs -zookeeper.tracelog.file=zookeeper_trace.log - -# -# ZooKeeper Logging Configuration -# - -# Format is " (, )+ - -# DEFAULT: console appender only -log4j.rootLogger=${zookeeper.root.logger} - -# Example with rolling log file -#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE - -# Example with rolling log file and tracing -#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold} -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n - -# -# Add ROLLINGFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender -log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold} -log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file} - -# Max log file size of 10MB -log4j.appender.ROLLINGFILE.MaxFileSize=10MB -# uncomment the next line to limit number of backup files -log4j.appender.ROLLINGFILE.MaxBackupIndex=10 - -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n - - -# -# Add TRACEFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender -log4j.appender.TRACEFILE.Threshold=TRACE -log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file} -log4j.appender.TRACEFILE.MaxFileSize=10MB -log4j.appender.TRACEFILE.MaxBackupIndex=10 - -log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout -### Notice we are including log4j's NDC here (%x) -log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/3.4.13/vm-image/opt/zkapp/conf/server/zoo_sample.cfg b/3.4.13/vm-image/opt/zkapp/conf/server/zoo_sample.cfg deleted file mode 100644 index a5a2c0b..0000000 --- a/3.4.13/vm-image/opt/zkapp/conf/server/zoo_sample.cfg +++ /dev/null @@ -1,28 +0,0 @@ -# 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=/tmp/zookeeper -# 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 diff --git a/ansible/.gitignore b/ansible/.gitignore new file mode 100644 index 0000000..69fc5c5 --- /dev/null +++ b/ansible/.gitignore @@ -0,0 +1,3 @@ +**/files/tmp/ +hosts +make.retry diff --git a/ansible/make.yml b/ansible/make.yml new file mode 100644 index 0000000..73fafc0 --- /dev/null +++ b/ansible/make.yml @@ -0,0 +1,21 @@ +--- +- name: zk tasks + hosts: all + vars: + target_env: "{{ lookup('env', 'target') }}" + tasks: + - include_role: + name: "{{ name }}" + loop: + - disable-apt-jobs-1.0.0 + - disable-motd-1.0.0 + - app-agent-1.0.1 + - appctl-1.0.7 + - arping-1.0.0 + - caddy-1.0.6 + - java-1.0.1 + - jq-1.0.3 + - netcat-openbsd-1.0.0 + - zookeeper + loop_control: + loop_var: name diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..578c8ac --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,8 @@ +- src: https://qingcloudappcenter.github.io/ansible-roles/app-agent-1.0.1.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles/appctl-1.0.7.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles/arping-1.0.0.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles/caddy-1.0.6.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles//confd-files-1.0.1.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles//java-1.0.1.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles//jq-1.0.3.tar.gz +- src: https://qingcloudappcenter.github.io/ansible-roles//netcat-openbsd-1.0.0.tar.gz diff --git a/ansible/roles/zookeeper/files/etc/confd/conf.d/caddy.sh.toml b/ansible/roles/zookeeper/files/etc/confd/conf.d/caddy.sh.toml new file mode 100644 index 0000000..17debc7 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/conf.d/caddy.sh.toml @@ -0,0 +1,8 @@ +[template] +src = "caddy.sh.tmpl" +dest = "/opt/app/bin/tmpl/caddy.sh" +mode = "0700" +keys = [ + "/", +] +reload_cmd = "/opt/app/bin/tmpl/caddy.sh; appctl reload caddy" diff --git a/ansible/roles/zookeeper/files/etc/confd/conf.d/zkrest.sh.toml b/ansible/roles/zookeeper/files/etc/confd/conf.d/zkrest.sh.toml new file mode 100644 index 0000000..115d8cb --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/conf.d/zkrest.sh.toml @@ -0,0 +1,8 @@ +[template] +src = "zkrest.sh.tmpl" +dest = "/opt/app/bin/tmpl/zkrest.sh" +mode = "0700" +keys = [ + "/", +] +reload_cmd = "/opt/app/bin/tmpl/zkrest.sh; appctl reload zookeeper-rest" diff --git a/ansible/roles/zookeeper/files/etc/confd/conf.d/zookeeper.sh.toml b/ansible/roles/zookeeper/files/etc/confd/conf.d/zookeeper.sh.toml new file mode 100644 index 0000000..37f1d81 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/conf.d/zookeeper.sh.toml @@ -0,0 +1,8 @@ +[template] +src = "zookeeper.sh.tmpl" +dest = "/opt/app/bin/tmpl/zookeeper.sh" +mode = "0700" +keys = [ + "/", +] +reload_cmd = "/opt/app/bin/tmpl/zookeeper.sh; appctl reload zookeeper-server" diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/01.svc.env.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/01.svc.env.tmpl new file mode 100644 index 0000000..395bbd1 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/01.svc.env.tmpl @@ -0,0 +1,3 @@ +flush /opt/app/bin/envs/svc-caddy.env << CADDY_ENV_EOF +SERVICES="\$SERVICES caddy/{{ getv "/env/web.console.enabled" "true" }}/http:80" +CADDY_ENV_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/02.caddyfile.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/02.caddyfile.tmpl new file mode 100644 index 0000000..8e88061 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/02.caddyfile.tmpl @@ -0,0 +1,13 @@ +flush /opt/app/conf/caddy/caddyfile << CADDYFILE_EOF +{{ getv "/host/ip" }}:80 { + {{- with getv "/env/web.console.password" "" }} + basicauth / "{{ getv "/env/web.console.username" "admin" }}" "{{ . }}" + {{- end }} + root /data + gzip + browse /zookeeper/dump + browse /zookeeper/logs + browse /zkrest/logs + tls off +} +CADDYFILE_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/03.index.html.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/03.index.html.tmpl new file mode 100644 index 0000000..4480fa3 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/caddy.sh/03.index.html.tmpl @@ -0,0 +1,92 @@ +flush /opt/app/conf/caddy/index.html << HTML_EOF + + + + + Files + + +
文件查看器
+
+ {{- $zkNodes := getvs "/hosts/*/ip" }} +
+ {{ len $zkNodes }} 个 ZooKeeper 节点 +
+ +
+ + + +HTML_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/zkrest.sh/01.svc-zkrest.env.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/zkrest.sh/01.svc-zkrest.env.tmpl new file mode 100644 index 0000000..778d5b6 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/zkrest.sh/01.svc-zkrest.env.tmpl @@ -0,0 +1,3 @@ +flush /opt/app/bin/envs/svc-zkreset.env << ZKREST_ENV_EOF +SERVICES="\$SERVICES zookeeper-rest/{{ getv "/env/zkrest.enabled" "true" }}/http:9998" +ZKREST_ENV_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/01.node.env.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/01.node.env.tmpl new file mode 100644 index 0000000..1db870a --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/01.node.env.tmpl @@ -0,0 +1,37 @@ +# global var which will be used in other tmpl files +{{- $allHosts := lsdir "/hosts" }} +{{- $joiningHosts := lsdir "/adding-hosts" }} +{{- $usingGsid := split "appv-9b7na511 appv-89xrqcih" " " | filter (getv "/upgrade-audit/from_app_version" "none") }} + +stableNodes="$(echo " +{{- range $allHosts }} +{{- if not ($joiningHosts | filter .) }} +{{ getv (printf "/hosts/%s/sid" .) }}/{{ getv (printf "/hosts/%s/node_id" .) }}/{{ getv (printf "/hosts/%s/ip" .) }} +{{- end }} +{{- end }} +" | xargs -n1 | sort -V | xargs)" + +joiningNodes="$(echo " +{{- range $joiningHosts }} +{{ getv (printf "/adding-hosts/%s/sid" .) }}/{{ getv (printf "/adding-hosts/%s/node_id" .) }}/{{ getv (printf "/adding-hosts/%s/ip" .) }} +{{- end }} +" | xargs -n1 | sort -V | xargs)" + +leavingNodes="$(echo " +{{- range lsdir "/deleting-hosts" }} +{{ getv (printf "/deleting-hosts/%s/sid" .) }}/{{ getv (printf "/deleting-hosts/%s/node_id" .) }}/{{ getv (printf "/deleting-hosts/%s/ip" .) }} +{{- end }} +" | xargs -n1 | sort -V | xargs)" + +flush /opt/app/bin/envs/node-zookeeper.env << ZK_ENV_EOF +SERVICES="\$SERVICES zookeeper-server/true/tcp:{{ getv "/cluster/endpoints/client/port" "2181" }}" +NODE_CTL="zookeeper" +CLUSTER_ID={{ getv "/cluster/cluster_id" }} +IS_UPGRADING={{ exists "/upgrade-audit/from_app_version" }} +MY_IP={{ getv "/host/ip" }} +MY_ZK_ID={{ if $usingGsid }}{{ getv "/host/gsid" }}{{ else }}{{ getv "/host/sid" }}{{ end }} +ZK_PORT={{ getv "/cluster/endpoints/client/port" "2181" }} +STABLE_NODES="$stableNodes" +JOINING_NODES="$joiningNodes" +LEAVING_NODES="$leavingNodes" +ZK_ENV_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/02.java.env.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/02.java.env.tmpl new file mode 100644 index 0000000..b3436d6 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/02.java.env.tmpl @@ -0,0 +1,16 @@ +dumpFlags="-XX:HeapDumpPath=/data/zookeeper/dump/dump.hprof" +{{- if eq "true" (getv "/env/zkAdminEnabled" "false") }} +pushd /opt/zookeeper/current +jarFiles="$(find lib -maxdepth 1 -type f -regex '^lib/\(slf4j-api\|zookeeper\)-[0-9].*$' | xargs)" +authFlags="-Dzookeeper.DigestAuthenticationProvider.superDigest=$(java -cp ${jarFiles// /:} \ + org.apache.zookeeper.server.auth.DigestAuthenticationProvider \ + "{{ getv "/env/zkAdminUsername" "" }}:{{ getv "/env/zkAdminPassword" "" }}" | awk -F'->' '{print $2}')" +popd +{{- end }} + +roFlags="-Dreadonlymode.enabled={{ getv "/env/readonlymode.enabled" "false" }}" + +flush /opt/app/conf/zookeeper/java.env << ZK_JAVA_ENV_EOF +SERVER_JVMFLAGS="$dumpFlags $authFlags $roFlags" +ZK_SERVER_HEAP={{ sub (getv "/host/memory") 90 }} +ZK_JAVA_ENV_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/03.zoo.cfg.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/03.zoo.cfg.tmpl new file mode 100644 index 0000000..6247931 --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/03.zoo.cfg.tmpl @@ -0,0 +1,16 @@ +flush /opt/app/conf/zookeeper/zoo.cfg << ZOO_CONF_EOF +tickTime={{ getv "/env/tickTime" "2000" }} +initLimit={{ getv "/env/initLimit" "10" }} +syncLimit={{ getv "/env/syncLimit" "5" }} +dataDir=/data/zookeeper +clientPort={{ getv "/cluster/endpoints/client/port" "2181" }} +maxClientCnxns={{ getv "/env/maxClientCnxns" "1000" }} +autopurge.snapRetainCount={{ getv "/env/autopurge.snapRetainCount" "3" }} +autopurge.purgeInterval={{ getv "/env/autopurge.purgeInterval" "1" }} +4lw.commands.whitelist=mntr,{{ getv "/env/4lw.commands.whitelist" "" }} +admin.enableServer={{ getv "/env/admin.server.enabled" "true" }} +tcpKeepAlive={{ getv "/env/tcpKeepAlive" "false" }} +standaloneEnabled=false +reconfigEnabled=false +dynamicConfigFile=/opt/app/conf/zookeeper/zoo.dynamic.cfg +ZOO_CONF_EOF diff --git a/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/04.zoo.dynamic.cfg.tmpl b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/04.zoo.dynamic.cfg.tmpl new file mode 100644 index 0000000..a0b144c --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/04.zoo.dynamic.cfg.tmpl @@ -0,0 +1,22 @@ +firstJoiningNode="${joiningNodes%% *}" +flush /opt/app/conf/zookeeper/zoo.dynamic.cfg << ZOO_DYNAMIC_CONF_EOF +{{- range $allHosts }} +{{- if not ($joiningHosts | filter .) }} +server.{{ if $usingGsid }}{{ getv (printf "/hosts/%s/gsid" .) }}{{ else }}{{ getv (printf "/hosts/%s/sid" .) }}{{ end }}={{ getv (printf "/hosts/%s/ip" .) }}:2888:3888 +{{- end }} +{{- end }} + +{{- $mySid := getv "/host/sid" }} +{{- range $joiningHosts }} +{{- $sid := getv (printf "/adding-hosts/%s/sid" .) }} +{{- if le $sid $mySid }} +server.{{ if $usingGsid }}{{ getv (printf "/adding-hosts/%s/gsid" .) }}{{ else }}{{ $sid }}{{ end }}={{ getv (printf "/adding-hosts/%s/ip" .) }}:2888:3888 +{{- end }} +{{- end }} + +{{- if $joiningHosts }} +{{- if and (not ($joiningHosts | filter (getv "/host/instance_id"))) (eq (sub (len $allHosts) (len $joiningHosts)) 1) }} +server.${firstJoiningNode%%/*}=${firstJoiningNode##*/}:2888:3888 +{{- end }} +{{- end }} +ZOO_DYNAMIC_CONF_EOF diff --git a/ansible/roles/zookeeper/files/lib/systemd/system/zookeeper-rest.service b/ansible/roles/zookeeper/files/lib/systemd/system/zookeeper-rest.service new file mode 100644 index 0000000..1e45619 --- /dev/null +++ b/ansible/roles/zookeeper/files/lib/systemd/system/zookeeper-rest.service @@ -0,0 +1,15 @@ +[Unit] +Description=ZooKeeper REST Gateway +Documentation=https://zookeeper.apache.org +Requires=network.target +After=network.target + +[Service] +Type=simple +User=zookeeper +Group=zookeeper +ExecStart=/opt/zkrest/current/bin/zkRest.sh +WorkingDirectory=/data/zkrest + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/ansible/roles/zookeeper/files/lib/systemd/system/zookeeper-server.service b/ansible/roles/zookeeper/files/lib/systemd/system/zookeeper-server.service new file mode 100644 index 0000000..12bd2ef --- /dev/null +++ b/ansible/roles/zookeeper/files/lib/systemd/system/zookeeper-server.service @@ -0,0 +1,19 @@ +[Unit] +Description=ZooKeeper Service +Documentation=https://zookeeper.apache.org +Requires=network.target +After=network.target + +[Service] +Type=simple +User=zookeeper +Group=zookeeper +EnvironmentFile=/opt/app/conf/zookeeper/server.env +ExecStart=/opt/zookeeper/current/bin/zkServer.sh start-foreground +ExecStop=/opt/zookeeper/current/bin/zkServer.sh stop +WorkingDirectory=/data/zookeeper + +LimitNOFILE=1048576 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/ansible/roles/zookeeper/files/opt/app/bin/envs/node-zookeeper.env b/ansible/roles/zookeeper/files/opt/app/bin/envs/node-zookeeper.env new file mode 100644 index 0000000..c241fee --- /dev/null +++ b/ansible/roles/zookeeper/files/opt/app/bin/envs/node-zookeeper.env @@ -0,0 +1 @@ +NODE_CTL="zookeeper" \ No newline at end of file diff --git a/ansible/roles/zookeeper/files/opt/app/bin/node/zookeeper.sh b/ansible/roles/zookeeper/files/opt/app/bin/node/zookeeper.sh new file mode 100644 index 0000000..7371556 --- /dev/null +++ b/ansible/roles/zookeeper/files/opt/app/bin/node/zookeeper.sh @@ -0,0 +1,122 @@ +EC_RETRIEVE_MODE_ERR=210 +EC_SCLIN_NOT_FOLLOWER=211 +EC_NO_LEADER_FOUND=212 +EC_START_ERR=213 +EC_UNKNOWN_ZK_ID=214 +EC_DELETING_TOO_MANY=215 +EC_UNKNOWN_MODE=216 +EC_MEASURE_ERR=220 + +initNode() { + mkdir -p /data/zookeeper/{dump,logs} /data/zkrest + chown -R zookeeper.svc /data/{zookeeper,zkrest} + local htmlFile=/data/index.html; [ -e "$htmlFile" ] || ln -s /opt/app/conf/caddy/index.html $htmlFile + _initNode + + if [ "$IS_UPGRADING" == "true" ]; then + # Fix "java.io.IOException: No snapshot found, but there are log entries. Something is broken!". + # See https://issues.apache.org/jira/browse/ZOOKEEPER-3056 for details. + local snapFile=/data/zookeeper/version-2/snapshot.0 + [ -e $snapFile ] || sudo -u zookeeper cp /opt/app/conf/zookeeper/snapshot.0 $snapFile + fi +} + +start() { + isNodeInitialized || initNode + reconfigure + + # Make sure newly joined nodes start after previously nodes to avoid data loss + if [[ "$JOINING_NODES " == *"/$MY_IP "* ]]; then + local node; for node in $STABLE_NODES; do retry 5 1 0 checkEndpoint tcp:2181 ${node##*/}; done + fi + + _start + + if [[ "$JOINING_NODES " == *"/$MY_IP "* ]]; then retry 3600 1 0 checkFullyStarted; fi + if [ "$IS_UPGRADING" == "true" ]; then retry 450 1 0 checkFullyStarted; fi +} + +reconfigure() { + [ -n "$MY_ZK_ID" ] && echo $MY_ZK_ID > /data/zookeeper/myid || return $EC_UNKNOWN_ZK_ID +} + +checkFullyStarted() { + local ip=${1:-$MY_IP} mode=${2:-"(leader|follower)"} + retrieveMode $ip | egrep -q "^$mode$" || return $EC_START_ERR +} + +retrieveMode() { + local ip=${1:-$MY_IP} + echo mntr | nc -q2 -w2 $ip 2181 | egrep "^zk_server_state\s(leader|follower)$" | cut -f2 || { + log "ERROR Failed to retrieve mode of $ip." + return $EC_RETRIEVE_MODE_ERR + } +} + +reload() { + if ! isNodeInitialized; then return 0; fi + + if [ "$1" == "zookeeper-server" ]; then + if [ -n "$LEAVING_NODES" ]; then return 0; fi + reconfigure + fi + + _reload $@ +} + +destroy() { + if [[ "$LEAVING_NODES " == *"/$MY_IP "* ]]; then + local mode; mode=$(retrieveMode) + [ "$mode" == "follower" ] || { + log "The current mode is '$mode' instead of 'follower'." + return $EC_SCLIN_NOT_FOLLOWER + } + fi +} + +findNodeIdOfLeader() { + local node; for node in $STABLE_NODES; do + local ip=${node##*/} mode; mode="$(retrieveMode $ip)" + if [ "$mode" == "leader" ]; then + echo $node | cut -d/ -f2 + return 0 + fi + done + + log "ERROR Failed to find leader node among all nodes ($STABLE_NODES)." + return $EC_NO_LEADER_FOUND +} + +backup() { + log "Taking snapshot ..." +} + +restore() { + find /data -mindepth 1 -maxdepth 1 ! -name zookeeper -exec rm -rf {} \; + find /data/zookeeper -mindepth 1 -maxdepth 1 ! -name version-2 -exec rm -rf {} \; + start +} + +checkSvc() { + if [ "$1" == "zookeeper-server" ]; then + retrieveMode | egrep -q '^(leader|follower)$' || return $EC_UNKNOWN_MODE + fi + _checkSvc $@ +} + +measure() { + local mappings=" + zk_server_state/mode + zk_([^_]*)_latency/\\1 + zk_packets_/ + zk_num_alive_connections/active + zk_(outstanding)_requests/\\1 + zk_(znode)_count/\\1 + " + echo mntr | nc -q2 -w2 localhost 2181 \ + | grep -v "This ZooKeeper instance is not currently serving requests" \ + | sed -r "$(echo "$mappings" | grep '\S' | sed 's#^ *#s/#g; s#$#/g;#g' | paste -s)" \ + | awk '$1=="mode"{$2=toupper(substr($2, 0, 1))} {print $1, $2}' \ + | jq -R 'split(" ") | {(.[0]): .[1]}' | jq -sc add \ + || (log "ERROR Failed to measure zk ($?)." && return $EC_MEASURE_ERR) +} \ No newline at end of file diff --git a/ansible/roles/zookeeper/files/opt/app/conf/caddy/caddyfile b/ansible/roles/zookeeper/files/opt/app/conf/caddy/caddyfile new file mode 100644 index 0000000..e69de29 diff --git a/3.4.13/vm-image/opt/zkapp/conf/rest/log4j.properties b/ansible/roles/zookeeper/files/opt/app/conf/zkrest/log4j.properties similarity index 72% rename from 3.4.13/vm-image/opt/zkapp/conf/rest/log4j.properties rename to ansible/roles/zookeeper/files/opt/app/conf/zkrest/log4j.properties index 1f09d21..84d17bf 100644 --- a/3.4.13/vm-image/opt/zkapp/conf/rest/log4j.properties +++ b/ansible/roles/zookeeper/files/opt/app/conf/zkrest/log4j.properties @@ -25,9 +25,13 @@ # Format is " (, )+ -# DEFAULT: rolling file +# DEFAULT: console appender only log4j.rootLogger=INFO, ROLLINGFILE +zkrest.log.dir=/data/zkrest/logs +zkrest.log.maxfilesize=1MB +zkrest.log.maxbackupindex=20 + # Example with rolling log file #log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE @@ -42,33 +46,25 @@ log4j.appender.CONSOLE.Threshold=INFO log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n -zkrest.log.dir=/logs -zkrest.log.file=zookeeper-rest.log -zkrest.tracelog.dir=/logs -zkrest.tracelog.file=zookeeper-rest_trace.log # # Add ROLLINGFILE to rootLogger to get log file output # Log DEBUG level and above messages to a log file -log4j.appender.ROLLINGFILE=org.apache.log4j.ConsoleAppender -log4j.appender.ROLLINGFILE.Threshold=DEBUG -log4j.appender.ROLLINGFILE.File=${zkrest.log.dir}/${zkrest.log.file} +log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender +log4j.appender.ROLLINGFILE.Threshold=INFO +log4j.appender.ROLLINGFILE.File=${zkrest.log.dir}/zkrest.log +log4j.appender.ROLLINGFILE.MaxFileSize=${zkrest.log.maxfilesize} +log4j.appender.ROLLINGFILE.MaxBackupIndex=${zkrest.log.maxbackupindex} log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n -# Max log file size of 10MB -log4j.appender.ROLLINGFILE.MaxFileSize=10MB -# uncomment the next line to limit number of backup files -log4j.appender.ROLLINGFILE.MaxBackupIndex=10 - # # Add TRACEFILE to rootLogger to get log file output # Log DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender +log4j.appender.TRACEFILE=org.apache.log4j.RollingFileAppender log4j.appender.TRACEFILE.Threshold=TRACE -log4j.appender.TRACEFILE.File=${zkrest.tracelog.dir}/${zkrest.tracelog.file} -log4j.appender.TRACEFILE.MaxFileSize=10MB -log4j.appender.TRACEFILE.MaxBackupIndex=10 - +log4j.appender.TRACEFILE.File=${zkrest.log.dir}/trace.log +log4j.appender.TRACEFILE.MaxFileSize=${zkrest.log.maxfilesize} +log4j.appender.TRACEFILE.MaxBackupIndex=${zkrest.log.maxbackupindex} log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout ### Notice we are including log4j's NDC here (%x) -log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n +log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n \ No newline at end of file diff --git a/3.4.13/vm-image/opt/zkapp/conf/rest/rest.properties b/ansible/roles/zookeeper/files/opt/app/conf/zkrest/rest.properties similarity index 100% rename from 3.4.13/vm-image/opt/zkapp/conf/rest/rest.properties rename to ansible/roles/zookeeper/files/opt/app/conf/zkrest/rest.properties diff --git a/3.4.13/vm-image/opt/zkapp/conf/server/configuration.xsl b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/configuration.xsl similarity index 100% rename from 3.4.13/vm-image/opt/zkapp/conf/server/configuration.xsl rename to ansible/roles/zookeeper/files/opt/app/conf/zookeeper/configuration.xsl diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties new file mode 100644 index 0000000..5e2d46f --- /dev/null +++ b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties @@ -0,0 +1,66 @@ +# Copyright 2012 The Apache Software Foundation +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Define some default values that can be overridden by system properties +zookeeper.root.logger=INFO, ROLLINGFILE + +zookeeper.console.threshold=INFO + +zookeeper.log.dir=/data/zookeeper/logs +zookeeper.log.file=zookeeper.log +zookeeper.log.threshold=INFO +zookeeper.log.maxfilesize=1MB +zookeeper.log.maxbackupindex=50 + +zookeeper.tracelog.dir=${zookeeper.log.dir} +zookeeper.tracelog.file=zookeeper_trace.log + +log4j.rootLogger=${zookeeper.root.logger} + +# +# console +# Add "console" to rootlogger above if you want to use this +# +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold} +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n + +# +# Add ROLLINGFILE to rootLogger to get log file output +# +log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender +log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold} +log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file} +log4j.appender.ROLLINGFILE.MaxFileSize=${zookeeper.log.maxfilesize} +log4j.appender.ROLLINGFILE.MaxBackupIndex=${zookeeper.log.maxbackupindex} +log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout +log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n + +# +# Add TRACEFILE to rootLogger to get log file output +# Log TRACE level and above messages to a log file +# +log4j.appender.TRACEFILE=org.apache.log4j.RollingFileAppender +log4j.appender.TRACEFILE.Threshold=TRACE +log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file} +log4j.appender.TRACEFILE.MaxFileSize=${zookeeper.log.maxfilesize} +log4j.appender.TRACEFILE.MaxBackupIndex=${zookeeper.log.maxbackupindex} +log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout +### Notice we are including log4j's NDC here (%x) +log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/server.env b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/server.env new file mode 100644 index 0000000..c0e8f34 --- /dev/null +++ b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/server.env @@ -0,0 +1,4 @@ +JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 +ZOOCFGDIR=/opt/app/conf/zookeeper +ZOO_LOG4J_PROP="INFO,ROLLINGFILE" +ZOO_LOG_DIR=/data/zookeeper/logs \ No newline at end of file diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/snapshot.0 b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/snapshot.0 new file mode 100644 index 0000000..3e6deee Binary files /dev/null and b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/snapshot.0 differ diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo.cfg b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo.cfg new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo.dynamic.cfg b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo.dynamic.cfg new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/zookeeper/files/opt/zkrest/current/bin/zkRest.sh b/ansible/roles/zookeeper/files/opt/zkrest/current/bin/zkRest.sh new file mode 100755 index 0000000..85f29dc --- /dev/null +++ b/ansible/roles/zookeeper/files/opt/zkrest/current/bin/zkRest.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd /opt/zkrest/current +java -cp $(ls zookeeper-*.jar lib/*.jar | xargs | tr ' ' :):/opt/app/conf/zkrest \ + -Xmx90m org.apache.zookeeper.server.jersey.RestMain \ No newline at end of file diff --git a/ansible/roles/zookeeper/tasks/main.yml b/ansible/roles/zookeeper/tasks/main.yml new file mode 100644 index 0000000..6f7cc44 --- /dev/null +++ b/ansible/roles/zookeeper/tasks/main.yml @@ -0,0 +1,153 @@ +--- +- name: set vars + set_fact: + zk_version: 3.5.6 + zkrest_version: 3.4.14 + +- name: add the service group + group: + name: svc + state: present + +- name: add the service user + user: + name: zookeeper + groups: svc + shell: /sbin/nologin + create_home: no + append: yes + comment: "Service User" + state: present + +- name: create directories + file: + path: /opt/{{ service }} + state: directory + loop: + - zookeeper/{{ zk_version }} + - zkrest/{{ zkrest_version }} + loop_control: + loop_var: service + +- name: link zookeeper binary dir + file: + src: "{{ zk_version }}" + dest: /opt/zookeeper/current + state: link + +- name: link zkrest binary dir + file: + src: "{{ zkrest_version }}" + dest: /opt/zkrest/current + state: link + +- name: prepare download dir + file: + path: "{{ role_path }}/files/tmp" + state: directory + delegate_to: localhost + +- name: download binary + vars: + path: "{{ role_path }}/files/tmp/zookeeper-{{ zk_version }}.tgz" + get_url: + url: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-{{ zk_version }}/apache-zookeeper-{{ zk_version }}-bin.tar.gz + dest: "{{ path }}" + delegate_to: localhost + when: path is not exists + run_once: True + +- name: install zk binaries + unarchive: + src: roles/{{ role_name }}/files/tmp/zookeeper-{{ zk_version }}.tgz + dest: /opt/zookeeper/current/ + extra_opts: + - --strip-components=1 + owner: root + group: root + creates: /opt/zookeeper/current/bin/zkServer.sh + +- name: extract zkrest + vars: + path: "{{ role_path }}/files/tmp" + unarchive: + src: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-{{ zkrest_version }}/zookeeper-{{ zkrest_version }}.tar.gz + dest: "{{ playbook_dir }}/roles/{{ role_name }}/files/tmp" + remote_src: yes + creates: "{{ playbook_dir }}/roles/{{ role_name }}/files/tmp/zookeeper-{{ zkrest_version }}/zookeeper-{{ zkrest_version }}.jar" + delegate_to: localhost + when: path is not exists + run_once: True + +- name: install zkrest + copy: + src: roles/{{ role_name }}/files/tmp/zookeeper-{{ zkrest_version }}/zookeeper-contrib/zookeeper-contrib-rest/{{ file_path }} + dest: /opt/zkrest/current/{{ file_path }} + owner: root + group: svc + mode: preserve + directory_mode: u=rwx,g=rx,o= + loop: + - zookeeper-{{ zkrest_version }}-rest.jar + - lib/ + - NOTICE.txt + - README.txt + loop_control: + loop_var: file_path + +- name: link necessary zk jar files to bootstrap zkrest + file: + src: /opt/zookeeper/current/lib/{{ file_path }} + dest: /opt/zkrest/current/{{ file_path }} + state: link + loop: + - zookeeper-{{ zk_version }}.jar + - zookeeper-jute-{{ zk_version }}.jar + loop_control: + loop_var: file_path + +- name: install services + copy: + src: roles/{{ role_name }}/files/lib/systemd/system/ + dest: /lib/systemd/system/ + +- name: copy files + copy: + src: files/opt/ + dest: /opt/ + owner: root + group: svc + mode: preserve + directory_mode: u=rwx,g=rx,o= + +- name: allow zk change conf files at runtime + file: + path: /opt/app/conf/zookeeper/{{ path }} + owner: zookeeper + group: svc + loop: + - zoo.cfg + - zoo.dynamic.cfg + loop_control: + loop_var: path + +- name: install confd files + include_role: + name: confd-files-1.0.1 + +- name: add commands to PATH + copy: + dest: /etc/profile.d/zookeeper-path.sh + content: 'PATH=$PATH:/opt/zookeeper/current/bin' + +- name: mask services + systemd: + name: "{{ service_name }}" + enabled: no + masked: yes + state: stopped + loop: + - zookeeper-server + - zookeeper-rest + loop_control: + loop_var: service_name diff --git a/3.4.13/app/cluster.json.mustache b/app/cluster.json.mustache similarity index 71% rename from 3.4.13/app/cluster.json.mustache rename to app/cluster.json.mustache index 310bd10..98b569e 100644 --- a/3.4.13/app/cluster.json.mustache +++ b/app/cluster.json.mustache @@ -3,11 +3,19 @@ "description": {{cluster.description}}, "vxnet": {{cluster.vxnet}}, "multi_zone_policy": "round_robin", + "backup_policy": "device", + "incremental_backup_supported": true, + "upgrade_policy": [ + "appv-89xrqcih", + "appv-9b7na511", + "appv-70gegwmp" + ], + "upgrading_policy": "sequential", "nodes": [{ "container": { "type": "kvm", "zone": "pek3a", - "image": "img-31fq61hi" + "image": "img-y7gct0gv" }, "count": {{cluster.zk_node.count}}, "cpu": {{cluster.zk_node.cpu}}, @@ -18,17 +26,28 @@ }, "server_id_upper_bound": 255, "services": { - "init": { - "cmd": "bash -e /opt/zkapp/bin/init.sh" - }, "start": { - "cmd": "bash -e /opt/zkapp/bin/app.sh start" + "cmd": "appctl start", + "timeout": 8000 }, "stop": { - "cmd": "bash -e /opt/zkapp/bin/app.sh stop" + "cmd": "appctl stop" + }, + "restart": { + "cmd": "appctl restart" + }, + "destroy": { + "allow_force": false, + "cmd": "appctl destroy" + }, + "backup": { + "selector": "appctl findNodeIdOfLeader", + "nodes_to_execute_on": 1, + "timeout": 3600, + "cmd": "appctl backup" }, - "upgrade": { - "cmd": "bash -e /opt/zkapp/bin/init.sh" + "restore": { + "cmd": "appctl restore" } }, "vertical_scaling_policy": "sequential" @@ -50,18 +69,18 @@ "action_timeout_sec": 30, "healthy_threshold": 2, "unhealthy_threshold": 2, - "check_cmd": "bash -e /opt/zkapp/bin/healthcheck.sh", - "action_cmd": "bash -e /opt/zkapp/bin/app.sh restart" + "check_cmd": "appctl check", + "action_cmd": "appctl revive" }, "monitor": { "enable": true, - "cmd": "bash -e /opt/zkapp/bin/metrics.sh", + "cmd": "appctl measure", "items": { "mode": { "unit": "", "value_type": "str", "statistics_type": "latest", - "enums": ["L", "F", "S"] + "enums": ["L", "F"] }, "min": { "unit": "ms", @@ -125,12 +144,18 @@ "zkAdminEnabled": {{env.admin_enabled}}, "zkAdminUsername": {{env.admin_username}}, "zkAdminPassword": {{env.admin_password}}, + "admin.server.enabled": {{env.admin.server.enabled}}, + "web.console.enabled": {{env.web.console.enabled}}, + "web.console.username": {{env.web.console.username}}, + "web.console.password": {{env.web.console.password}}, + "zkrest.enabled": {{env.zkrest.enabled}}, "tickTime": {{env.tickTime}}, "initLimit": {{env.initLimit}}, "syncLimit": {{env.syncLimit}}, "maxClientCnxns": {{env.maxClientCnxns}}, + "4lw.commands.whitelist": {{env.4lw.commands.whitelist}}, + "tcpKeepAlive": {{env.tcpKeepAlive}}, "autopurge.snapRetainCount": {{env.autopurge_snapRetainCount}}, - "autopurge.purgeInterval": {{env.autopurge_purgeInterval}}, - "zkVersion": "3.4.13" + "autopurge.purgeInterval": {{env.autopurge_purgeInterval}} } } diff --git a/3.4.13/app/config.json b/app/config.json similarity index 68% rename from 3.4.13/app/config.json rename to app/config.json index 619c54b..78b87d7 100644 --- a/3.4.13/app/config.json +++ b/app/config.json @@ -52,7 +52,7 @@ "description": "The instance type for the cluster to run, such as high performance, high performance plus", "type": "integer", "default": 0, - "range": [0, 1], + "range": [0, 1, 301], "required": "yes" }, { "key": "count", @@ -60,7 +60,7 @@ "description": "Number of nodes", "type": "integer", "default": 3, - "range": [ 1, 3, 5, 7, 9 ], + "range": [1, 3, 5, 7, 9], "required": "yes" }, { "key": "volume_size", @@ -76,32 +76,6 @@ "description": "Application configuration properties", "type": "array", "properties": [{ - "key": "admin_enabled", - "label": "Admin Enabled?", - "description": "Enable admin user to administrate ZooKeeper cluster, ZNodes, and ACLs", - "type": "boolean", - "changeable": true, - "default": false, - "required": "yes" - }, { - "key": "admin_username", - "label": "Admin Username", - "description": "The username of the admin user (ignore if disabled), can contain lowercase letters and digits, and must start with lowercase letters, with 3-12 characters in total", - "type": "string", - "changeable": true, - "default": "super", - "pattern": "[a-z][a-z0-9]{3,12}", - "required": "yes" - }, { - "key": "admin_password", - "label": "Admin Password", - "description": "The password of the admin user (ignore if disabled), can contain uppercase & lowercase letters, digits, and the following 10 special characters !@#$%^&*() with 4-32 characters in total", - "type": "password", - "changeable": true, - "default": "Super12345", - "pattern": "[A-Za-z0-9!@#$%^&*()]{4,32}", - "required": "yes" - }, { "key": "tickTime", "label": "tickTime", "description": "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", @@ -131,16 +105,6 @@ "min": 1, "max": 1000000, "required": "no" - }, { - "key": "maxClientCnxns", - "label": "maxClientCnxns", - "description": "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; this is used to prevent certain classes of DoS attacks, including file descriptor exhaustion; setting this to 0 entirely removes the limit on concurrent connections", - "type": "integer", - "changeable": true, - "default": 1000, - "min": 0, - "max": 1000000, - "required": "no" }, { "key": "autopurge_snapRetainCount", "label": "autopurge.snapRetainCount", @@ -161,6 +125,119 @@ "min": 0, "max": 720, "required": "no" + }, { + "key": "4lw.commands.whitelist", + "label": "4lw.commands.whitelist", + "description": "A list of Four Letter Words commands that user wants to use", + "type": "string", + "changeable": true, + "range": [ + "conf", + "cons", + "crst", + "dirs", + "dump", + "envi", + "gtmk", + "isro", + "ruok", + "srst", + "srvr", + "stat", + "stmk", + "wchc", + "wchp", + "wchs" + ], + "multichoice": true, + "default": "srvr", + "required": "no" + }, { + "key": "tcpKeepAlive", + "label": "tcpKeepAlive", + "description": "Setting this to true sets the TCP keepAlive flag on the sockets used by quorum members to perform elections", + "type": "boolean", + "changeable": true, + "default": false, + "required": "no" + }, { + "key": "maxClientCnxns", + "label": "maxClientCnxns", + "description": "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; this is used to prevent certain classes of DoS attacks, including file descriptor exhaustion; setting this to 0 entirely removes the limit on concurrent connections", + "type": "integer", + "changeable": true, + "default": 1000, + "min": 0, + "max": 1000000, + "required": "no" + }, { + "key": "admin_enabled", + "label": "Admin Enabled?", + "description": "Enable admin user to administrate ZooKeeper cluster, ZNodes, and ACLs", + "type": "boolean", + "changeable": true, + "default": false, + "required": "no" + }, { + "key": "admin_username", + "label": "Admin Username", + "description": "The username of the admin user (ignore if disabled), can contain lowercase letters and digits, and must start with lowercase letters, with 4-12 characters in total", + "type": "string", + "changeable": true, + "default": "super", + "pattern": "[a-z][a-z0-9]{3,12}", + "required": "no" + }, { + "key": "admin_password", + "label": "Admin Password", + "description": "The password of the admin user (ignore if disabled), can contain uppercase & lowercase letters, digits, and the following 10 special characters !@#$%^&*() with 4-32 characters in total", + "type": "password", + "changeable": true, + "default": "Super12345", + "pattern": "[A-Za-z0-9!@#$%^&*()]{4,32}", + "required": "no" + }, { + "key": "admin.server.enabled", + "label": "Enable AdminServer", + "description": "The AdminServer is an embedded Jetty server that provides an HTTP interface to the four letter word commands", + "type": "boolean", + "changeable": true, + "default": true, + "required": "no" + }, { + "key": "web.console.enabled", + "label": "Enable Web Console", + "description": "ZooKeeper logging files can be viewed from the web console", + "type": "boolean", + "changeable": true, + "default": true, + "required": "no" + }, { + "key": "web.console.username", + "label": "Web Console Username", + "description": "The username of the admin web console, can contain uppercase & lowercase letters, digits with 4-12 characters in total", + "type": "string", + "changeable": true, + "default": "admin", + "pattern": "^[a-z][a-z0-9_-]{3,32}", + "required": "no" + }, { + "key": "web.console.password", + "label": "Web Console Password", + "description": "The password of the admin web console, can contain uppercase & lowercase letters, digits, and the following 10 special characters !@#$%^&*() with 4-32 characters in total", + "type": "password", + "changeable": true, + "default": "admin", + "pattern": "[A-Za-z0-9!@#$%^&*()]{4,32}", + "required": "no" + }, { + "key": "zkrest.enabled", + "label": "Enable REST Gateway", + "description": "Whether enable REST gateway", + "type": "boolean", + "changeable": true, + "default": true, + "required": "no" }] }] } diff --git a/3.4.13/app/locale/en.json b/app/locale/en.json similarity index 100% rename from 3.4.13/app/locale/en.json rename to app/locale/en.json diff --git a/3.4.13/app/locale/zh-cn.json b/app/locale/zh-cn.json similarity index 57% rename from 3.4.13/app/locale/zh-cn.json rename to app/locale/zh-cn.json index 46adbc7..f9f491a 100644 --- a/3.4.13/app/locale/zh-cn.json +++ b/app/locale/zh-cn.json @@ -16,10 +16,13 @@ "The volume size for each node": "每个节点的存储容量", "instance class": "实例类型", "The instance type for the cluster to run, such as high performance, high performance plus": "节点实例类型,比如性能型与超高性能型。", + "notice_when_upgrade": "升级前请确保所有客户端都已经升级到 3.5.6 或以上版本,否则可能会出现 API 不兼容等原因而导致业务中断!", + "err_code210": "当前无法获取待删除节点的角色,为避免主节点被删除,请稍候重试,并确保集群状态正常并且选中从节点进行删除(可以通过节点的“服务模式”监控项获取主从信息)", + "err_code211": "当前选中的待删除节点可能包含主节点,为避免数据丢失,请选中从节点删除(可以通过节点的“服务模式”监控项获取主从信息)或等节点状态稳定后重试", "latency": "响应延迟时间", "throughput": "吞吐量", "connections": "连接数", - "mode": "服务模式 (L:Leader,F:Follower,S:Standalone)", + "mode": "服务模式 (L:主节点,F:从节点)", "min": "最小响应延迟时间", "avg": "平均响应延迟时间", "max": "最大响应延迟时间", @@ -28,22 +31,28 @@ "active": "活跃连接数", "outstanding": "待处理连接数", "client": "客户端", + "A list of Four Letter Words commands that user wants to use": "允许用户使用的 4lw (4 字母命令),请注意 mntr 监控命令永远开启,用来获取节点监控数据", + "Setting this to true sets the TCP keepAlive flag on the sockets used by quorum members to perform elections": "在 socket 层面启用 TCP keepalive 来防止节点之间意外断开,详情可参见操作系统的 TCP keepalive 说明", "Admin Enabled?": "启用管理员用户?", "Enable admin user to administrate ZooKeeper cluster, ZNodes, and ACLs": "管理员用户可以对集群、ZNodes及其数据,以及权限控制 (ACL) 进行管理", "Admin Username": "管理员用户名", - "The username of the admin user (ignore if disabled), can contain lowercase letters and digits, and must start with lowercase letters, with 3-12 characters in total": "管理员用户的用户名(不启用可忽略),可以由小写字母和数字组成,必须以字母开头,要求3到12位", + "The username of the admin user (ignore if disabled), can contain lowercase letters and digits, and must start with lowercase letters, with 4-12 characters in total": "管理员用户的用户名(不启用可忽略),可以由小写字母、数字、短横线(-)、下划线(_)组成,必须以字母开头,要求 4 到 12 位", "Admin Password": "管理员密码", - "The password of the admin user (ignore if disabled), can contain uppercase & lowercase letters, digits, and the following 10 special characters !@#$%^&*() with 4-32 characters in total": "管理员用户的密码(不启用可忽略),可以由大小写字母、数字和特殊字符 !@#$%^&*() 组成,要求4到32位", - + "The password of the admin user (ignore if disabled), can contain uppercase & lowercase letters, digits, and the following 10 special characters !@#$%^&*() with 4-32 characters in total": "管理员用户的密码(不启用可忽略),可以由大小写字母、数字和特殊字符 !@#$%^&*() 组成,要求 4 到 32 位", + "Enable AdminServer": "启用 AdminServer", + "The AdminServer is an embedded Jetty server that provides an HTTP interface to the four letter word commands": "用户可以通过 AdminServer 提供的 HTTP 接口(http://ip:8080/commands)执行 4lw(4 字母命令)", + "Enable Web Console": "启用文件查看控制台", + "ZooKeeper logging files can be viewed from the web console": "用户可以通过此控制台(http://ip)查看、下载日志等文件", + "Web Console Username": "文件查看用户名", + "The username of the admin web console, can contain uppercase & lowercase letters, digits with 4-12 characters in total": "登录文件查看控制台的用户名(不启用可忽略),可以由小写字母、数字、短横线(-)、下划线(_)组成,必须以字母开头,要求 4 到 12 位", + "Web Console Password": "文件查看密码", + "The password of the admin web console, can contain uppercase & lowercase letters, digits, and the following 10 special characters !@#$%^&*() with 4-32 characters in total": "登录文件查看控制台的密码(不启用可忽略),可以由大小写字母、数字和特殊字符 !@#$%^&*() 组成,要求 4 到 32 位", + "Enable REST Gateway": "启用 REST 网关", + "Whether enable REST gateway": "用户可以通过 REST 网关提供的 HTTP 接口访问 ZooKeeper 节点数据,详情可查阅官方仓库:https://github.com/apache/zookeeper/tree/release-3.4.14/zookeeper-contrib/zookeeper-contrib-rest", "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": "ZooKeeper 最小时间单位 tick 的毫秒数,用来调整心跳和超时,比如 session 的最短超时时间为两个 tick", - "Amount of time, in ticks (see tickTime), to allow followers to connect and sync to a leader; increase this value as needed, if the amount of data managed by ZooKeeper is large": "允许 follower 跟 leader 进行初始化连接和数据同步的最长时间,以 tick 为单位,如有需要可调大这个值,尤其是 ZooKeeper 管理的数据量很大的时候", - "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": "允许 follower 同步数据的最长时间,以 tick 为单位,如果 follower 的数据太旧,此 follower 将被丢弃", - "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; this is used to prevent certain classes of DoS attacks, including file descriptor exhaustion; setting this to 0 entirely removes the limit on concurrent connections": "限制以 IP 地址标识的客户端与单个 ZooKeeper 节点的最大并发连接数,用来防止某些 DoS 攻击,包括 file descriptor exhaustion ,设为 0 表示不做限制", - "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": "当自动清除功能 (Auto Purge) 开启时,所要保留的最新快照和事务日志文件数,其余文件将被清除", - "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": "自动清除功能的执行间隔,以小时为单位,0 表示不开启" } diff --git a/app/replace_policy.json b/app/replace_policy.json new file mode 100644 index 0000000..e4b69c0 --- /dev/null +++ b/app/replace_policy.json @@ -0,0 +1,83 @@ +{ + "ap2a": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 201 + }] + }, + "ap3a": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 202 + }] + }, + "gd2a": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 201 + }] + }, + "gd2b": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 201 + }] + }, + "pek3b": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 202 + }] + }, + "pek3c": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 202 + }] + }, + "pek3d": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 202 + }] + }, + "sh1a": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 202 + }] + }, + "sh1b": { + "instance_class": [{ + "src": "0", + "dst": 101 + }, { + "src": "1", + "dst": 202 + }] + } +} diff --git a/3.4.13/examples/java-client/.gitignore b/tests/java-client/.gitignore similarity index 100% rename from 3.4.13/examples/java-client/.gitignore rename to tests/java-client/.gitignore diff --git a/3.4.13/examples/java-client/README.md b/tests/java-client/README.md similarity index 100% rename from 3.4.13/examples/java-client/README.md rename to tests/java-client/README.md diff --git a/3.4.13/examples/java-client/build.gradle b/tests/java-client/build.gradle similarity index 100% rename from 3.4.13/examples/java-client/build.gradle rename to tests/java-client/build.gradle diff --git a/3.4.13/examples/java-client/gradle/wrapper/gradle-wrapper.jar b/tests/java-client/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from 3.4.13/examples/java-client/gradle/wrapper/gradle-wrapper.jar rename to tests/java-client/gradle/wrapper/gradle-wrapper.jar diff --git a/3.4.13/examples/java-client/gradle/wrapper/gradle-wrapper.properties b/tests/java-client/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from 3.4.13/examples/java-client/gradle/wrapper/gradle-wrapper.properties rename to tests/java-client/gradle/wrapper/gradle-wrapper.properties diff --git a/3.4.13/examples/java-client/gradlew b/tests/java-client/gradlew similarity index 100% rename from 3.4.13/examples/java-client/gradlew rename to tests/java-client/gradlew diff --git a/3.4.13/examples/java-client/gradlew.bat b/tests/java-client/gradlew.bat similarity index 100% rename from 3.4.13/examples/java-client/gradlew.bat rename to tests/java-client/gradlew.bat diff --git a/3.4.13/examples/java-client/src/main/java/com/yunify/appcenter/examples/zookeeper/ClientExample.java b/tests/java-client/src/main/java/com/yunify/appcenter/examples/zookeeper/ClientExample.java similarity index 100% rename from 3.4.13/examples/java-client/src/main/java/com/yunify/appcenter/examples/zookeeper/ClientExample.java rename to tests/java-client/src/main/java/com/yunify/appcenter/examples/zookeeper/ClientExample.java diff --git a/3.4.13/examples/zk-cli/README.md b/tests/zk-cli/README.md similarity index 100% rename from 3.4.13/examples/zk-cli/README.md rename to tests/zk-cli/README.md