Skip to content

Commit caabb1a

Browse files
charisubai-charisu
charisu
authored andcommitted
modify lib install method and fix mutiple deploy
Change-Id: I58fc32c6a0141dea85c77d49bedab37021196d07
1 parent c984b4f commit caabb1a

22 files changed

+209
-88
lines changed

curve-ansible/README

+37-4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ cluster_map:
7373
如果是多机部署,则需要把internalport和externalport都设置成0。需要注意这里zone的数量要大于等于logicalpools里面指定的zonenum。
7474
logicalpools是逻辑池的列表,除了名字,需要指定它所属的物理池、类型、副本数量、copyset数量zone数量以及scatterwidth。目前的类型
7575
只支持0,page file类型。
76+
如果需要格式化磁盘,则需要额外在group_vars/chunkservers.yml中指定磁盘的列表。比如:
77+
disk_list:
78+
- sda
79+
- sdb
80+
- sdc
81+
group_vars/chunkservers.yml中指定的变量是所有chunkserver共用的,如果某个chunkserver上的磁盘列表跟其他的不一致,则需要在host_vars
82+
中额外给出。比如server.ini中chunkserver是下面三台机器:
83+
[chunkservers]
84+
server1 ansible_ssh_host=10.192.100.1
85+
server2 ansible_ssh_host=10.192.100.2
86+
server3 ansible_ssh_host=10.192.100.3
87+
假设server1和server2对应的都是sda,sdb,sdc, server3使用的是sda,sdb,sdd,sde这四块盘。那么server1和server2的disk_list不需要在host_vars
88+
额外指出,而server3的disk_list需要额外指出。具体做法是在host_vars下面新建一个server3.yml。
89+
里面的内容为:
90+
disk_list:
91+
- sda
92+
- sdb
93+
- sdd
94+
- sde
7695

