From 4b4a593efd7656a5777de440eeedf322edba2aaf Mon Sep 17 00:00:00 2001 From: Hongliang Wang Date: Sun, 1 Mar 2020 08:40:15 +0000 Subject: [PATCH] Upgrade to zk 3.5.7 --- ansible/group_vars/all.yml | 3 +- .../templates/zookeeper.sh/02.java.env.tmpl | 2 +- .../templates/zookeeper.sh/03.zoo.cfg.tmpl | 40 +++-------- .../zookeeper.sh/04.zoo.dynamic.cfg.tmpl | 23 +++++++ .../files/opt/app/bin/envs/node-zookeeper.env | 1 + .../files/opt/app/bin/node/zookeeper.sh | 13 +++- .../files/opt/app/conf/caddy/caddyfile | 0 .../files/opt/app/conf/zkrest/keys/README | 8 --- .../files/opt/app/conf/zkrest/keys/rest.cer | Bin 595 -> 0 bytes .../files/opt/app/conf/zkrest/keys/rest.jks | Bin 1363 -> 0 bytes .../opt/app/conf/zookeeper/log4j.properties | 64 ++++++++++-------- .../files/opt/app/conf/zookeeper/snapshot.0 | Bin 0 -> 424 bytes .../opt/app/conf/zookeeper/zoo.dynamic.cfg | 0 .../opt/app/conf/zookeeper/zoo_sample.cfg | 28 -------- ansible/roles/zookeeper/tasks/main.yml | 45 ++++++++---- app/cluster.json.mustache | 7 +- app/config.json | 11 ++- app/locale/zh-cn.json | 11 +-- 18 files changed, 137 insertions(+), 119 deletions(-) create mode 100644 ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/04.zoo.dynamic.cfg.tmpl create mode 100644 ansible/roles/zookeeper/files/opt/app/bin/envs/node-zookeeper.env create mode 100644 ansible/roles/zookeeper/files/opt/app/conf/caddy/caddyfile delete mode 100644 ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/README delete mode 100644 ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/rest.cer delete mode 100644 ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/rest.jks create mode 100644 ansible/roles/zookeeper/files/opt/app/conf/zookeeper/snapshot.0 create mode 100644 ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo.dynamic.cfg delete mode 100644 ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo_sample.cfg diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 36a9834..54017f6 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1 +1,2 @@ -zk_version: 3.4.14 +zk_version: 3.5.7 +zkrest_version: 3.4.14 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 index 72806ea..10394f6 100644 --- 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 @@ -1,7 +1,7 @@ dumpFlags="-XX:HeapDumpPath=/data/zookeeper/dump/dump.hprof" {{- if eq "true" (getv "/env/zkAdminEnabled" "false") }} pushd /opt/zookeeper/current -jarFiles="$(echo -n lib/slf4j-api*):zookeeper-$ZK_VERSION.jar" +jarFiles="$(echo -n lib/slf4j-api*):lib/zookeeper-$ZK_VERSION.jar" authFlags="-Dzookeeper.DigestAuthenticationProvider.superDigest=$(java -cp $jarFiles \ org.apache.zookeeper.server.auth.DigestAuthenticationProvider \ "{{ getv "/env/zkAdminUsername" "" }}:{{ getv "/env/zkAdminPassword" "" }}" | awk -F'->' '{print $2}')" 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 index 23f75b8..6247931 100644 --- 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 @@ -1,34 +1,16 @@ -firstJoiningNode="${joiningNodes%% *}" - 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"}} +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" "0"}} +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" }} - -{{- range $allNodes }} -{{- if not ($joiningNodes | 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 $joiningNodes }} -{{- $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 $joiningNodes }} -{{- if and (not ($joiningNodes | filter (getv "/host/instance_id"))) (eq (sub (len $allNodes) (len $joiningNodes)) 1) }} -server.${firstJoiningNode%%/*}=${firstJoiningNode##*/}:2888:3888 -{{- end }} -{{- end }} +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..06c7c0f --- /dev/null +++ b/ansible/roles/zookeeper/files/etc/confd/templates/zookeeper.sh/04.zoo.dynamic.cfg.tmpl @@ -0,0 +1,23 @@ +firstJoiningNode="${joiningNodes%% *}" + +flush /opt/app/conf/zookeeper/zoo.dynamic.cfg << ZOO_DYNAMIC_CONF_EOF +{{- range $allNodes }} +{{- if not ($joiningNodes | 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 $joiningNodes }} +{{- $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 $joiningNodes }} +{{- if and (not ($joiningNodes | filter (getv "/host/instance_id"))) (eq (sub (len $allNodes) (len $joiningNodes)) 1) }} +server.${firstJoiningNode%%/*}=${firstJoiningNode##*/}:2888:3888 +{{- end }} +{{- end }} +ZOO_DYNAMIC_CONF_EOF 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 index a43e560..2a6eb5f 100644 --- a/ansible/roles/zookeeper/files/opt/app/bin/node/zookeeper.sh +++ b/ansible/roles/zookeeper/files/opt/app/bin/node/zookeeper.sh @@ -12,6 +12,13 @@ initNode() { 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() { @@ -34,13 +41,13 @@ reconfigure() { } checkFullyStarted() { - local ip=${1:-$MY_IP} mode=${2:-"(leader|follower|standalone)"} + 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|standalone)$" | cut -f2 || { + 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 } @@ -93,7 +100,7 @@ restore() { checkSvc() { if [ "$1" == "zookeeper" ]; then - retrieveMode | egrep -q '^(leader|follower|standalone)$' || return $EC_UNKNOWN_MODE + retrieveMode | egrep -q '^(leader|follower)$' || return $EC_UNKNOWN_MODE fi _checkSvc $@ } 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/ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/README b/ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/README deleted file mode 100644 index 085810a..0000000 --- a/ansible/roles/zookeeper/files/opt/app/conf/zkrest/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/ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/rest.cer b/ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/rest.cer deleted file mode 100644 index 13e5aabe562f0d0507d3c6709a3a3527ce258f19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 595 zcmXqLV)8d=V%)KSnTe5!iNz;sF0TPE8>d#AN85K^Mn+av27??!0RuiZ=1>+kVfN6x z?7aN)JeUXvh6p=`2p5J3H--o^T*N?5oY&C6z{0@P(9qDt$S_Kr*Vxp+*vK5prL$`q z=Oc#(BP#=QV=se2V<%H%BSYWbGS>f3PJXvm4%r-kd}HQ?l{*@lYdP% zKXaEoN*khNe+YWI`;11mY-+!bZpKk1GMmr3`n#2w6gv+_ab<1?{)@-|1UO&Uzt2^?V`hx> zo~?GG?UC!1EZ6iZIv5CUjxayK`25YYdr9R_ivm4AKHV<1dRh-#_&ZUf9R~ND9?75o t@hPEFdt$!Tolof%M$N1r7$#`FG}+r_l_j^PQl#fZW6;l-MbVp5Spm(9$n*dJ diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/rest.jks b/ansible/roles/zookeeper/files/opt/app/conf/zkrest/keys/rest.jks deleted file mode 100644 index 539e8be7ba44e0dc3cb39deb822280a4fbde67af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1363 zcmezO_TO6u1_mY|W&~r_+{*0KN+3_m@oVinpv*3VCZ=r$d~96WY>X_7T1J%57Nhc{i> zJWVv!CM&G;pKJ1F`Eydn8DX>4x8`(zSaIhqXF2aCF+QER+=YLS?SH#k?)!w(4c&fo zKk7Exu6e?c<~~{0x^8-+)!C|#nx4Hzp%*`A+gLFCy?gR@u13_fpKF5B^E}t?QD%LX z5p!;a2&0!zztzrfJQuE4uuNJz`+_ZBGXGRVy~N3x4_sq@ysP*sD<$b(+QLw~VQJf^ zd%r)51}K^S)hT4q6me+0D9Pv@6J+`QNqwBGgq^QW4wu%!!n^-UrdS<5b^R%C&&%0P z4eY^tdmqbnE^cj!_&3>X`nC5{w^9e zOV{?oh78_@+vR1aT0TYTHiXuHXY6O4zsqcjWq|M#uBH@?gkBxv?ea?9mlr9w-cks; z<5yI3Pe;MtdVc*b<0GF$T{e}uME}mUG`jcx%f88*G<9O4!+j;~a@{pL%g+A(@Jsf@ z=Dq*Q*%@A0*#j|HF%N9H1UsSl@e|w@_=G=0DQ{9(pYLv@+i)F7E zot$-blI}ET?>>)`3LA&Fys;T}5$&;VX zoqQ30pgLpU^H+)C8_%s;vC4ev#pda=)_ZVdtqgBtnY6HBD);ulD=Ujc=gm9guO7C` zI#kts=@Fg01SN4H%hnr74-PjUoAOCKvE6O*RIl|H+AnAQ?t&!f2t88+OJG6{1}0>G zgC@ou3z(T0nV497qUQ1%@Un4gwRyCC=LM!}RtAF{Ljhn?XAWgy6J`(1%g)O$&x46@ zV2H3|h;U(uaASxt!$l0_#CZ)33@i*x4Gj%Vj0~g1d5ujCjE&5pTspg^aXxZr05dsr zV=se2V<%H%BSYWbGS>f3PJXvm4%r-kd}HQ?l{*@lYdP%KXaEoN*khN ze+YWI`; z11mY-+!bZpKk1GMmr3`n#2w6gv+_ab<1?{)@-|1UO&Uzt2^?V`hx>o~?GG?UC!1 zEZ6iZIv5CUjxayK`25YYdr9R_ivm4AKHV<1dRh-#_&ZUf9R~ND9?75o@hPEFdt$!T zolof%M$N1r7$#`FG}+r_l_j^PQl#fZW6;l-MbVp5S#Ql>`)8x9kFnIL9nVyf=6eU7 H+RO<6^fNHf diff --git a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties index c90f6a9..5e2d46f 100644 --- a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties +++ b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/log4j.properties @@ -1,29 +1,40 @@ +# 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, CONSOLE, ROLLINGFILE +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.tracelog.dir=/data/zookeeper/logs -zookeeper.tracelog.file=zookeeper_trace.log - -# -# ZooKeeper Logging Configuration -# +zookeeper.log.maxfilesize=1MB +zookeeper.log.maxbackupindex=50 -# Format is " (, )+ +zookeeper.tracelog.dir=${zookeeper.log.dir} +zookeeper.tracelog.file=zookeeper_trace.log -# 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 +# 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} @@ -32,29 +43,24 @@ log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %- # # 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=1MB -# uncomment the next line to limit number of backup files -log4j.appender.ROLLINGFILE.MaxBackupIndex=50 - +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 DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender +# 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=1MB -log4j.appender.TRACEFILE.MaxBackupIndex=50 - +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/snapshot.0 b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/snapshot.0 new file mode 100644 index 0000000000000000000000000000000000000000..3e6deee02b83966e6e933ea33a686a7c11223515 GIT binary patch literal 424 zcma#@4)$YUU|{+W1wb|kFhVFW4Pt{ZYk7WAP7090mY7$WpO*?%!hog~CQK^LrC*hw zpPiaokXi)NN+nYT5vJ-V=jWwmrX#rv=1U|Y>`ahju*e7?8D3bLUy=w?LnVhZ>Vpj1 MvB=sJNHOXI0LqX(R{#J2 literal 0 HcmV?d00001 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/app/conf/zookeeper/zoo_sample.cfg b/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/zoo_sample.cfg deleted file mode 100644 index a5a2c0b..0000000 --- a/ansible/roles/zookeeper/files/opt/app/conf/zookeeper/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/roles/zookeeper/tasks/main.yml b/ansible/roles/zookeeper/tasks/main.yml index a4d26f9..ee62c39 100644 --- a/ansible/roles/zookeeper/tasks/main.yml +++ b/ansible/roles/zookeeper/tasks/main.yml @@ -1,4 +1,9 @@ --- +- name: set vars + set_fact: + zk_version: 3.5.7 + zkrest_version: 3.4.14 + - name: add the service group group: name: svc @@ -21,30 +26,35 @@ opts: pkg_name: zookeeper pkg_version: "{{ zk_version }}" - pkg_url: https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-{{ zk_version }}/zookeeper-{{ zk_version }}.tar.gz + pkg_url: https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-{{ zk_version }}/apache-zookeeper-{{ zk_version }}-bin.tar.gz pkg_type: .tgz extracts: true bin_path: bin creates: bin/zkServer.sh -- name: set up zkrest dir - file: - path: /opt/zkrest - state: directory - -- name: set up zkrest files - file: - src: /opt/zookeeper/current/zookeeper-contrib/zookeeper-contrib-rest - dest: /opt/zkrest/current - state: link +- name: install zkrest + include_role: + name: install-1.0.0 + vars: + opts: + pkg_name: zkrest + pkg_version: "{{ zkrest_version }}" + pkg_url: https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-{{ zkrest_version }}/zookeeper-{{ zkrest_version }}.tar.gz + pkg_type: .tgz + extracts: true + extra_opts: + - --strip-components=3 + - zookeeper-{{ zkrest_version }}/zookeeper-contrib/zookeeper-contrib-rest + creates: zookeeper-{{ zkrest_version }}-rest.jar - name: link necessary zk jar files to bootstrap zkrest file: - src: /opt/zookeeper/current/{{ file_path }} + 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 @@ -74,6 +84,17 @@ 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: set up zk env copy: dest: /opt/app/bin/envs/confd.env diff --git a/app/cluster.json.mustache b/app/cluster.json.mustache index a6209d8..6c72dc7 100644 --- a/app/cluster.json.mustache +++ b/app/cluster.json.mustache @@ -14,8 +14,8 @@ "nodes": [{ "container": { "type": "kvm", - "zone": "pek3a", - "image": "img-bdt5kork" + "zone": "pek3", + "image": "img-nd557r5e" }, "count": {{cluster.zk_node.count}}, "cpu": {{cluster.zk_node.cpu}}, @@ -80,7 +80,7 @@ "unit": "", "value_type": "str", "statistics_type": "latest", - "enums": ["L", "F", "S"] + "enums": ["L", "F"] }, "min": { "unit": "ms", @@ -144,6 +144,7 @@ "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}}, diff --git a/app/config.json b/app/config.json index d806950..677849a 100644 --- a/app/config.json +++ b/app/config.json @@ -171,6 +171,7 @@ "conf", "cons", "crst", + "dirs", "dump", "envi", "gtmk", @@ -185,7 +186,7 @@ "wchs" ], "multichoice": true, - "default": "conf,cons,crst,dump,envi,gtmk,isro,ruok,srst,srvr,stat,stmk,wchc,wchp,wchs", + "default": "srvr", "required": "no" }, { "key": "tcpKeepAlive", @@ -195,6 +196,14 @@ "changeable": true, "default": false, "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", diff --git a/app/locale/zh-cn.json b/app/locale/zh-cn.json index a50f07d..57dbe48 100644 --- a/app/locale/zh-cn.json +++ b/app/locale/zh-cn.json @@ -15,14 +15,14 @@ "Volume Size": "存储容量", "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": "升级期间会发生主从切换,生产环境升级前请先在测试环境测试,确保所有客户端可以正常处理并自动重连,以免造成业务中断!", + "The instance type for the cluster to run, such as high performance, high performance plus": "节点实例类型,比如性能型与超高性能型。", + "notice_when_upgrade": "升级前请确保所有客户端都已经升级到 3.5.7 或以上版本,否则可能会出现 API 不兼容等原因而导致业务中断!", "err_code210": "当前无法获取待删除节点的角色,为避免主节点被删除,请稍候重试,并确保集群状态正常并且选中从节点进行删除(可以通过节点的“服务模式”监控项获取主从信息)", "err_code211": "当前选中的待删除节点可能包含主节点,为避免数据丢失,请选中从节点删除(可以通过节点的“服务模式”监控项获取主从信息)或等节点状态稳定后重试", "latency": "响应延迟时间", "throughput": "吞吐量", "connections": "连接数", - "mode": "服务模式 (L:主节点,F:从节点,S:独立节点)", + "mode": "服务模式 (L:主节点,F:从节点)", "min": "最小响应延迟时间", "avg": "平均响应延迟时间", "max": "最大响应延迟时间", @@ -31,7 +31,7 @@ "active": "活跃连接数", "outstanding": "待处理连接数", "client": "客户端", - "A list of Four Letter Words commands that user wants to use": "允许用户使用的 4lw (4 字母命令),请注意 mntr 监控命令永远开启,平台用 mntr 命令来获取节点监控数据", + "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) 进行管理", @@ -39,6 +39,8 @@ "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 位", + "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": "文件查看用户名", @@ -54,3 +56,4 @@ "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 表示不开启" } +