sh 拆分Ceph Filestore OSD离线

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 拆分Ceph Filestore OSD离线相关的知识,希望对你有一定的参考价值。

#!/bin/bash

merge_num=-2
split_num=16

while [[ "$(ceph health)" != "HEALTH_OK" ]]; do
  sleep 10
done

# Some method to set your ceph.conf file to the subfolder splitting settings you want.
# If you are not changing the ceph.conf settings, then you can start the osd at the end of the loop instead of at the end.
conf=/etc/ceph/ceph.conf
if ! grep -q '^\[global\]' $conf; then
  echo $conf is badly formed
  exit
fi
merge=$(grep -E filestore.merge.threshold $conf)
merge=${merge:-false}
split=$(grep -E filestore.split.multiple $conf)
split=${split:-false}
if [[ "$merge" != false ]]; then
  sudo sed -i "/filestore.merge.threshold/c filestore_merge_threshold = $merge_num" $conf
else
  sudo sed -i "/^\[global\]/a filestore_merge_threshold = $merge_num" $conf
fi
if [[ "$split" != false ]]; then
  sudo sed -i "/filestore.split.multiple/c filestore_split_multiple = $split_num" $conf
else
  sudo sed -i "/^\[global\]/a filestore_split_multiple = $split_num" $conf
fi

ceph osd set noout
#sudo systemctl stop ceph.target && sleep 30
/etc/init.d/ceph stop osd && sleep 30
for osd in $(sudo mount | grep -Eo ceph-[0-9]+ | cut -d- -f2 | sort -nu); do
  for run_in_background in true; do
    echo "Starting osd $osd"
    sudo -u ceph ceph-osd --flush-journal -i=${osd}
    for pool in $(ceph osd lspools | awk 'BEGIN {RS=","} {print $2}'); do
      sudo -u ceph ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-${osd} \
        --journal-path /var/lib/ceph/osd/ceph-${osd}/journal \
        --log-file=/var/log/ceph/objectstore_tool.${osd}.log \
        --op apply-layout-settings \
        --pool $pool \
        --debug
    done
    echo "Finished osd.${osd}"
    # sudo systemctl start ceph-osd@${osd}.service
  done &
done
wait

# set ceph.conf back to normal before starting the OSDs
if [[ "$merge" != false ]]; then
  sudo sed -i "/filestore.merge.threshold/c \\${merge}" $conf
else
  sudo sed -i "/filestore.merge.threshold/d" $conf
fi
if [[ "$split" != false ]]; then
  sudo sed -i "/filestore.split.multiple/c \\${split}" $conf
else
  sudo sed -i "/filestore.merge.multiple/d" $conf
fi
echo starting OSDs
# sudo systemctl start ceph.target
/etc/init.d/ceph start osd 

#while true; do
#  stat=$(ceph osd stat)
#  up=$(echo "$stat" | grep -Eo '[[:digit:]]+\s+up' | awk '{print $1}')
#  in=$(echo "$stat" | grep -Eo '[[:digit:]]+\s+in' | awk '{print $1}')
#  if (( $up == $in )); then
#    ceph tell osd.\* injectargs --osd_max_backfills=1
#    #ceph osd unset noout
#    break
#  else
#    sleep 10
#  fi
#done

以上是关于sh 拆分Ceph Filestore OSD离线的主要内容,如果未能解决你的问题,请参考以下文章

解析CEPH: 存储引擎实现之一 filestore

ceph搭建,动态增加osd,增加的osd状态是down,怎样才能up

影响性能的关键部分-ceph的osd journal写

ceph问题解决运维记录

ceph luminous版部署bluestore

ceph-性能调优