7796
1.1 部署etcd
7897
部署命令:
@@ -204,15 +223,19 @@ curve-sdk主要给cinder,nova等服务使用,只需要更新包和配置即
204223
│   └── wait_copysets_status_healthy.yml # 在一段时间内循环检查copyset健康状态
205224
│   ├── wait_until_server_down.yml # 等待直到server停掉
206225
│   └── wait_until_server_up.yml # 等待直到server起来
207-
├── roles # roles也是用来存放可以复用的代码,一个role内的task存在关联
208226
├── group_vars # 组变量
209227
│   ├── all.yml # 属于所有host的变量
228+
│   ├── chunkservers.yml # 属于chunkserver的变量
210229
│   └── mds.yml # 属于mds的变量
230+
├── host_vars # 主机变量, 其中的文件名要合inventory中定义的主机名一致
231+
│   └── localhost.yml # 属于localhost的变量,host_vars优先级高于group_vars
232+
├── roles # roles也是用来存放可以复用的代码,一个role内的task存在关联
211233
│   ├── format_chunkserver # 用来格式化chunkserver的role
212234
│   │   ├── defaults
213235
│   │   │   └── main.yml # 存放带默认值的变量
214236
│   │   └── tasks
215237
│   │   ├── include
238+
│   │   │   ├── prepare_chunkserver_with_disk_format.yml # 使用格式化磁盘的方式准备data目录
216239
│   │   │   └── prepare_chunkserver_without_disk_format.yml # 使用非格式化磁盘的方式准备data目录
217240
│   │   └── main.yml
218241
│   ├── restart_service # 用来重启服务的role
@@ -241,19 +264,25 @@ curve-sdk主要给cinder,nova等服务使用,只需要更新包和配置即
241264
│   │   │   │   ├── install_curve-mds.yml # 安装mds
242265
│   │   │   │   ├── install_curve-nbd.yml # 安装nbd
243266
│   │   │   │   ├── install_curve-sdk.yml # 安装curve-sdk
267+
│   │   │   │   ├── install_curve-snapshotcloneserver-nginx.yml # 安装快照克隆使用的Nginx
268+
│   │   │   │   ├── install_curve-snapshotcloneserver.yml # 部署快照克隆
244269
│   │   │   │   ├── install_curve-tools.yml # 安装部署工具
270+
│   │   │   │   ├── install_daemon.yml # 安装daemon
245271
│   │   │   │   ├── install_deb_package.yml # 安装debian包
246272
│   │   │   │   ├── install_etcd.yml # 安装etcd
273+
│   │   │   │   ├── install_jemalloc.yml # 安装jemalloc
247274
│   │   │   │   ├── install_libuuid.yml # 安装libuuid
248-
│   │   │   │   ├── install_lib_with_source_code.yml # 从源码安装库
275+
│   │   │   │   └── install_with_yum_apt.yml # 用apt或yum的方式安装
276+
│   │   │   │   ├── install_with_source_code.yml # 从源码安装
249277
│   │   │   │   └── install_nebd.yml # 安装nebd
250278
│   │   │   └── main.yml
251279
│   │   ├── templates # 存放模板
252280
│   │   │   ├── chunkserver_ctl.sh.j2 # chunkserver启动脚本的模板
253281
│   │   │   ├── chunkserver_deploy.sh.j2 # chunkserver格式化脚本的模板
254282
│   │   │   ├── etcd-daemon.sh.j2 # etcd启动脚本的模板
255283
│   │   │   ├── mds-daemon.sh.j2 # mds启动脚本的模板
256-
│   │   │   └── nebd-daemon.j2 # nebd-server启动脚本的模板
284+
│   │   │   ├── nebd-daemon.j2 # nebd-server启动脚本的模板
285+
│   │   │   └── snapshot-daemon.sh.j2 # 快照克隆启动脚本模板
257286
│   │   └── vars
258287
│   │   └── main.yml
259288
│   ├── set_leader_and_follower_list # 设置leader和follower列表
@@ -292,7 +321,9 @@ curve-sdk主要给cinder,nova等服务使用,只需要更新包和配置即
292321
│   │   │   ├── start_chunkserver.yml # 启动chunkserver
293322
│   │   │   ├── start_etcd.yml # 启动etcd
294323
│   │   │   ├── start_mds.yml # 启动mds
295-
│   │   │   └── start_nebd.yml # 启动nebd
324+
│   │   │   ├── start_nebd.yml # 启动nebd
325+
│   │   │   ├── start_snapshotcloneserver_nginx.yml # 启动Nginx
326+
│   │   │   └── start_snapshotcloneserver.yml # 启动快照克隆
296327
│   │   └── main.yml
297328
│   └── vars
298329
│   └── main.yml
@@ -312,6 +343,8 @@ curve-sdk主要给cinder,nova等服务使用,只需要更新包和配置即
312343
├── deploy_mds.yml # 部署mds
313344
├── deploy_nbd.yml # 部署nbd
314345
├── deploy_nebd.yml # 部署nebd
346+
├── deploy_snapshotcloneserver_nginx.yml # 部署快照克隆所用Nginx
347+
├── deploy_snapshotcloneserver.yml # 部署快照克隆
315348
├── README # 本帮助文档
316349
├── client.ini # client的inventory文件
317350
└── server.ini # server的列表,包括mds,快照克隆,etcd,chunkserver

curve-ansible/client.ini

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ curve_include_dir=/usr/include
3232
curvefs_dir=/usr/curvefs
3333
ansible_ssh_port=22
3434
lib_install_prefix=/usr/local
35+
bin_install_prefix=/usr

curve-ansible/deploy_curve.yml

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
#
1717
# The deploy playbook of Curve
1818

19+
# 检查ansible版本
20+
- name: Stop if ansible version not match, make sure that the Ansible version is Ansible 2.5.9
21+
hosts: localhost
22+
gather_facts: no
23+
tasks:
24+
- assert:
25+
that:
26+
- ansible_version.full|version_compare('2.5.9', '==')
27+
1928
# 部署curve集群
2029

2130
- name: deploy etcd

curve-ansible/roles/install_package/tasks/include/determine_if_lib_installed.yml curve-ansible/group_vars/chunkservers.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
- name: determine if lib installed
19-
ignore_errors: true
20-
shell: /sbin/ldconfig -p | grep {{ lib_name }}
21-
register: ldconfig_res
22-
23-
- name: set lib_installed
24-
set_fact:
25-
lib_installed: true
26-
when: ldconfig_res.stdout != ""
18+
disk_list:
19+
- sda
20+
- sdb
21+
- sdc

