ceph的设备关系获取

2022/09/09 posted in  ceph统计信息

需求

因为ceph采用的是lvm管理,磁盘对应关系找起来没有以前方便,所以用一个脚本把当前机器的对应关系列出来

实现

[root@node235 ceph]# cat get.sh 
#! /bin/bash
IFS=$'\n\n' 
for osd in `ceph osd dump|grep osd|grep -v req|grep -v max|awk '{print ``1,``19}'`
do 

osdnum=`echo  $osd|awk '{print $1}'`
osdid=`echo  $osd|awk '{print $2}'`
vgname=`lvdisplay |grep $osdid -A 1|tail  -n 1|awk '{print $3}'`
pvname=`pvdisplay |grep $vgname -B1|head -n 1|awk '{print $3}'`

echo $osdnum  $osdid  $vgname  $pvname

done

效果

需要用bash命令运行

[root@node235 ceph]# bash get.sh 
osd.0 c40d9963-4894-42bd-a7a8-c9d8c3280e9f ceph-f0f4f8ce-8d02-4111-97bd-fae7ff20a961 /dev/sdd1
osd.1 c4b7f141-51a0-4b97-80b5-e9681025f7db ceph-f786b5a2-82f4-4086-b0d1-7f5e6787c421 /dev/sdc1
osd.2 24f68dd2-5a4f-4b41-8775-ae0211a06e5d ceph-07e22954-93d0-4bb1-9ce3-59485eab1673 /dev/sdi1
osd.3 deed6a2e-456f-40be-bade-07a4b358e2c1 ceph-f1f76e61-d0d6-447b-ac26-a9a2d7fd2d5d /dev/sds1
osd.4 f325a546-a6c7-4610-9916-31062ec6decc ceph-5c1357a5-036a-4f2e-83a8-4463e4349264 /dev/sdf1
osd.5 3790748f-f212-4d46-8b72-b6c9ba007019 ceph-9874a1ac-9163-4936-a2f9-976260f19d6d /dev/sdr1
osd.6 50140786-a01d-47c4-bca4-68ad7730863c ceph-0e4af92c-9766-467c-a7d5-db4435aadd6b /dev/sdk1
osd.7 5e56f9a0-7637-477a-95cf-b995987e6270 ceph-c0de6d4b-1907-49d7-aa9b-194ccbc72465 /dev/sdb1
osd.8 261ea9d8-581b-42ec-9493-1df7b74394b7 ceph-54946fde-edc4-4cf1-b59a-375d69bfff7a /dev/sdm1
osd.9 a4212438-e463-48f3-be58-7668df524c35 ceph-805428c1-077c-4092-80f5-95b0ac9f5ea5 /dev/sdh1
osd.10 ebfb8caf-a3e6-4715-b992-9ca560104c4e ceph-7e9809bf-c4c0-4686-84f6-4e8639f02dac /dev/sde1
osd.11 7c310379-994d-4faa-9724-1ec1bf6d85bd ceph-3b602d70-99d0-496e-8b96-c34b36d973bc /dev/sdo1
osd.12 cd608ef9-d491-4d09-8f7f-ac82e026b321 ceph-2a8d2275-d307-41ab-9125-17dbe610559a /dev/sdg1
osd.14 782cb3ed-9fcd-40aa-9db3-1cd7babda3fb ceph-9117f02b-c6a0-43a0-ac3f-c0af75381c5f /dev/sdq1
osd.15 77275ae5-d953-44fc-8196-d6b31e005fb3 ceph-c30f789a-3213-49ce-8831-2296e5697119 /dev/sdp1
osd.16 1a325633-209d-4c3a-a89a-c90d6c26688f ceph-397d3bce-9f1a-4e33-9bd0-48f52804a7f6 /dev/sdj1