Skip to content

Commit 55cecca

Browse files
committed
fix: ansible deploy mutiple machine
1 parent a60bbd4 commit 55cecca

20 files changed

+93
-146
lines changed

conf/chunkserver.conf.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ clone.thread_num=10
107107
# 克隆的队列深度
108108
clone.queue_depth=6000
109109
# curve用户名
110-
curve.root_username=root
110+
curve.root_username=xxx
111111
# curve密码
112-
curve.root_password=root_password
112+
curve.root_password=xxx
113113
# client配置文件
114114
curve.config_path=conf/cs_client.conf
115115
# s3配置文件

conf/mds.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ mds.file.scanIntevalTimeUs=500000
113113
# auth settings
114114
#
115115
# root用户密码
116-
mds.auth.rootUserName=root
117-
mds.auth.rootPassword=root_password
116+
mds.auth.rootUserName=xxx
117+
mds.auth.rootPassword=xxx
118118

119119
#
120120
# file lock setting

conf/snapshot_clone_server.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# client配置文件位置
55
client.config_path=conf/cs_client.conf
66
# mds root 用户名
7-
mds.rootUser=root
7+
mds.rootUser=xxx
88
# mds root 密码
9-
mds.rootPassword=root_password
9+
mds.rootPassword=xxx
1010
# 调用client方法的重试总时间
1111
client.methodRetryTimeSec=300
1212
# 调用client方法重试间隔时间

curve-ansible/common_tasks/wait_until_server_down.yml

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

1818
- name: wait until server is down
1919
wait_for:
20+
host: "{{ ansible_ssh_host }}"
2021
port: "{{ ping_port }}"
2122
state: stopped
2223
msg: "the server {{ ansible_host }}:{{ ping_port }} is down"

curve-ansible/common_tasks/wait_until_server_up.yml

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

1818
- name: wait until server is up
1919
wait_for:
20+
host: "{{ ansible_ssh_host }}"
2021
port: "{{ ping_port }}"
2122
state: started
2223
timeout: "{{ wait_service_timeout }}"