curve-ansible/group_vars/mds.yml

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
---
2+
#
3+
# Copyright (c) 2020 NetEase Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
217

318
# 集群拓扑信息
419
cluster_map:

curve-ansible/host_vars/localhost.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
#
3+
# Copyright (c) 2020 NetEase Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
disk_list:
19+
- sda
20+
- sdb
21+
- sdc
22+
- sdd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
#
3+
# Copyright (c) 2020 NetEase Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
- name: deploy chunkserver with format disk
19+
shell: sudo ./chunkserver_ctl.sh deploy all --noConfirm
20+
async: 0
21+
poll: 3

curve-ansible/roles/format_chunkserver/tasks/main.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
#
1717

1818
- name: deploy chunkserver with format disk
19-
shell: sudo ./chunkserver_ctl.sh deploy all --noConfirm
20-
async: 0
21-
poll: 3
19+
include_tasks: "include/prepare_chunkserver_with_disk_format.yml"
2220
when: chunkserver_format_disk
2321

2422
- name: deploy chunkserver without format disk

curve-ansible/roles/install_package/defaults/main.yml

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ etcd_download_dir: /tmp
4444
install_etcd_dir: /usr/bin
4545

4646
download_dir: /tmp
47-
libunwind_download_url: http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
4847
jemalloc_download_url: https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2
4948
lib_install_prefix: /usr/local
50-
libnl_download_url: http://www.infradead.org/~tgr/libnl/files/libnl-3.2.25.tar.gz
5149
daemon_download_url: http://libslack.org/daemon/download/daemon-0.6.4.tar.gz

curve-ansible/roles/install_package/tasks/include/install_curve-chunkserver.yml

+17-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,28 @@
1717

1818
- name: install libunwind
1919
vars:
20-
lib_name: libunwind
21-
download_url: "{{ libunwind_download_url }}"
22-
include_tasks: install_lib_with_source_code.yml
20+
apt_lib_name: libunwind8 libunwind8-dev
21+
yum_lib_name: libunwind libunwind-devel
22+
include_tasks: install_with_yum_apt.yml
23+
24+
- name: install bzip2
25+
vars:
26+
apt_lib_name: bzip2
27+
yum_lib_name: bzip2
28+
include_tasks: install_with_yum_apt.yml
2329

2430
- name: install jemalloc
2531
vars:
2632
lib_name: jemalloc
2733
download_url: "{{ jemalloc_download_url }}"
28-
include_tasks: install_lib_with_source_code.yml
34+
include_tasks: install_jemalloc.yml
35+
36+
- name: install psmisc
37+
vars:
38+
apt_lib_name: psmisc
39+
yum_lib_name: psmisc
40+
include_tasks: install_with_yum_apt.yml
41+
when: chunkserver_format_disk
2942

3043
- name: install chunkserver bin
3144
vars:

curve-ansible/roles/install_package/tasks/include/install_curve-mds.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
- name: install libunwind
1919
vars:
20-
lib_name: libunwind
21-
download_url: "{{ libunwind_download_url }}"
22-
include_tasks: install_lib_with_source_code.yml
20+
apt_lib_name: libunwind8 libunwind8-dev
21+
yum_lib_name: libunwind libunwind-devel
22+
include_tasks: install_with_yum_apt.yml
2323

2424
- name: install libuuid
25-
include_tasks: install_libuuid.yml
25+
vars:
26+
apt_lib_name: libunwind8 uuid-dev
27+
yum_lib_name: libunwind libuuid-devel
28+
include_tasks: install_with_yum_apt.yml
2629

2730
- name: install daemon
2831
include_tasks: install_daemon.yml

curve-ansible/roles/install_package/tasks/include/install_curve-nbd.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
- name: install libunwind
1919
vars:
20-
lib_name: libunwind
21-
download_url: "{{ libunwind_download_url }}"
22-
include_tasks: install_lib_with_source_code.yml
20+
apt_lib_name: libunwind8 libunwind8-dev
21+
yum_lib_name: libunwind libunwind-devel
22+
include_tasks: install_with_yum_apt.yml
2323

