简介

ceph从L版本开始新增了个功能叫crush class,又被称之为磁盘智能分组。因为这个功能就是根据磁盘类型自动进行属性关联,然后进行分类减少了很多的人为操作。在这个功能之前,如果我们需要对ssd和hdd进行分组的时候,需要大量的修改crushmap,然后绑定不同的存储池到不同的crush树上面,而这个功能让我们简化了这种逻辑。

ceph中的每个设备都可以选择一个class类型与之关联,通常有三种class类型:

  • hdd
  • ssd
  • nvme

配置crush class

1. 创建ssd class

默认情况下,我们所有的osd都会class类型都是hdd:

root@ceph:~# ceph osd crush class ls
[
"hdd"
]

查看当前的osd布局:

root@ceph:~# ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 47.37482 root default
-3 11.84311 host ctnr.a1-56-11.pub.unp
0 hdd 1.81879 osd.0 up 1.00000 1.00000
25 hdd 1.81879 osd.25 up 1.00000 1.00000
26 hdd 1.81879 osd.26 up 1.00000 1.00000
27 hdd 1.81879 osd.27 up 1.00000 1.00000
28 hdd 1.81879 osd.28 up 1.00000 1.00000
29 hdd 1.81879 osd.29 up 1.00000 1.00000
30 hdd 0.46519 osd.30 up 1.00000 1.00000
31 hdd 0.46519 osd.31 up 1.00000 1.00000
-2 11.84430 host ctnr.a1-56-14.pub.unp
1 hdd 1.81898 osd.1 up 1.00000 1.00000
11 hdd 1.81898 osd.11 up 1.00000 1.00000
12 hdd 1.81898 osd.12 up 1.00000 1.00000
13 hdd 1.81898 osd.13 up 1.00000 1.00000
14 hdd 1.81898 osd.14 up 1.00000 1.00000
15 hdd 1.81898 osd.15 up 1.00000 1.00000
16 hdd 0.46519 osd.16 up 1.00000 1.00000
17 hdd 0.46519 osd.17 up 1.00000 1.00000
-7 11.84430 host ctnr.a1-56-15.pub.unp
2 hdd 1.81898 osd.2 up 1.00000 1.00000
3 hdd 1.81898 osd.3 up 1.00000 1.00000
5 hdd 1.81898 osd.5 up 1.00000 1.00000
6 hdd 1.81898 osd.6 up 1.00000 1.00000
7 hdd 1.81898 osd.7 up 1.00000 1.00000
8 hdd 1.81898 osd.8 up 1.00000 1.00000
9 hdd 0.46519 osd.9 up 1.00000 1.00000
10 hdd 0.46519 osd.10 up 1.00000 1.00000
-11 11.84311 host ctnr.a1-56-16.pub.unp
4 hdd 1.81879 osd.4 up 1.00000 1.00000
18 hdd 1.81879 osd.18 up 1.00000 1.00000
19 hdd 1.81879 osd.19 up 1.00000 1.00000
20 hdd 1.81879 osd.20 up 1.00000 1.00000
21 hdd 1.81879 osd.21 up 1.00000 1.00000
22 hdd 1.81879 osd.22 up 1.00000 1.00000
23 hdd 0.46519 osd.23 up 1.00000 1.00000
24 hdd 0.46519 osd.24 up 1.00000 1.00000

可以看到,当前有四个osd节点,每个节点上有8个osd,我们假设说每个节点上的最后两个osd为ssd磁盘。现在需要为其创建ssd的class。我们需要先将所有的ssd的osd从hdd class中删除:

for i in 30 31 16 17 9 10 23 24; do ceph osd crush rm-device-class osd.$i;done

这个时候,如果我们再次使用ceph osd tree查看osd布局,会看到被我们指定的osd前面不再有hdd标识,事实上啥也没有了。

此时可通过如下指令将这些osd添加至ssd class:

for i in 30 31 16 17 9 10 23 24; do ceph osd crush set-device-class ssd osd.$i;done

添加完成之后,我们再次查看osd布局:

