Skip to content

Commit

Permalink
Upgrade to zk 3.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
hlwanghl committed Feb 27, 2020
1 parent 937aeab commit 4e52e7a
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 161 deletions.
3 changes: 2 additions & 1 deletion ansible/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
- include_role:
name: "{{ name }}"
loop:
- update-apt-sources-1.0.0
- disable-apt-jobs-1.0.0
- disable-motd-1.0.0
- app-agent-1.0.1
- appctl-1.0.7
- appctl-1.0.9
- arping-1.0.0
- caddy-1.0.6
- java-1.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ leavingNodes="$(echo "
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"
DATA_MOUNTS=/data
CLUSTER_ID={{ getv "/cluster/cluster_id" }}
IS_UPGRADING={{ exists "/upgrade-audit/from_app_version" }}
MY_IP={{ getv "/host/ip" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -euo pipefail

cd /opt/zkrest/current
java -cp $(ls zookeeper-*.jar lib/*.jar | xargs | tr ' ' :):/opt/app/conf/zkrest \
java -cp $(echo zookeeper-*.jar lib/*.jar | tr ' ' :):/opt/app/conf/zkrest \
-Xmx90m org.apache.zookeeper.server.jersey.RestMain
127 changes: 37 additions & 90 deletions ansible/roles/zookeeper/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: set vars
set_fact:
zk_version: 3.5.6
zk_version: 3.5.7
zkrest_version: 3.4.14

- name: add the service group
Expand All @@ -19,81 +19,33 @@
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
- name: install zk
include_role:
name: install-1.0.0
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
opts:
pkg_name: zookeeper
pkg_version: "{{ zk_version }}"
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: 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
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:
Expand All @@ -111,6 +63,18 @@
src: roles/{{ role_name }}/files/lib/systemd/system/
dest: /lib/systemd/system/

- name: mask services
systemd:
name: "{{ service_name }}"
enabled: no
masked: yes
state: stopped
loop:
- zookeeper-server
- zookeeper-rest
loop_control:
loop_var: service_name

- name: copy files
copy:
src: files/opt/
Expand All @@ -134,20 +98,3 @@
- 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
2 changes: 1 addition & 1 deletion app/cluster.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"container": {
"type": "kvm",
"zone": "pek3a",
"image": "img-y7gct0gv"
"image": "img-8hrq0dqs"
},
"count": {{cluster.zk_node.count}},
"cpu": {{cluster.zk_node.cpu}},
Expand Down
4 changes: 2 additions & 2 deletions app/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"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, 301],
"default": 101,
"range": [101, 202, 301],
"required": "yes"
}, {
"key": "count",
Expand Down
4 changes: 2 additions & 2 deletions app/locale/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"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 不兼容等原因而导致业务中断!",
"notice_when_upgrade": "升级前请确保所有客户端都已经升级到 3.5.7 或以上版本,否则可能会出现 API 不兼容等原因而导致业务中断!",
"err_code210": "当前无法获取待删除节点的角色,为避免主节点被删除,请稍候重试,并确保集群状态正常并且选中从节点进行删除(可以通过节点的“服务模式”监控项获取主从信息)",
"err_code211": "当前选中的待删除节点可能包含主节点,为避免数据丢失,请选中从节点删除(可以通过节点的“服务模式”监控项获取主从信息)或等节点状态稳定后重试",
"latency": "响应延迟时间",
Expand Down Expand Up @@ -46,7 +46,7 @@
"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 位",
"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 位;默认为 admin,请及时修改",
"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",
Expand Down
74 changes: 10 additions & 64 deletions app/replace_policy.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,29 @@
{
"ap2a": {
"pek3a": {
"instance_class": [{
"src": "0",
"dst": 101
"src": "101",
"dst": 0
}, {
"src": "1",
"dst": 201
}]
},
"ap3a": {
"instance_class": [{
"src": "0",
"dst": 101
}, {
"src": "1",
"dst": 202
"src": "202",
"dst": 1
}]
},
"gd2a": {
"instance_class": [{
"src": "0",
"dst": 101
}, {
"src": "1",
"src": "202",
"dst": 201
}]
},
"gd2b": {
"instance_class": [{
"src": "0",
"dst": 101
}, {
"src": "1",
"src": "202",
"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": {
"ap2a": {
"instance_class": [{
"src": "0",
"dst": 101
}, {
"src": "1",
"dst": 202
"src": "202",
"dst": 201
}]
}
}

0 comments on commit 4e52e7a

Please sign in to comment.