curve-ansible/deploy_snapshotcloneserver.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
tags:
2828
- prepare
2929
roles:
30-
- { role: install_package, package_name: snapshotcloneserver, package_version: "{{ snapshot_package_version }}",
30+
- { role: install_package, package_name: curve-snapshotcloneserver, package_version: "{{ snapshot_package_version }}",
3131
tags: ["install_package", "install_snap_package"] }
3232
- { role: install_package, package_name: aws-sdk, package_version: "{{ aws_package_version }}",
3333
tags: ["install_package", "install_aws_sdk_package"] }

curve-ansible/deploy_snapshotcloneserver_nginx.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
tags:
2828
- prepare
2929
roles:
30-
- { role: install_package, package_name: snapshotcloneserver_nginx,
30+
- { role: install_package, package_name: curve-snapshotcloneserver-nginx,
3131
tags: ["install_conf_package", "install_snapshotclone_nginx_conf_package"] }
3232
- { role: generate_config, template_name: nginx.conf, conf_path: "{{ snapshot_nginx_conf_path }}",
3333
tags: ["generate_config", "generate_snap_nginx_conf"] }

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#
1717

1818
# 通用配置
19-
curve_root_username: root
20-
curve_root_password: root_password
19+
curve_root_username: xxx
20+
curve_root_password: xxx
2121
chunk_size: 16777216
2222
file_expired_time_us: 5000000
2323

@@ -104,8 +104,6 @@ chunkserver_copyset_load_concurrency: 10
104104
chunkserver_copyset_check_retrytimes: 3
105105
chunkserver_copyset_finishload_margin: 2000
106106
chunkserver_copyset_check_loadmargin_interval_ms: 1000
107-
chunkserver_clone_disable_curve_client: false
108-
chunkserver_clone_disable_s3_adapter: false
109107
chunkserver_clone_slice_size: 1048576
110108
chunkserver_clone_enable_paste: false
111109
chunkserver_clone_thread_num: 10

curve-ansible/roles/generate_config/templates/chunkserver.conf.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ copyset.check_loadmargin_interval_ms={{ chunkserver_copyset_check_loadmargin_int
100100
# Clone settings
101101
#
102102
# 禁止使用curveclient
103-
clone.disable_curve_client={{ chunkserver_clone_disable_curve_client }}
103+
clone.disable_curve_client={{ disable_snapshot_clone }}
104104
# 禁止使用s3adapter
105-
clone.disable_s3_adapter={{ chunkserver_clone_disable_s3_adapter }}
105+
clone.disable_s3_adapter={{ disable_snapshot_clone }}
106106
# 克隆的分片大小,一般1MB
107107
clone.slice_size={{ chunkserver_clone_slice_size }}
108108
# 读clone chunk时是否需要paste到本地

curve-ansible/roles/install_package/templates/chunkserver_deploy.sh.j2

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
#confirm提示,防止误操作
3+
dataDir={{ chunkserver_data_dir }}
34
function do_confirm {
45
echo "This deployment script will format the disk and delete all the data."
56
echo "Please confirm that you want to do this action!"
@@ -19,7 +20,7 @@ function deploy_prep {
1920
if [ $? -eq 0 ]
2021
then
2122
sed -i '/curvefs/d' /etc/fstab
22-
sed -i '/\/data\/chunkserver/d' /etc/fstab
23+
sed -i '/chunkserver/d' /etc/fstab
2324
fi
2425
#通过lsscsi的输出过滤出curve使用的数据盘,将数据盘挂载的目录都卸载掉,为下一步格式化磁盘做准备
2526
for i in `lsscsi |grep ATA|awk '{print $7}'|awk -F"/" '{print $3}'`
@@ -41,7 +42,6 @@ function deploy_prep {
4142
}
4243
{% raw %}
4344
#记录磁盘的盘符信息和磁盘的wwn信息,将信息持久化到diskinfo文件
44-
DATA_DIR=/data
4545
declare -A disk_map
4646
diskinfo=./diskinfo
4747
function record_diskinfo {
@@ -61,23 +61,23 @@ function record_diskinfo {
6161
done
6262
}
6363

64-
#根据磁盘数量创建数据目录和日志目录,目前的数据目录格式统一是/data/chunkserver+num,日志目录在/data/log/chunkserver+num
64+
#根据磁盘数量创建数据目录和日志目录,目前的数据目录格式统一是$dataDir/chunkserver+num,日志目录在$dataDir/log/chunkserver+num
6565
function chunk_dir_prep {
66-
if [ -d ${DATA_DIR} ]
66+
if [ -d ${dataDir} ]
6767
then
68-
rm -rf ${DATA_DIR}
68+
rm -rf ${dataDir}/chunkserver*
6969
if [ $? -ne 0 ]
7070
then
71-
echo "rm $DATA_DIR failed"
71+
echo "rm $dataDir failed"
7272
exit
7373
fi
7474
fi
75-
mkdir -p ${DATA_DIR}
75+
mkdir -p ${dataDir}
7676
echo $((${#disk_map[@]}-1))
7777
for i in `seq 0 $((${#disk_map[@]}-1))`
7878
do
79-
mkdir -p ${DATA_DIR}/chunkserver$i
80-
mkdir -p ${DATA_DIR}/log/chunkserver$i
79+
mkdir -p ${dataDir}/chunkserver$i
80+
mkdir -p ${dataDir}/log/chunkserver$i
8181
done
8282
}
8383
{% endraw %}
@@ -107,7 +107,7 @@ function mount_dir {
107107
j=0
108108
for i in `cat $diskinfo |awk '{print $1}'|awk -F":" '{print $2}'`
109109
do
110-
mount /dev/$i $DATA_DIR/chunkserver$j
110+
mount /dev/$i $dataDir/chunkserver$j
111111
if [ $? -ne 0 ]
112112
then
113113
echo "mount $i failed"
@@ -137,7 +137,7 @@ function meta_record {
137137
grep curvefs /etc/fstab
138138
if [ $? -eq 0 ]
139139
then
140-
for i in `cat /etc/fstab | grep "/data/chunkserver" | awk '{print $1 $2}' | awk -F '=' '{print $2}'`
140+
for i in `cat /etc/fstab | grep "$dataDir/chunkserver" | awk '{print $1 $2}' | awk -F '=' '{print $2}'`
141141
do
142142
uuid=`echo $i | awk -F / '{print $1}'`
143143
uuidmd5=`echo -n $uuid | md5sum | cut -d ' ' -f1`
@@ -155,9 +155,9 @@ ret=`lsblk|grep chunkserver|wc -l`
155155
for i in `seq 0 $((${ret}-1))`
156156
do
157157
curve-format -allocatepercent={{ chunk_alloc_percent }} \
158-
-chunkfilepool_dir=/data/chunkserver$i/chunkfilepool \
159-
-chunkfilepool_metapath=/data/chunkserver$i/chunkfilepool.meta \
160-
-filesystem_path=/data/chunkserver$i/chunkfilepool &
158+
-chunkfilepool_dir=$dataDir/chunkserver$i/chunkfilepool \
159+
-chunkfilepool_metapath=$dataDir/chunkserver$i/chunkfilepool.meta \
160+
-filesystem_path=$dataDir/chunkserver$i/chunkfilepool &
161161
done
162162
wait
163163
}
@@ -168,7 +168,7 @@ function usage {
168168
echo " or deploy one disk by setting the diskname"
169169
echo "Example:"
170170
echo " ./chunkserver_deploy2.sh all"
171-
echo " ./chunkserver_deploy2.sh /dev/sd{id} /data/chunkserver{id}"
171+
echo " ./chunkserver_deploy2.sh /dev/sd{id} $dataDir/chunkserver{id}"
172172
exit
173173
}
174174

curve-ansible/rolling_update_snapshotclone.yml

+13-27
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,25 @@
1818

1919
# 滚动升级snapshotclone
2020

21-
# 1. 更新各节点上的配置
22-
- name: update config
21+
# 1、准备包和配置
22+
- name: prepare snapshotcloneserver
2323
hosts: snapshotclone
24-
gather_facts: no
2524
any_errors_fatal: true
26-
become: true
27-
become_user: "{{ sudo_user }}"
28-
become_flags: -iu {{ sudo_user }}
29-
tags:
30-
- update_config
31-
roles:
32-
- { role: generate_config, template_name: snapshot_clone_server.conf, conf_path: "{{ snapshot_config_path }}" }
33-
- { role: generate_config, template_name: s3.conf, conf_path: "{{ snap_s3_config_path }}" }
34-
- { role: generate_config, template_name: client.conf, conf_path: "{{ snap_client_config_path }}" }
35-
- { role: generate_config, template_name: snapshot_tools.conf, conf_path: "{{ snap_tool_config_path }}" }
36-
37-
# 2. 更新各节点上的包和配置
38-
- name: update package
39-
hosts: snapshotclone
4025
gather_facts: no
41-
any_errors_fatal: true
42-
become: true
26+
become: yes
4327
become_user: "{{ sudo_user }}"
4428
become_flags: -iu {{ sudo_user }}
4529
tags:
46-
- update_package
47-
48-
tasks:
49-
- vars:
50-
update_component: "curve-snapshotcloneserver={{ snap_package_version }}"
51-
include_tasks: "common_tasks/update_package.yml"
30+
- prepare
31+
roles:
32+
- { role: install_package, package_name: curve-snapshotcloneserver, package_version: "{{ snapshot_package_version }}",
33+
tags: ["install_package", "install_snap_package"] }
34+
- { role: generate_config, template_name: snapshot_clone_server.conf, conf_path: "{{ snapshot_config_path }}",
35+
tags: ["generate_config", "generate_snap_conf"] }
36+
- { role: generate_config, template_name: client.conf, conf_path: "{{ snap_client_config_path }}",
37+
tags: ["generate_config", "generate_snap_client_conf"] }
5238

53-
# 3. 获取leader节点和follower节点
39+
# 2. 获取leader节点和follower节点
5440
- name: set leader and follower list
5541
hosts: snapshotclone
5642
gather_facts: no
@@ -60,7 +46,7 @@
6046
roles:
6147
- { role: set_leader_and_follower_list, service_name: snapshot }
6248

63-
# 4. 按顺序先升级follower节点,再升级leader节点
49+
# 3. 按顺序先升级follower节点,再升级leader节点
6450
- name: update follower and leader server in sequence
6551
hosts: snapshot_servers_followers, snapshot_servers_leader
6652
any_errors_fatal: true

curve-ansible/server.ini

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
localhost ansible_ssh_host=127.0.0.1
44

55
[etcd]
6-
localhost ansible_ssh_host=127.0.0.1
6+
localhost ansible_ssh_host=127.0.0.1 etcd_name=etcd1
77

88
[snapshotclone]
99
localhost ansible_ssh_host=127.0.0.1
@@ -15,7 +15,6 @@ localhost ansible_ssh_host=127.0.0.1
1515
localhost ansible_ssh_host=127.0.0.1
1616

1717
[mds:vars]
18-
ansible_ssh_port=1046
1918
mds_dummy_port=6667
2019
mds_port=6666
2120
mds_subnet=127.0.0.1/22
@@ -30,7 +29,6 @@ mds_log_dir=/data/log/curve/mds
3029
topo_file_path=/etc/curve/topo.json
3130

3231
[etcd:vars]
33-
ansible_ssh_port=1046
3432
etcd_listen_client_port=2379
3533
etcd_listen_peer_port=2380
3634
etcd_name="etcd"
@@ -40,13 +38,12 @@ etcd_config_path=/etc/curve/etcd.conf.yml
4038
etcd_log_dir=/data/log/curve/etcd
4139

4240
[snapshotclone:vars]
43-
ansible_ssh_port=1046
4441
snapshot_port=5556
4542
snapshot_dummy_port=8081
4643
snapshot_subnet=127.0.0.1/22
4744
defined_healthy_status="cluster is healthy"
4845
snapshot_package_version="0.0.6.1.1+7af4d6a4"
49-
snapshot_need_sudo=false
46+
snapshot_need_sudo=true
5047
snapshot_config_path=/etc/curve/snapshot_clone_server.conf
5148
snap_s3_config_path=/etc/curve/s3.conf
5249
snap_client_config_path=/etc/curve/snap_client.conf
@@ -57,13 +54,10 @@ client_chunkserver_max_rpc_timeout_ms=16000
5754
client_chunkserver_max_stable_timeout_times=64
5855
client_turn_off_health_check=false
5956
snapshot_clone_server_log_dir=/data/log/curve/snapshotclone
60-
s3_ak=""
61-
s3_sk=""
6257
aws_package_version="1.0"
6358

6459
[chunkservers:vars]
6560
wait_service_timeout=60
66-
ansible_ssh_port=1046
6761
env_name=pubt1
6862
check_copysets_status_times=1000
6963
check_copysets_status_interval=1
@@ -72,6 +66,7 @@ aws_package_version="1.0"
7266
defined_copysets_status="Copysets are healthy"
7367
chunkserver_base_port=8200
7468
chunkserver_format_disk=false
69+
chunk_alloc_percent=80
7570
# 每台机器上的chunkserver的数量
7671
chunkserver_num=3
7772
chunkserver_need_sudo=true
@@ -90,6 +85,7 @@ client_register_to_mds=false
9085
client_chunkserver_op_max_retry=3
9186
client_chunkserver_max_stable_timeout_times=64
9287
client_turn_off_health_check=false
88+
disable_snapshot_clone=true
9389

9490
[snapshotclone_nginx:vars]
9591
snapshotcloneserver_nginx_dir=/etc/curve/nginx
@@ -102,7 +98,11 @@ nginx_docker_external_port=5555
10298
need_confirm=true
10399
curve_ops_tool_config=/etc/curve/tools.conf
104100
need_update_config=true
105-
mysql_url=localhost
106101
wait_service_timeout=10
107102
sudo_user=curve
108103
deploy_dir=/home/curve
104+
s3_ak=""
105+
s3_sk=""
106+
ansible_ssh_port=22
107+
curve_root_username=xxx
108+
curve_root_password=xxx

docs/cn/deploy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ansible是一款自动化运维工具,curve-ansible 是基于 ansible playbook
3636

3737
1.```root``` 用户登录中控机, 在中控机上创建 ```curve``` 用户, 并生成ssh key
3838

39-
2. 下载tar包 并 解压
39+
2. 下载tar包并解压
4040

4141
```
4242
wget https://github.com/opencurve/curve/releases/download/v0.1.0/curve_0.1.0+0bd75f0a.tar.gz

monitor/grafana/dashboards/chunkserver.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7674,9 +7674,9 @@
76747674
{
76757675
"allValue": "",
76767676
"current": {
7677-
"text": "pubbeta2-curve22.dg.163.org",
7677+
"text": "localhost",
76787678
"value": [
7679-
"pubbeta2-curve22.dg.163.org"
7679+
"localhost"
76807680
]
76817681
},
76827682
"datasource": "Prometheus",

0 commit comments

Comments
 (0)