通过 by-path 对应 盘符和 OSD_ID

8 篇文章 2 订阅
2 篇文章 0 订阅

当前平台:在K8s上部署了Ceph,由Ceph生成的磁盘用途有两种:缓存盘和数据盘

背景说明:每个数据盘都会对应一个OSD_ID,而缓存盘是一种特殊的数据盘

需求:监控页面需要展示各种用途的磁盘的总容量和已使用量,而数据盘(缓存盘)的OSD_ID和盘符之间的关系,需要通过/dev/disk/by-path/pci××× 来对应

方法:

(1) 获取该节点的所有数据盘和缓存盘pod

[root@node-1 ~]# ds=$(kubectl get ds -n ceph | grep osd | grep $(hostname -s)| awk '{print $1}')
[root@node-1 ~]# echo $ds
ceph-osd-0-node-1 ceph-osd-1-node-1 ceph-osd-2-node-1 ceph-osd-3-node-1 ceph-osd-4-node-1

(2) 获取缓存盘的/dev/disk/by-path路径

[root@node-1 ~]# cache_paths=$(for i in $ds;do kubectl get ds $i -n ceph -o yaml | grep -A1 BLUESTORE_CACHE_DISK| grep value | uniq;done | uniq | awk '{print $2}')
[root@node-1 ~]# echo $cache_paths
/dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:0:0

(3) 获取到该缓存盘的盘符

[root@node-1 ~]# cache_disks=$(for i in $cache_paths;do ls -l $i | awk -F '/' '{print $NF}';done)
[root@node-1 ~]# echo $cache_disks
sdp

(4) 获取数据盘的/dev/disk/by-path路径

[root@node-1 ~]# data_paths=$(for i in $ds;do kubectl get ds $i -n ceph -o yaml | grep -A1 BLUESTORE_DATA_DISK| grep value | uniq;done |uniq | awk '{print $2}')
[root@node-1 ~]# echo $data_paths
/dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:10:0 /dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:11:0 /dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:12:0 /dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:13:0 /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:0:0

(5) 获取数据盘的盘符 (缓存盘是一种特殊的数据盘)

[root@node-1 ~]# data_disks=$(for i in $data_paths;do ls -l $i | awk -F '/' '{print $NF}';done)
[root@node-1 ~]# echo $data_disks
sdf sdg sdh sdi sdp

(6) 获取以上盘符对应的OSD_ID,从OSD pod的name上取,该方法比较粗糙,精确的方法见(8)

[root@node-1 ~]# osd_ids=$(for i in $ds;do echo $i | cut -d- -f3 | uniq;done)
[root@node-1 ~]# echo $osd_ids
0 1 2 3 4

(7) 所以盘符和OSD_ID之间的对应关系如下

sdf sdg sdh sdi sdp
0    1   2   3   4

备注,盘符是通过变量ds,按序遍历获取,OSD_ID也是通过变量ds按序遍历获取,所以,存在按序一一对应关系

(8) 获取OSD_ID更精确的方法,从OSD的配置文件里取

[root@node-1 ~]# data_disks=$(for i in $ds;do kubectl get ds $i -n ceph -o yaml | grep -A1 BLUESTORE_OSD_ID| grep value | uniq;done |uniq | awk -F '"' '{print $2}')
[root@node-1 ~]# echo $data_disks
0 1 2 3 4

 

拓展:通过OSD_ID,获取数据盘和缓存盘的使用量

[root@node-1 ~]# ceph osd df
ID CLASS WEIGHT  REWEIGHT SIZE    USE     AVAIL   %USE  VAR  PGS 
 4   hdd 0.08008  1.00000 62.0GiB 14.8GiB 47.2GiB 23.93 4.64 128 
 9   hdd 0.08008  1.00000 62.0GiB 14.8GiB 47.2GiB 23.93 4.64 128 
14   ssd 0.08066  1.00000 62.6GiB 14.7GiB 47.9GiB 23.48 4.55 128 
 0   ssd 0.92920  1.00000  932GiB 47.5GiB  884GiB  5.10 0.99 112 
 1   ssd 0.92920  1.00000  932GiB 39.4GiB  892GiB  4.23 0.82 113 
 2   ssd 0.92920  1.00000  932GiB 46.0GiB  886GiB  4.94 0.96 110 
 3   ssd 0.92920  1.00000  932GiB 47.6GiB  884GiB  5.11 0.99 129 
 5   ssd 0.92920  1.00000  932GiB 37.1GiB  894GiB  3.98 0.77 103 
 6   ssd 0.92920  1.00000  932GiB 54.7GiB  877GiB  5.87 1.14 136 
 7   ssd 0.92920  1.00000  932GiB 45.5GiB  886GiB  4.88 0.95 102 
 8   ssd 0.92920  1.00000  932GiB 43.2GiB  888GiB  4.63 0.90 123 
10   ssd 0.92920  1.00000  932GiB 37.2GiB  894GiB  4.00 0.77 112 
11   ssd 0.92920  1.00000  932GiB 32.4GiB  899GiB  3.48 0.67 111 
12   ssd 0.92920  1.00000  932GiB 52.2GiB  879GiB  5.61 1.09 119 
13   ssd 0.92920  1.00000  932GiB 59.1GiB  872GiB  6.34 1.23 122 
                    TOTAL 11.1TiB  586GiB 10.5TiB  5.16          
MIN/MAX VAR: 0.67/4.64  STDDEV: 8.36

第一列对应OSD_ID, 第六列对应使用量

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Whether you are making a road, a ramp, a path or a river, Path Painter makes terrain based path creation and texturing a breeze! Path Painter allows you to: - Create paths; - Create ramps; - Create roads; - Create plateaus for secret forts; - Create lake and river beds; - Change terrain elevation along path; - Re-texture along path embankments; - Clear grass and trees along path; - Use various algorithms for natural clearing; - Standard Unity terrain compatible! Path Painter is a collaboration between Frank Slater and Procedural Worlds, and we are very excited to be working together. Note: This asset is provided in DLL form rather than with source code. If you would also like to purchase the source then please contact us directly. Our Product Suite: Gaia - A world generation system for creating, texturing, planting and populating scenes from low poly mobile, VR and through to high end desktop. GeNa 2 - A sophisticated localised level design tool that augments Gaia’s broad brush strokes, by working intuitively to give fine grained control. Path Painter - A powerful path and easy to use road, path and river bed painting system for Unity 3D. CTS - Nominated by Unity of as one of the best assets in 2017, a PBR terrain shading system that significantly improves terrain look, performance and usability. SECTR - A suite of performance-enhancing tools that enable open world streaming, massive mobile games and includes the latest techniques in audio occlusion and propagation. Pegasus - A system that can drive anything along a path. Great for cut-scenes, and even has an ambient ai that supports formations, animation and local avoidance for your npc's and animals! Want To Know More ? Unity Forum Path Painter Tutorials Have A Chat Ticketed Support NOTE: Path Painter does not create meshes, so if you are making rivers you would typically also use another tool as well to shade the river component.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值