久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

ceph中rbdmap遇到問題的案例分析

174次閱讀
沒有評論

共計 3978 個字符,預計需要花費 10 分鐘才能閱讀完成。

這篇文章將為大家詳細講解有關(guān) ceph 中 rbdmap 遇到問題的案例分析,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

運行于 centos6.5 的 rbdmap:

[root@mon0 ceph]# cat /etc/init.d/rbdmap 
#!/bin/bash
# rbdmap Ceph RBD Mapping
# chkconfig: 2345 70 70
# description: Ceph RBD Mapping
### BEGIN INIT INFO
# Provides: rbdmap
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Should-Start: ceph
# Should-Stop: ceph
# X-Start-Before: $x-display-manager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ceph RBD Mapping
# Description: Ceph RBD Mapping
### END INIT INFO
DESC= RBD Mapping: 
RBDMAPFILE= /etc/ceph/rbdmap 
. /lib/lsb/init-functions
do_map() {if [ ! -f  $RBDMAPFILE  ]; then
 #log_warning_msg  $DESC : No $RBDMAPFILE found. 
 exit 0
 # Read /etc/rbdtab to create non-existant mapping
 RET=0
 while read DEV PARAMS; do
 case  $DEV  in
   |\#*)
 continue
  */*)
  *)
 DEV=rbd/$DEV
 esac
 #log_action_begin_msg  ${DESC}  ${DEV} 
 newrbd= 
 MAP_RV= 
 RET_OP=0
 OIFS=$IFS
 IFS= , 
 for PARAM in ${PARAMS[@]}; do
 CMDPARAMS= $CMDPARAMS --$(echo $PARAM | tr  =    ) 
 done
 IFS=$OIFS
 if [ ! -b /dev/rbd/$DEV ]; then
 MAP_RV=$(rbd map $DEV $CMDPARAMS 2 1)
 if [ $? -eq 0 ]; then
  newrbd= yes 
 else
  RET=$((${RET}+$?))
  RET_OP=1
 #log_action_end_msg ${RET_OP}  ${MAP_RV} 
 if [  $newrbd  ]; then
 ## Mount new rbd
 MNT_RV= 
 mount --fake /dev/rbd/$DEV  /dev/null 2 1 \
  MNT_RV=$(mount -v /dev/rbd/$DEV 2 1)
 [ -n  ${MNT_RV}  ]   log_action_msg  mount: ${MNT_RV} 
 ## post-mapping
 if [ -x  /etc/ceph/rbd.d/${DEV}  ]; then
  #log_action_msg  RBD Running post-map hook  /etc/ceph/rbd.d/${DEV} 
  /etc/ceph/rbd.d/${DEV} map  /dev/rbd/${DEV} 
 done   $RBDMAPFILE
 exit ${RET}
do_unmap() {
 RET=0
 ## Unmount and unmap all rbd devices
 if ls /dev/rbd[0-9]*  /dev/null 2  then
 for DEV in /dev/rbd[0-9]*; do
 ## pre-unmapping
 for L in $(find /dev/rbd -type l); do
  LL= ${L##/dev/rbd/} 
  if [  $(readlink -f $L)  =  ${DEV}  ] \
    [ -x  /etc/ceph/rbd.d/${LL}  ]; then
  log_action_msg  RBD pre-unmap:  ${DEV}  hook  /etc/ceph/rbd.d/${LL} 
  /etc/ceph/rbd.d/${LL} unmap  $L 
  break
  fi
 done
 #log_action_begin_msg  RBD un-mapping:  ${DEV} 
 UMNT_RV= 
 UMAP_RV= 
 RET_OP=0
 MNT=$(findmnt --mtab --source ${DEV} --noheadings | awk  {print $1})
 if [ -n  ${MNT}  ]; then
 # log_action_cont_msg  un-mounting  ${MNT} 
  UMNT_RV=$(umount  ${MNT}  2 1)
 if mountpoint -q  ${MNT}  then
  ## Un-mounting failed.
  RET_OP=1
  RET=$((${RET}+1))
 else
  ## Un-mapping.
  UMAP_RV=$(rbd unmap $DEV 2 1)
  if [ $? -ne 0 ]; then
  RET=$((${RET}+$?))
  RET_OP=1
  fi
 #log_action_end_msg ${RET_OP}  ${UMAP_RV} 
 [ -n  ${UMNT_RV}  ]   log_action_msg  ${UMNT_RV} 
 done
 exit ${RET}

 *) log_success_msg  Usage: rbdmap {start|stop|restart|force-reload|reload|status} exit 1 esac

修改一些在 centos 上沒有的 log 后,這個腳本使用起來還是有問題,具體描述如下:

1. 在只 rbd map 一個塊得到 /dev/rbd0 后,使用 rbdmap 腳本可以正常 map/unmap /dev/rbd0。

2. 當將 /dev/rbd0 格式化后掛載到一個目錄上,再使用 rbdmap,關(guān)機的時候系統(tǒng)就會 hang 在 unmounting filesystem 上了,只能強制斷電;再開機啟動后執(zhí)行了 rbdmap 的 do_map() 函數(shù),一切正常。

排查后發(fā)現(xiàn),當將 /dev/rbd0 掛載到目錄后,rbdmap 就不會執(zhí)行 do_unmap() 函數(shù),即使函數(shù)中加入顯式 umount 操作也不會執(zhí)行。

想了一個折中的辦法,在 rbdmap 停止優(yōu)先級高的服務中的 stop 函數(shù)中顯式加入 umount 操作,重啟時一切正常了。

先來看一下 ceph、rbdmap 的啟停順序:

head rbdmap
#!/bin/bash
# rbdmap Ceph RBD Mapping
# chkconfig: 2345 70 70
# description: Ceph RBD Mapping
head ceph
#!/bin/sh
# Start/stop ceph daemons
# chkconfig: - 60 80
### BEGIN INIT INFO
# Provides: ceph
# Default-Start:
# Default-Stop:
# Required-Start: $remote_fs $named $network $time
# Required-Stop: $remote_fs $named $network $time

可以看出 ceph 先于 rbdmap 啟動,rbdmap 先于 ceph 停止。如果采用 nfs,使用 rbdmap 映射出的塊設(shè)備,先看看 nfs 的啟停順序:

head /etc/init.d/nfs
#!/bin/sh
# nfs This shell script takes care of starting and stopping
# the NFS services.
# chkconfig: - 30 60
# description: NFS is a popular protocol for file sharing across networks.
# This service provides NFS server functionality, which is \
# configured via the /etc/exports file.
# probe: true

nfs 是這三者中最先啟動的,也是最先停止的。所以在 nfs 的 stop 函數(shù)中加入 umount 命令:

umount /mnt/nfs
umount /mnt/nfs2

在 rbdmap 中加入掛載命令:

mount /dev/rbd0 -o rw,noexec,nodev,noatime,nobarrier,discard /mnt/nfs
mount /dev/rbd1 -o rw,noexec,nodev,noatime,nobarrier,discard /mnt/nfs2

/etc/ceph/rbdmap 的設(shè)置如下:

backup1/backup.img
backup2/backup.img

記得在 ceph-0.80 時測試是沒有問題的,到了 0.87.1 出現(xiàn)了上述問題。

關(guān)于“ceph 中 rbdmap 遇到問題的案例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-16發(fā)表,共計3978字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 平泉县| 西青区| 香格里拉县| 新平| 武平县| 塔城市| 黔东| 班玛县| 扎囊县| 靖边县| 合作市| 拜城县| 宜阳县| 宁安市| 青川县| 嘉祥县| 昌平区| 商南县| 余江县| 龙陵县| 义马市| 沁源县| 松滋市| 波密县| 江都市| 昌乐县| 清镇市| 彭阳县| 镇坪县| 独山县| 米易县| 拉萨市| 平安县| 华阴市| 六枝特区| 鄢陵县| 新民市| 固安县| 海原县| 永定县| 葵青区|