diff --git a/3.4.9/cluster.json.mustache b/3.4.9/cluster.json.mustache new file mode 100644 index 0000000..87277b3 --- /dev/null +++ b/3.4.9/cluster.json.mustache @@ -0,0 +1,117 @@ +{ + "name": {{cluster.name}}, + "description": {{cluster.description}}, + "vxnet": {{cluster.vxnet}}, + "nodes": [{ + "container": { + "type": "kvm", + "zone": "pek3a", + "image": "img-svm7yple" + }, + "count": {{cluster.zk_node.count}}, + "cpu": {{cluster.zk_node.cpu}}, + "memory": {{cluster.zk_node.memory}}, + "instance_class": {{cluster.zk_node.instance_class}}, + "volume": { + "size": {{cluster.zk_node.volume_size}} + }, + "server_id_upper_bound": 255, + "services": { + "start": { + "cmd": "/opt/zookeeper/bin/zkServer.sh start;/opt/zookeeper/bin/rest.sh start" + }, + "stop": { + "cmd": "/opt/zookeeper/bin/rest.sh stop;/opt/zookeeper/bin/zkServer.sh stop" + } + }, + "advanced_actions": ["change_vxnet", "scale_horizontal"], + "vertical_scaling_policy": "sequential" + }], + "endpoints": { + "client": { + "port": 2181, + "protocol": "tcp" + }, + "rest": { + "port": 9998, + "protocol": "tcp" + } + }, + "health_check": { + "enable": true, + "interval_sec": 60, + "timeout_sec": 10, + "action_timeout_sec": 30, + "healthy_threshold": 2, + "unhealthy_threshold": 2, + "check_cmd": "echo srvr | nc 127.0.0.1 2181", + "action_cmd": "/opt/zookeeper/bin/restart-server.sh" + }, + "monitor": { + "enable": true, + "cmd": "/opt/zookeeper/bin/get-monitor.sh", + "items": { + "mode": { + "unit": "", + "value_type": "str", + "statistics_type": "latest", + "enums": ["L", "F", "S"] + }, + "min": { + "unit": "ms", + "value_type": "int", + "statistics_type": "min", + "scale_factor_when_display": 1 + }, + "avg": { + "unit": "ms", + "value_type": "int", + "statistics_type": "avg", + "scale_factor_when_display": 1 + }, + "max": { + "unit": "ms", + "value_type": "int", + "statistics_type": "max", + "scale_factor_when_display": 1 + }, + "received": { + "unit": "count", + "value_type": "int", + "statistics_type": "latest", + "scale_factor_when_display": 1 + }, + "sent": { + "unit": "count", + "value_type": "int", + "statistics_type": "latest", + "scale_factor_when_display": 1 + }, + "active": { + "unit": "count", + "value_type": "int", + "statistics_type": "latest", + "scale_factor_when_display": 1 + }, + "outstanding": { + "unit": "count", + "value_type": "int", + "statistics_type": "latest", + "scale_factor_when_display": 1 + }, + "znode": { + "unit": "znode_count", + "value_type": "int", + "statistics_type": "latest", + "scale_factor_when_display": 1 + } + }, + "groups": { + "latency": ["min", "avg", "max"], + "throughput": ["received", "sent"], + "connections": ["active", "outstanding"] + }, + "display": ["mode", "latency", "throughput", "connections", "znode"], + "alarm": ["avg"] + } +} diff --git a/3.4.9/config.json b/3.4.9/config.json new file mode 100644 index 0000000..4034ad3 --- /dev/null +++ b/3.4.9/config.json @@ -0,0 +1,93 @@ +{ + "type": "array", + "properties": [{ + "key": "cluster", + "description": "ZooKeeper release 3.4.9 cluster properties", + "type": "array", + "properties": [{ + "key": "name", + "label": "Name", + "description": "The name of the ZooKeeper service", + "type": "string", + "default": "ZooKeeper", + "required": "no" + }, { + "key": "description", + "label": "Description", + "description": "The description of the ZooKeeper service", + "type": "string", + "default": "", + "required": "no" + }, { + "key": "vxnet", + "label": "VxNet", + "description": "Choose a vxnet to join", + "type": "string", + "default": "", + "required": "yes" + }, { + "key": "zk_node", + "label": "ZooKeeper Node", + "description": "role-based node properties", + "type": "array", + "properties": [{ + "key": "cpu", + "label": "CPU", + "description": "CPUs of each node", + "type": "integer", + "default": 1, + "range": [ + 1, + 2, + 4, + 8 + ], + "required": "yes" + }, { + "key": "memory", + "label": "Memory", + "description": "memory of each node (in MiB)", + "type": "integer", + "default": 2048, + "range": [ + 1024, + 2048, + 4096, + 8192, + 16384, + 32768 + ], + "required": "yes" + }, { + "key": "instance_class", + "label": "Instance Class", + "description": "The instance type for the cluster to run,such as high performance,high performance plus", + "type": "integer", + "default": 0, + "range": [0, 1], + "required": "yes" + }, { + "key": "count", + "label": "Node Count", + "description": "Number of nodes for the cluster to create", + "type": "integer", + "default": 3, + "range": [ + 1, + 3, + 5, + 7, + 9 + ], + "required": "yes" + }, { + "key": "volume_size", + "label": "Volume Size", + "description": "The volume size for each node", + "type": "integer", + "default": 10, + "required": "yes" + }] + }] + }] +} diff --git a/3.4.9/locale/en.json b/3.4.9/locale/en.json new file mode 100644 index 0000000..fe90c57 --- /dev/null +++ b/3.4.9/locale/en.json @@ -0,0 +1,36 @@ +{ + "Name": "Name", + "Description": "Description", + "The name of the ZooKeeper service": "The name of the ZooKeeper service", + "The description of the ZooKeeper service": "The description of the ZooKeeper service", + "VxNet": "VxNet", + "Choose a vxnet to join": "Choose a vxnet to join", + "CPU": "CPU", + "CPUs of each node": "CPUs of each node", + "Memory": "Memory", + "Memory of each node (in MiB)": "Memory of each node (in MiB)", + "Volume Size": "Volume Size", + "Instance Class": "Instance Class", + "The volume size for each node": "The volume size for each node", + "ZooKeeper Node": "ZooKeeper Node", + "Node Count": "Node Count", + "count": "count", + "znode_count": "count", + "Number of nodes for the cluster to create": "Number of nodes for the cluster to create", + "instance class": "instance class", + "The instance type for the cluster to run, such as high performance, high performance plus": "The instance type for the cluster to run, such as high performance, high performance plus", + "zk_node": "zk_node", + "latency": "latency", + "throughput": "throughput", + "connections": "connections", + "znode": "znode", + "mode": "mode (L:Leader,F:Flower,S:Standalone)", + "min": "min", + "avg": "avg", + "max": "max", + "received": "received", + "sent": "sent", + "active": "active", + "outstanding": "outstanding" +} + diff --git a/3.4.9/locale/zh-cn.json b/3.4.9/locale/zh-cn.json new file mode 100644 index 0000000..e02f0a7 --- /dev/null +++ b/3.4.9/locale/zh-cn.json @@ -0,0 +1,37 @@ +{ + "Name": "名称", + "Description": "描述", + "The name of the ZooKeeper service": "ZooKeeper 服务名称", + "The description of the ZooKeeper service": "ZooKeeper 服务描述", + "VxNet": "私有网络", + "Choose a vxnet to join": "选择要加入的私有网络", + "CPU": "CPU", + "CPUs of each node": "每个节点的 CPU 数量", + "Memory": "内存", + "Memory of each node (in MiB)": "每个节点的内存数量(单位:MiB)", + "Instance Class": "主机类型", + "ZooKeeper Node": "ZooKeeper 节点", + "Node Count": "节点数量", + "count": "次", + "znode_count": "个", + "Number of nodes for the cluster to create": "要创建的节点数量", + "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": "节点实例类型,比如性能型与超高性能型。", + "zk_node": "ZooKeeper 节点", + "latency": "响应延迟时间", + "throughput": "吞吐量", + "connections": "连接数", + "znode": "节点数量", + "mode": "角色 (L:Leader,F:Flower,S:Standalone)", + "min": "最小响应延迟时间", + "avg": "平均响应延迟时间", + "max": "最大响应延迟时间", + "received": "请求接收数", + "sent": "发送响应数", + "active": "活跃连接数", + "outstanding": "待处理连接数", + "client": "客户端" +} + diff --git a/3.4.9/zk-3.4.9.tar.gz b/3.4.9/zk-3.4.9.tar.gz new file mode 100644 index 0000000..d5badba Binary files /dev/null and b/3.4.9/zk-3.4.9.tar.gz differ diff --git a/README.md b/README.md index 1ea61e6..38cfe75 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -# Zookeeper \ No newline at end of file + +# ZooKeeper App + +[QingCloud - Apache ZooKeeper](https://appcenter.qingcloud.com/apps/app-tg3lbp0a) diff --git a/images/ZK.png b/images/ZK.png new file mode 100644 index 0000000..1056226 Binary files /dev/null and b/images/ZK.png differ diff --git a/rest/lib/activation-1.1.jar b/rest/lib/activation-1.1.jar new file mode 100644 index 0000000..53f82a1 Binary files /dev/null and b/rest/lib/activation-1.1.jar differ diff --git a/rest/lib/asm-3.1.jar b/rest/lib/asm-3.1.jar new file mode 100644 index 0000000..8217cae Binary files /dev/null and b/rest/lib/asm-3.1.jar differ diff --git a/rest/lib/grizzly-framework-1.9.8.jar b/rest/lib/grizzly-framework-1.9.8.jar new file mode 100644 index 0000000..91d72ce Binary files /dev/null and b/rest/lib/grizzly-framework-1.9.8.jar differ diff --git a/rest/lib/grizzly-http-1.9.8.jar b/rest/lib/grizzly-http-1.9.8.jar new file mode 100644 index 0000000..7d42f6b Binary files /dev/null and b/rest/lib/grizzly-http-1.9.8.jar differ diff --git a/rest/lib/grizzly-http-servlet-1.9.8.jar b/rest/lib/grizzly-http-servlet-1.9.8.jar new file mode 100644 index 0000000..53512a6 Binary files /dev/null and b/rest/lib/grizzly-http-servlet-1.9.8.jar differ diff --git a/rest/lib/grizzly-portunif-1.9.8.jar b/rest/lib/grizzly-portunif-1.9.8.jar new file mode 100644 index 0000000..d9a8bec Binary files /dev/null and b/rest/lib/grizzly-portunif-1.9.8.jar differ diff --git a/rest/lib/grizzly-rcm-1.9.8.jar b/rest/lib/grizzly-rcm-1.9.8.jar new file mode 100644 index 0000000..4b0ea5b Binary files /dev/null and b/rest/lib/grizzly-rcm-1.9.8.jar differ diff --git a/rest/lib/grizzly-servlet-webserver-1.9.8.jar b/rest/lib/grizzly-servlet-webserver-1.9.8.jar new file mode 100644 index 0000000..b80855a Binary files /dev/null and b/rest/lib/grizzly-servlet-webserver-1.9.8.jar differ diff --git a/rest/lib/grizzly-utils-1.9.8.jar b/rest/lib/grizzly-utils-1.9.8.jar new file mode 100644 index 0000000..eab2a05 Binary files /dev/null and b/rest/lib/grizzly-utils-1.9.8.jar differ diff --git a/rest/lib/ivy-2.2.0.jar b/rest/lib/ivy-2.2.0.jar new file mode 100644 index 0000000..7e73dab Binary files /dev/null and b/rest/lib/ivy-2.2.0.jar differ diff --git a/rest/lib/jackson-core-asl-1.1.1.jar b/rest/lib/jackson-core-asl-1.1.1.jar new file mode 100644 index 0000000..935e2b0 Binary files /dev/null and b/rest/lib/jackson-core-asl-1.1.1.jar differ diff --git a/rest/lib/jaxb-api-2.1.jar b/rest/lib/jaxb-api-2.1.jar new file mode 100644 index 0000000..be3d6dc Binary files /dev/null and b/rest/lib/jaxb-api-2.1.jar differ diff --git a/rest/lib/jaxb-impl-2.1.12.jar b/rest/lib/jaxb-impl-2.1.12.jar new file mode 100644 index 0000000..392e682 Binary files /dev/null and b/rest/lib/jaxb-impl-2.1.12.jar differ diff --git a/rest/lib/jersey-core-1.1.5.1.jar b/rest/lib/jersey-core-1.1.5.1.jar new file mode 100644 index 0000000..91333fc Binary files /dev/null and b/rest/lib/jersey-core-1.1.5.1.jar differ diff --git a/rest/lib/jersey-json-1.1.5.1.jar b/rest/lib/jersey-json-1.1.5.1.jar new file mode 100644 index 0000000..ea65e8a Binary files /dev/null and b/rest/lib/jersey-json-1.1.5.1.jar differ diff --git a/rest/lib/jersey-server-1.1.5.1.jar b/rest/lib/jersey-server-1.1.5.1.jar new file mode 100644 index 0000000..dbcf903 Binary files /dev/null and b/rest/lib/jersey-server-1.1.5.1.jar differ diff --git a/rest/lib/jettison-1.1.jar b/rest/lib/jettison-1.1.jar new file mode 100644 index 0000000..e4e9c8c Binary files /dev/null and b/rest/lib/jettison-1.1.jar differ diff --git a/rest/lib/jsr311-api-1.1.1.jar b/rest/lib/jsr311-api-1.1.1.jar new file mode 100644 index 0000000..ec8bc81 Binary files /dev/null and b/rest/lib/jsr311-api-1.1.1.jar differ diff --git a/rest/lib/servlet-api-2.5.jar b/rest/lib/servlet-api-2.5.jar new file mode 100644 index 0000000..fb52493 Binary files /dev/null and b/rest/lib/servlet-api-2.5.jar differ diff --git a/rest/lib/stax-api-1.0-2.jar b/rest/lib/stax-api-1.0-2.jar new file mode 100644 index 0000000..015169d Binary files /dev/null and b/rest/lib/stax-api-1.0-2.jar differ diff --git a/rest/lib/stax-api-1.0.1.jar b/rest/lib/stax-api-1.0.1.jar new file mode 100644 index 0000000..d9a1665 Binary files /dev/null and b/rest/lib/stax-api-1.0.1.jar differ diff --git a/rest/rest.sh b/rest/rest.sh new file mode 100644 index 0000000..1122d11 --- /dev/null +++ b/rest/rest.sh @@ -0,0 +1,111 @@ +#!/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"` +ZK_HOME="/opt/zookeeper" +ZKREST_HOME="$ZK_HOME"/src/contrib/rest +ZK_DATA="/data/zookeeper" + +if $cygwin +then + # cygwin has a "kill" in the shell itself, gets confused + KILL=/bin/kill +else + KILL=kill +fi + +if [ -z $ZKREST_PIDFILE ] + then ZKREST_PIDFILE=$ZK_DATA/rest_server.pid +fi + +ZKREST_MAIN=org.apache.zookeeper.server.jersey.RestMain + +ZKREST_CONF=$ZKREST_HOME/conf +ZKREST_LOG=$ZK_DATA/logs/zkrest.log + +CLASSPATH="$ZKREST_CONF:$CLASSPATH" + +for i in "$ZKREST_HOME"/*.jar +do + CLASSPATH="$i:$CLASSPATH" +done + +for i in "$ZKREST_HOME"/lib/*.jar +do + CLASSPATH="$i:$CLASSPATH" +done + +for i in "$ZK_HOME"/zookeeper-*.jar +do + CLASSPATH="$i:$CLASSPATH" +done + +for i in "$ZK_HOME"/lib/*.jar +do + CLASSPATH="$i:$CLASSPATH" +done + +case $1 in +start) + echo "Starting ZooKeeper REST Gateway ... " + if [ -f "$ZKREST_PIDFILE" ] + then + if kill -0 `cat $ZKREST_PIDFILE` > /dev/null 2>&1;then + echo "error: rest already running at `cat $ZKREST_PIDFILE`" + exit 0 + fi + else + java -cp "$CLASSPATH" $JVMFLAGS $ZKREST_MAIN >$ZKREST_LOG 2>&1 & + /bin/echo -n $! > "$ZKREST_PIDFILE" + echo STARTED + fi + ;; +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|stop|restart}" >&2 + +esac diff --git a/scripts/check-rest-server.sh b/scripts/check-rest-server.sh new file mode 100644 index 0000000..46759fe --- /dev/null +++ b/scripts/check-rest-server.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +ZOOKEEPER_BIN_PATH="/opt/zookeeper/bin" +ZOOKEEPER_PID_FILE="/data/zookeeper/rest_server.pid" + +"$ZOOKEEPER_BIN_PATH"/zkServer.sh status +if [ $? -ne 0 ] +then + exit 1 # zk server is not running +else + curl http://localhost:9998 + if [ $? -ne 0 ] # zk rest server is not running + then + if [ -f $ZOOKEEPER_PID_FILE ] # zk pid file exists + then + rm $ZOOKEEPER_PID_FILE + fi + "$ZOOKEEPER_BIN_PATH"/rest.sh start + fi +fi + +exit 0 diff --git a/scripts/get-monitor.sh b/scripts/get-monitor.sh new file mode 100644 index 0000000..3db15e2 --- /dev/null +++ b/scripts/get-monitor.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +data=`echo srvr | nc 127.0.0.1 2181` +if [ $? -ne 0 ] +then + exit 1 +fi +mode=`echo "$data" | grep Mode | awk -F':' '{print $2}' | awk '{$1=$1};1'` +latency=`echo "$data" | grep Latency | awk -F':' '{print $2}' | awk '{$1=$1};1'` +min=`echo "$latency" | awk -F'/' '{print $1}' | awk '{$1=$1};1'` +avg=`echo "$latency" | awk -F'/' '{print $2}' | awk '{$1=$1};1'` +max=`echo "$latency" | awk -F'/' '{print $3}' | awk '{$1=$1};1'` +received=`echo "$data" | grep Received | awk -F':' '{print $2}' | awk '{$1=$1};1'` +sent=`echo "$data" | grep Sent | awk -F':' '{print $2}' | awk '{$1=$1};1'` +active=`echo "$data" | grep Connections | awk -F':' '{print $2}' | awk '{$1=$1};1'` +outstanding=`echo "$data" | grep Outstanding | awk -F':' '{print $2}' | awk '{$1=$1};1'` +znode=`echo "$data" | grep count | awk -F':' '{print $2}' | awk '{$1=$1};1'` + +echo "{\"mode\":\"$mode\",\"min\":$min,\"avg\":$avg,\"max\":$max,\"received\":$received, \"sent\":$sent,\"active\":$active,\"outstanding\":$outstanding,\"znode\":$znode}" diff --git a/scripts/purge-data.sh b/scripts/purge-data.sh new file mode 100644 index 0000000..5d47118 --- /dev/null +++ b/scripts/purge-data.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +ZOOKEEPER_DATA_PATH="/data/zookeeper" +ZOOKEEPER_BIN_PATH="/opt/zookeeper/bin" +count=$(ls -l $ZOOKEEPER_DATA_PATH/version-2/snapshot* | wc -l) +if [ $count -gt 3 ]; then + $ZOOKEEPER_BIN_PATH/zkCleanup.sh -n 3 +fi + +exit 0 diff --git a/scripts/zookeeper b/scripts/zookeeper new file mode 100644 index 0000000..7784dc2 --- /dev/null +++ b/scripts/zookeeper @@ -0,0 +1,8 @@ +# crontab entries for zookeeper service + +SHELL=/bin/bash +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +*/10 * * * * root /opt/zookeeper/bin/purge-data.sh >/dev/null 2>&1 +* * * * * root /opt/zookeeper/bin/check-rest-server.sh >/dev/null 2>&1; sleep 30; /opt/zookeeper/bin/check-rest-server.sh >/dev/null 2>&1 +