2424
- name: install libnl
2525
vars:
26-
lib_name: libnl-3
27-
download_url: "{{ libnl_download_url}}"
28-
include_tasks: install_lib_with_source_code.yml
26+
apt_lib_name: libnl-3-dev libnl-genl-3-dev
27+
yum_lib_name: libnl3 libnl3-devel
28+
include_tasks: install_with_yum_apt.yml
2929

3030
- name: install nbd bin
3131
vars:

curve-ansible/roles/install_package/tasks/include/install_curve-sdk.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
- name: install libunwind
1919
vars:
20-
lib_name: libunwind
21-
download_url: "{{ libunwind_download_url }}"
22-
include_tasks: install_lib_with_source_code.yml
20+
apt_lib_name: libunwind8 libunwind8-dev
21+
yum_lib_name: libunwind libunwind-devel
22+
include_tasks: install_with_yum_apt.yml
2323

2424
- name: install curve-sdk bin
2525
vars:

curve-ansible/roles/install_package/tasks/include/install_curve-snapshotcloneserver.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
- name: install libunwind
1919
vars:
20-
lib_name: libunwind
21-
download_url: "{{ libunwind_download_url }}"
22-
include_tasks: install_lib_with_source_code.yml
20+
apt_lib_name: libunwind8 libunwind8-dev
21+
yum_lib_name: libunwind libunwind-devel
22+
include_tasks: install_with_yum_apt.yml
2323

2424
- name: install libuuid
25-
include_tasks: install_libuuid.yml
25+
vars:
26+
apt_lib_name: libunwind8 uuid-dev
27+
yum_lib_name: libunwind libuuid-devel
28+
include_tasks: install_with_yum_apt.yml
2629

2730
- name: install daemon
2831
include_tasks: install_daemon.yml

curve-ansible/roles/install_package/tasks/include/install_daemon.yml

+1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
- name: install lib if not installed
2929
vars:
3030
download_url: "{{ daemon_download_url }}"
31+
prefix: "{{ bin_install_prefix }}"
3132
include_tasks: install_with_source_code.yml
3233
when: not daemon_installed

curve-ansible/roles/install_package/tasks/include/install_lib_with_source_code.yml curve-ansible/roles/install_package/tasks/include/install_jemalloc.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@
1515
# limitations under the License.
1616
#
1717

18-
- name: determine if lib installed
18+
- name: determine if jemalloc installed
1919
ignore_errors: true
20-
shell: /sbin/ldconfig -p | grep {{ lib_name }}
21-
register: ldconfig_res
20+
shell: ls {{ lib_install_prefix }}/lib | grep jemalloc
21+
register: ls_res
2222

2323
- name: set lib_installed true
2424
set_fact:
2525
lib_installed: true
26-
when: ldconfig_res.stdout != ""
26+
when: ls_res.stdout != ""
2727

2828
- name: set lib_installed false
2929
set_fact:
3030
lib_installed: false
31-
when: ldconfig_res.stdout == ""
31+
when: ls_res.stdout == ""
3232

3333
- name: install lib if not installed
34+
vars:
35+
prefix: "{{ lib_install_prefix }}"
36+
lib_name: jemalloc
3437
include_tasks: install_with_source_code.yml
3538
when: not lib_installed

curve-ansible/roles/install_package/tasks/include/install_nebd.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@
1717

1818
- name: install libunwind
1919
vars:
20-
lib_name: libunwind
21-
download_url: "{{ libunwind_download_url }}"
22-
include_tasks: install_lib_with_source_code.yml
20+
apt_lib_name: libunwind8 libunwind8-dev
21+
yum_lib_name: libunwind libunwind-devel
22+
include_tasks: install_with_yum_apt.yml
23+
24+
- name: install bzip2
25+
vars:
26+
apt_lib_name: bzip2
27+
yum_lib_name: bzip2
28+
include_tasks: install_with_yum_apt.yml
2329

2430
- name: install jemalloc
2531
vars:
2632
lib_name: jemalloc
2733
download_url: "{{ jemalloc_download_url }}"
28-
include_tasks: install_lib_with_source_code.yml
34+
include_tasks: install_jemalloc.yml
2935

3036
- name: install daemon
3137
include_tasks: install_daemon.yml

0 commit comments

Comments
 (0)