root@ceph:~# ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 47.37482 root default
-3 11.84311 host ctnr.a1-56-11.pub.unp
0 hdd 1.81879 osd.0 up 1.00000 1.00000
25 hdd 1.81879 osd.25 up 1.00000 1.00000
26 hdd 1.81879 osd.26 up 1.00000 1.00000
27 hdd 1.81879 osd.27 up 1.00000 1.00000
28 hdd 1.81879 osd.28 up 1.00000 1.00000
29 hdd 1.81879 osd.29 up 1.00000 1.00000
30 ssd 0.46519 osd.30 up 1.00000 1.00000
31 ssd 0.46519 osd.31 up 1.00000 1.00000
-2 11.84430 host ctnr.a1-56-14.pub.unp
1 hdd 1.81898 osd.1 up 1.00000 1.00000
11 hdd 1.81898 osd.11 up 1.00000 1.00000
12 hdd 1.81898 osd.12 up 1.00000 1.00000
13 hdd 1.81898 osd.13 up 1.00000 1.00000
14 hdd 1.81898 osd.14 up 1.00000 1.00000
15 hdd 1.81898 osd.15 up 1.00000 1.00000
16 ssd 0.46519 osd.16 up 1.00000 1.00000
17 ssd 0.46519 osd.17 up 1.00000 1.00000
-7 11.84430 host ctnr.a1-56-15.pub.unp
2 hdd 1.81898 osd.2 up 1.00000 1.00000
3 hdd 1.81898 osd.3 up 1.00000 1.00000
5 hdd 1.81898 osd.5 up 1.00000 1.00000
6 hdd 1.81898 osd.6 up 1.00000 1.00000
7 hdd 1.81898 osd.7 up 1.00000 1.00000
8 hdd 1.81898 osd.8 up 1.00000 1.00000
9 ssd 0.46519 osd.9 up 1.00000 1.00000
10 ssd 0.46519 osd.10 up 1.00000 1.00000
-11 11.84311 host ctnr.a1-56-16.pub.unp
4 hdd 1.81879 osd.4 up 1.00000 1.00000
18 hdd 1.81879 osd.18 up 1.00000 1.00000
19 hdd 1.81879 osd.19 up 1.00000 1.00000
20 hdd 1.81879 osd.20 up 1.00000 1.00000
21 hdd 1.81879 osd.21 up 1.00000 1.00000
22 hdd 1.81879 osd.22 up 1.00000 1.00000
23 ssd 0.46519 osd.23 up 1.00000 1.00000
24 ssd 0.46519 osd.24 up 1.00000 1.00000

可以看到我们选定的osd的class都变为了ssd。

然后我们再次查看crush class,也多出了一个名为ssd的class:

root@ceph:~# ceph osd crush class ls
[
"hdd",
"ssd"
]

2. 创建基于ssd的class rule

创建一个class rule,取名为ssd_rule,使用ssd的osd:

ceph osd crush rule create-replicated ssd_rule default host ssd

查看集群rule:

root@ceph:~# ceph osd crush rule ls
replicated_rule
ssd_rule

通过如下方式查看详细的crushmap信息:

