Skip to content

Commit

Permalink
ansible: add auto start nebd-server at boot
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanHai authored and ilixiaocui committed May 14, 2021
1 parent 5a4889d commit 4b772c2
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 27 deletions.
2 changes: 2 additions & 0 deletions curve-ansible/client.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ nebd_data_dir=/data/nebd
nebd_log_dir=/data/log/nebd
curve_sdk_log_dir=/data/log/curve
py_client_config_path=/etc/curve/py_client.conf
clean_log_when_clean=false

[mds:vars]
mds_port=6666
Expand All @@ -34,3 +35,4 @@ ansible_connection=local
wait_service_timeout=20
curve_bin_dir=/usr/bin
start_by_daemon=true
install_with_deb=false
26 changes: 0 additions & 26 deletions curve-ansible/release_disk_5%_space.yml

This file was deleted.

15 changes: 15 additions & 0 deletions curve-ansible/roles/clean/tasks/include/clean_nebd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,18 @@
- name: clean nebd log dir
shell: sudo rm -rf {{ nebd_log_dir }}
when: clean_log_when_clean | bool

- name: clean nebd auto start at boot
block:
- name: get distro name
vars:
distro:
include_tasks: common_tasks/get_distro_name.yml
- name: disable on debain ubuntu
shell: sudo update-rc.d -f nebd-daemon remove
when: "'Ubuntu' in distro or 'Debian' in distro"
- name: disable on centos
shell: sudo chkconfig nebd-daemon off && sudo chkconfig --del nebd-daemon
when: "'CentOS' in distro"
- name: remove nebd-daemon in init.d
shell: sudo rm -f /etc/init.d/nebd-daemon
2 changes: 2 additions & 0 deletions curve-ansible/roles/generate_config/templates/tools.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rpcRetryTimes={{ tool_rpc_retry_times }}
{% set _ = etcd_address.append("%s:%s" % (etcd_ip, etcd_port)) -%}
{% endfor -%}
etcdAddr={{ etcd_address | join(',') }}
{% if groups.snapshotclone is defined and groups.snapshotclone[0] is defined %}
# snapshot clone server 地址
{% set snap_address=[] -%}
{% for host in groups.snapshotclone -%}
Expand All @@ -30,3 +31,4 @@ etcdAddr={{ etcd_address | join(',') }}
snapshotCloneAddr={{ snap_address | join(',') }}
# snapshot clone server dummy port
snapshotCloneDummyPort={{ hostvars[groups.snapshotclone[0]].snapshot_dummy_port }}
{% endif -%}
19 changes: 19 additions & 0 deletions curve-ansible/roles/install_package/tasks/include/install_nebd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,22 @@
local_file_path: "/tmp/nebd-daemon"
file_mode: 0755
include_tasks: copy_file_to_remote.yml

- name: add nebd auto start at boot
block:
- name: get distro name
vars:
distro:
include_tasks: common_tasks/get_distro_name.yml
- name: copy nebd-daemon to init.d
vars:
remote_dir_name: "/etc/init.d"
local_file_path: "/tmp/nebd-daemon"
file_mode: 0755
include_tasks: copy_file_to_remote.yml
- name: enable on debain ubuntu
shell: sudo update-rc.d nebd-daemon defaults
when: "'Ubuntu' in distro or 'Debian' in distro"
- name: enable on centos
shell: sudo chkconfig --add nebd-daemon && sudo chkconfig nebd-daemon on
when: "'CentOS' in distro"
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ done
wait
}

function release_disk_reserved_space {
disks=`{{ get_disk_list_cmd }}`
for disk in ${disks}
do
sudo tune2fs -m 0 /dev/$disk
done
}

function deploy_one_walfile_pool {
curve-format -allocatePercent={{ wal_segment_alloc_percent }} \
-filePoolDir=/data/chunkserver$1/walfilepool \
Expand Down Expand Up @@ -210,6 +218,7 @@ function deploy_all {
fstab_record;
meta_record;
chunkfile_pool_prep;
release_disk_reserved_space;
}

function deploy_one {
Expand Down Expand Up @@ -279,5 +288,7 @@ function deploy_one {
-fileSize={{ chunk_size }} \
-fileSystemPath=$dirname/chunkfilepool &
wait
# release disk reserved space
sudo tune2fs -m 0 $diskname
exit
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@

- name: stop nebd without daemon
ignore_errors: true
shell: killall {{ curve_bin_dir }}/nebd-server
shell: {{ sudo }} killall nebd-server
when: not start_by_daemon | bool
11 changes: 11 additions & 0 deletions curve-chunkserver/home/nbs/chunkserver_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ function deploy_one_walfile_pool {
-fileSystemPath=/data/chunkserver$1/walfilepool &
}

function release_disk_reserved_space {
disks=`lsscsi |grep ATA|awk '{print $7}'|awk -F/ '{print $3}'`
for disk in ${disks}
do
sudo tune2fs -m 0 /dev/$disk
done
}

# format walfile pool
function walfile_pool_prep {
ret=`lsblk|grep chunkserver|wc -l`
Expand Down Expand Up @@ -216,6 +224,7 @@ function deploy_all {
fstab_record;
meta_record;
chunkfile_pool_prep;
release_disk_reserved_space;
}

function deploy_one {
Expand Down Expand Up @@ -298,5 +307,7 @@ function deploy_one {
-filePoolMetaPath=$dirname/chunkfilepool.meta \
-fileSystemPath=$dirname/chunkfilepool &
wait
# release disk reserved space
sudo tune2fs -m 0 $diskname
exit
}

0 comments on commit 4b772c2

Please sign in to comment.