root@ceph:~# ceph osd getcrushmap -o crushmap
172
root@ceph:~# crushtool -d crushmap -o crushmap.txt
root@ceph:~# cat crushmap.txt
# begin crush map
tunable choose_local_tries 0
tunable choose_local_fallback_tries 0
tunable choose_total_tries 50
tunable chooseleaf_descend_once 1
tunable chooseleaf_vary_r 1
tunable straw_calc_version 1
tunable allowed_bucket_algs 54 # devices
device 0 osd.0 class hdd
device 1 osd.1 class hdd
device 2 osd.2 class hdd
device 3 osd.3 class hdd
device 4 osd.4 class hdd
device 5 osd.5 class hdd
device 6 osd.6 class hdd
device 7 osd.7 class hdd
device 8 osd.8 class hdd
device 9 osd.9 class ssd
device 10 osd.10 class ssd
device 11 osd.11 class hdd
device 12 osd.12 class hdd
device 13 osd.13 class hdd
device 14 osd.14 class hdd
device 15 osd.15 class hdd
device 16 osd.16 class ssd
device 17 osd.17 class ssd
device 18 osd.18 class hdd
device 19 osd.19 class hdd
device 20 osd.20 class hdd
device 21 osd.21 class hdd
device 22 osd.22 class hdd
device 23 osd.23 class ssd
device 24 osd.24 class ssd
device 25 osd.25 class hdd
device 26 osd.26 class hdd
device 27 osd.27 class hdd
device 28 osd.28 class hdd
device 29 osd.29 class hdd
device 30 osd.30 class ssd
device 31 osd.31 class ssd # types
type 0 osd
type 1 host
type 2 chassis
type 3 rack
type 4 row
type 5 pdu
type 6 pod
type 7 room
type 8 datacenter
type 9 region
type 10 root # buckets
host ctnr.a1-56-11.pub.unp {
id -3 # do not change unnecessarily
id -4 class hdd # do not change unnecessarily
id -9 class ssd # do not change unnecessarily
# weight 11.843
alg straw2
hash 0 # rjenkins1
item osd.0 weight 1.819
item osd.25 weight 1.819
item osd.26 weight 1.819
item osd.27 weight 1.819
item osd.28 weight 1.819
item osd.29 weight 1.819
item osd.30 weight 0.465
item osd.31 weight 0.465
}
host ctnr.a1-56-15.pub.unp {
id -7 # do not change unnecessarily
id -8 class hdd # do not change unnecessarily
id -10 class ssd # do not change unnecessarily
# weight 11.844
alg straw2
hash 0 # rjenkins1
item osd.2 weight 1.819
item osd.3 weight 1.819
item osd.5 weight 1.819
item osd.6 weight 1.819
item osd.7 weight 1.819
item osd.8 weight 1.819
item osd.9 weight 0.465
item osd.10 weight 0.465
}
host ctnr.a1-56-14.pub.unp {
id -2 # do not change unnecessarily
id -5 class hdd # do not change unnecessarily
id -13 class ssd # do not change unnecessarily
# weight 11.844
alg straw2
hash 0 # rjenkins1
item osd.1 weight 1.819
item osd.11 weight 1.819
item osd.12 weight 1.819
item osd.13 weight 1.819
item osd.14 weight 1.819
item osd.15 weight 1.819
item osd.16 weight 0.465
item osd.17 weight 0.465
}
host ctnr.a1-56-16.pub.unp {
id -11 # do not change unnecessarily
id -12 class hdd # do not change unnecessarily
id -14 class ssd # do not change unnecessarily
# weight 11.843
alg straw2
hash 0 # rjenkins1
item osd.4 weight 1.819
item osd.18 weight 1.819
item osd.19 weight 1.819
item osd.20 weight 1.819
item osd.21 weight 1.819
item osd.22 weight 1.819
item osd.23 weight 0.465
item osd.24 weight 0.465
}
root default {
id -1 # do not change unnecessarily
id -6 class hdd # do not change unnecessarily
id -15 class ssd # do not change unnecessarily
# weight 47.375
alg straw2
hash 0 # rjenkins1
item ctnr.a1-56-11.pub.unp weight 11.843
item ctnr.a1-56-15.pub.unp weight 11.844
item ctnr.a1-56-14.pub.unp weight 11.844
item ctnr.a1-56-16.pub.unp weight 11.843
} # rules
rule replicated_rule {
id 0
type replicated
min_size 1
max_size 10
step take default
step chooseleaf firstn 0 type host
step emit
}
rule ssd_rule {
id 1
type replicated
min_size 1
max_size 10
step take default class ssd
step chooseleaf firstn 0 type host
step emit
} # end crush map

3. 创建基于ssd_rule规则的存储池

  1. 创建一个基于该ssdh_rule规则的存储池:
ceph osd pool create cache 64 64 ssd_rule

# 查看cache的信息可以看到使用的crush_rule为1,也就是ssd_rule
root@ceph:~# ceph osd pool get cache crush_rule
crush_rule: ssd_rule
  1. 将一个现有的池迁移至ssd的osd上:
ceph osd pool set cephfs_metadata crush_rule ssd_rule

root@ceph:~# ceph osd pool get cephfs_metadata crush_rule
crush_rule: ssd_rule

4. 测试基于ssd的池

root@ceph:~# echo "hello world" > test.txt
root@ceph:~# rados -p cache put test test.txt
root@ceph:~# rados -p cache get test
root@ceph:~# rados -p cache ls |grep test
test
root@ceph:~# ceph osd map cache test
osdmap e3156 pool 'cache' (4) object 'test' -> pg 4.40e8aab5 (4.35) -> up ([23,30,16], p23) acting ([23,30,16], p23)

参考: https://blog.csdn.net/kozazyh/article/details/79904219

crushmap磁盘智能分组的更多相关文章

  1. ceph luminous 新功能之磁盘智能分组

    前言 本篇是luminous一个新功能介绍,关于磁盘智能分组的,这个在ceph里面叫crush class,这个我自己起名叫磁盘智能分组,因为这个实现的功能就是根据磁盘类型进行属性关联,然后进行分类, ...

  2. Ceph 12.2.0 实践osd 智能分组功能

    以前我们需要对ssd和hdd进行分组的时候,需要大量的修改crush map,然后绑定不同的存储池到不同的 crush 树上面,现在这个逻辑简化了很多.以上是官方宣传听起来很不错等到12.2.0稳定版 ...

  3. 管理ceph缓存池

    目录 缓存池简介 缓存池原理 缓存池的工作模式 配置缓存池 1. 创建一个缓存池 2. 设置缓存层 3. 缓存层相关参数说明 4. 测试缓存池 删除缓存池 1. 删除read-only缓存池 2. 删 ...

  4. ceph mimic版本 部署安装

    ceph 寻址过程 1. file --- object映射, 把file分割成N个相同的对象 2. object - PG 映射, 利用静态hash得到objectID的伪随机值,在 "位 ...

  5. crush class实验

    标签(空格分隔): ceph,ceph实验,crushmap luminous版本的ceph新增了一个功能crush class,这个功能又可以称为磁盘智能分组.因为这个功能就是根据磁盘类型自动的进行 ...

  6. [ ceph ] CEPH 部署完整版(CentOS 7 + luminous)

    1. 前言 拜读了 胖哥的(el7+jewel)完整部署 受益匪浅,目前 CEPH 已经更新到 M 版本,配置方面或多或少都有了变动,本博文就做一个 ceph luminous 版本完整的配置安装. ...

  7. 容器网络——从CNI到Calico

    从容器诞生开始,存储和网络这两个话题就一直为大家津津乐道.我们今天这个环境下讲网络这个问题,其实是因为容器对网络的需求,和传统物理.虚拟环境对网络环境需求是有差别的,主要面临以下两个问题: 过去Iaa ...

  8. Windows Server 2012 虚拟化实战:存储(二)

    五.搭建Window Server 2012虚拟化的存储网络 前文我们讨论了Window Server 2012支持的各种与存储相关的技术,接下来我们通过实践对其中的一些技术进行检验.实际上Windo ...

  9. 通过 SMB 直通优化文件服务器的性能

    https://technet.microsoft.com/zh-cn/library/hh831487.aspx Windows Server 2012 内置新增功能,称为 SMB 直通,用来支持使 ...

随机推荐

  1. 执行http脚本

    Invoke-Expression (Invoke-WebRequest http://10.16.2.5:81/Configcmd.ps1).content

  2. Flask补充--threading.local对象

    目录 Local 局部变量 全局变量 使用threading.local() 自定义threading.local 函数版 面向对象版 通过setattr和getattr实现 每个对象有自己的存储空间 ...

  3. 【APS系统应用案例】高博通信智能制造的新武器

    企业背景: 早在2006年,一个年轻的企业瞄准国际高端航空产业及超精密制造行业.高博集团,以普世价值开创航空中国的新纪元. 高博通信(上海)有限公司(下文简称“高博通信”)占地36000平方米,以满足 ...

  4. maven 学习---Maven项目文档

    本教程将教你如何一步到位创建应用程序的文档.因此,让我们开始,到  C:/MVN 创建java应用程序consumerBanking. OpenconsumerBanking文件夹,然后执行以下命令m ...

  5. flink WaterMark之TumblingEventWindow

    1.WaterMark,翻译成水印或水位线,水印翻译更抽象,水位线翻译接地气. watermark是用于处理乱序事件的,通常用watermark机制结合window来实现. 流处理从事件产生,到流经s ...

  6. os模块,sys模块,json和pickle模块,logging模块

    目录 OS模块 sys模块 json和pickle模块 序列化和反序列化 json模块 pickle logging模块 OS模块 能与操作系统交互,控制文件 / 文件夹 # 创建文件夹 import ...

  7. Nginx03(实现负载均衡)

    一.负载均衡的作用 1.转发功能 按照一定的算法[权重.轮询.Ip_Hash],将客户端请求转发到不同应用服务器上,减轻单个服务器压力,提高系统并发量. 2.故障移除 通过心跳检测的方式,判断应用服务 ...

  8. influxdb-1.7.8(centos 7) 部署

    1.官方下载: https://dl.influxdata.com/influxdb/releases/influxdb-1.7.8.x86_64.rpm 2.安装软件 sudo yum locali ...

  9. pytest生成allure报告

    在pytest框架中可以用很多插件来生成测试报告,本文总结下怎么生成allure报告 allure allure是一款开源的,专门用来展示测试结果的一个工具,allure可以与很多的测试框架做集成,比 ...

  10. python 爬虫之-- 正则表达式

    正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. 正则表达式非python独有,python 提供了正则表达式的接口,re模块 一.正则匹配字符简介 模式 描述 \d ...