文档章节

crushmap使用说明

 惊浪
发布于 2014/11/21 14:49
字数 913
阅读 289
收藏 1

This article introduces a simple use case for storage providers. For some reasons some customers would like to pay more for a fast storage solution and other would prefer to pay less for a reasonnable storage solution.

I. Use case

Roughly say your infrastructure could be based on several type of servers:

  • storage nodes full of SSDs disks

  • storage nodes full of SAS disks

  • storage nodes full of SATA disks

Such handy mecanism is possible with the help of the CRUSH Map.


II. A bit about CRUSH

CRUSH stands for Controlled Replication Under Scalable Hashing:

  • Pseudo-random placement algorithm

  • Fast calculation, no lookup Repeatable, deterministic

  • Ensures even distribution

  • Stable mapping

  • Limited data migration

  • Rule-based configuration, rule determines data placement

  • Infrastructure topology aware, the map knows the structure of your infra (nodes, racks, row, datacenter)

  • Allows weighting, every OSD has a weight

For more details check the Ceph Official documentation.


III. Setup

What are we going to do?

  1. Retrieve the current CRUSH Map

  2. Decompile the CRUSH Map

  3. Edit it. We will add 2 buckets and 2 rulesets

  4. Recompile the new CRUSH Map.

  5. Re-inject the new CRUSH Map.

III.1. Begin

Grab your current CRUSH map:

12
$ ceph osd getcrushmap -o ma-crush-map$ crushtool -d ma-crush-map -o ma-crush-map.txt

For the sake of simplicity, let’s assume that you have 4 OSDs:

  • 2 of them are SAS disks

  • 2 of them are SSD enterprise

And here is the OSD tree:

1234567891011
$ ceph osd treedumped osdmap tree epoch 621# id    weight  type name   up/down reweight-1  12  pool default-3  12      rack le-rack-2  3           host ceph-010   1               osd.0   up  11   1               osd.1   up  1-4  3           host ceph-022   1               osd.2   up  13   1               osd.3   up  1

III.2. Default crush map

Edit your CRUSH map:

# begin crush map

# devices
device 0 osd.0
device 1 osd.1
device 2 osd.2
device 3 osd.3

# types
type 0 osd
type 1 host
type 2 rack
type 3 row
type 4 room
type 5 datacenter
type 6 pool

# buckets
host ceph-01 {
    id -2       # do not change unnecessarily
    # weight 3.000
    alg straw
    hash 0  # rjenkins1
    item osd.0 weight 1.000
    item osd.1 weight 1.000
}
host ceph-02 {
    id -4       # do not change unnecessarily
    # weight 3.000
    alg straw
    hash 0  # rjenkins1
    item osd.2 weight 1.000
    item osd.3 weight 1.000
}
rack le-rack {
    id -3       # do not change unnecessarily
    # weight 12.000
    alg straw
    hash 0  # rjenkins1
    item ceph-01 weight 2.000
    item ceph-02 weight 2.000
}
pool default {
    id -1       # do not change unnecessarily
    # weight 12.000
    alg straw
    hash 0  # rjenkins1
    item le-rack weight 4.000
}

# rules
rule data {
    ruleset 0
    type replicated
    min_size 1
    max_size 10
    step take default
    step chooseleaf firstn 0 type host
    step emit
}
rule metadata {
    ruleset 1
    type replicated
    min_size 1
    max_size 10
    step take default
    step chooseleaf firstn 0 type host
    step emit
}
rule rbd {
    ruleset 2
    type replicated
    min_size 1
    max_size 10
    step take default
    step chooseleaf firstn 0 type host
    step emit
}

# end crush map

III.3. Add buckets and rules

Now we have to add 2 new specific rules:

  • one for the SSD pool

  • one for the SAS pool

III.3.1. SSD Pool

Add a bucket for the pool SSD:

pool ssd {
    id -5       # do not change unnecessarily
    alg straw
    hash 0  # rjenkins1
    item osd.0 weight 1.000
    item osd.1 weight 1.000
}

Add a rule for the bucket nearly created:

rule ssd {
    ruleset 3
    type replicated
    min_size 1
    max_size 10
    step take ssd
    step choose firstn 0 type osd
    step emit
}

III.3.1. SAS Pool

Add a bucket for the pool SAS:

pool sas {
    id -6       # do not change unnecessarily
    alg straw
    hash 0  # rjenkins1
    item osd.2 weight 1.000
    item osd.3 weight 1.000
}

Add a rule for the bucket nearly created:

rule sas {
    ruleset 4
    type replicated
    min_size 1
    max_size 10
    step take sas
    step choose firstn 0 type osd
    step emit
}

Eventually recompile and inject the new CRUSH map:

12
$ crushtool -c ma-crush-map.txt -o ma-nouvelle-crush-map$ ceph osd setcrushmap -i ma-nouvelle-crush-map

III.3. Create and configure the pools

Create your 2 new pools:

1234
$ rados mkpool ssdsuccessfully created pool ssd$ rados mkpool sassuccessfully created pool sas

Set the rule set to the pool:

12
ceph osd pool set ssd crush_ruleset 3ceph osd pool set sas crush_ruleset 4

Check that the changes have been applied successfully:

123
$ ceph osd dump | grep -E 'ssd|sas'pool 3 'ssd' rep size 2 crush_ruleset 3 object_hash rjenkins pg_num 128 pgp_num 128 last_change 21 owner 0pool 4 'sas' rep size 2 crush_ruleset 4 object_hash rjenkins pg_num 128 pgp_num 128 last_change 23 owner 0

III.4. Test it

Just create some random files and put them into your object store:

1234
$ dd if=/dev/zero of=ssd.pool bs=1M count=512 conv=fsync$ dd if=/dev/zero of=sas.pool bs=1M count=512 conv=fsync$ rados -p ssd put ssd.pool ssd.pool.object$ rados -p sas put sas.pool sas.pool.object

Where are pg active?

12345
$ ceph osd map ssd ssd.pool.objectosdmap e260 pool 'ssd' (3) object 'ssd.pool.object' -> pg 3.c5034eb8 (3.0) -> up [1,0] acting [1,0]$ ceph osd map sas sas.pool.objectosdmap e260 pool 'sas' (4) object 'sas.pool.object' -> pg 4.9202e7ee (4.0) -> up [3,2] acting [3,2]

CRUSH Rules! As you can see from this article CRUSH allows you to perform amazing things. The CRUSH Map could be very complex, but it brings a lot of flexibility! Happy CRUSH Mapping ;-)

© 著作权归作者所有

共有 人打赏支持
粉丝 16
博文 29
码字总数 17864
作品 0
福州
程序员
osd 节点替换

从crushmap中删除操作 调整osd的crush weight ceph osd crush reweight osd.0 0.1 说明:这个地方如果想慢慢的调整就分几次将crush 的weight 减低到0 ,这个过程实际上是让数据不分布在这个节...

吴景峰
2017/10/19
0
0
mkcephfs创建集群过程分析

$0指的就是mkcephfs 1. 校验conf文件,并创建随机的临时目录: dir = /tmp/mkcephfs.jYWWOaxaTa 2 .执行 :$0 --prepare-monmap -d $dir -c $conf 1) 得到mon列表、mon的id以及mon的地址 :...

itfanr
2015/04/16
0
2
ceph 容器化安装 以及 需要趟过去的坑

ceph集群的容器化安装比原始安装步骤简单,好操作。但是运维相对可能会有许多坑需要趟。下面就做一个简单的分享。 1 节点规划 admin 172.18.1.193 node1 172.18.1.195 node2 172.18.1.196 2...

胡子叭槎
04/16
0
0
Ceph编译安装教程

Ceph官方版本目前支持的纠删码很有限,实验室这块希望能够整合我们自主开发的纠删码BRS(Binary Reed–Solomon encoding),所以需要编译Ceph环境。Ceph官方目前推荐的安装方式都是通过Ceph-...

LeeHappen
2017/12/01
0
0
ceph crush 策略配置

0.问题 一个同事搭建了两个主机的集群。ceph -s 后,集群一直会出现 recovery 32402/195672 objects degraded objects degraded 警告。 原因在于,默认3份副本。crush select策略是从host 选...

安静美男子
2015/08/26
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

spring 容器实现对bean的管理(注解方式解析,源码阅读)

因为最近在研究学习spring boot,所以这里想详细学习回顾了一下spring 容器对bean的一些管理方式和部分源码学习。 首先初始类AnnotationConfigApplicationContext,简单源码查看,支持两个参...

小海bug
10分钟前
0
0
数据结构:二分查找 java

二分查找的前提是有序存储,利用顺序存储和元素排序 /** * 二分查找,查找成功,返回下标记 * @param values * @param begin * @param end * @param key * @param <T> * @ret...

京一
27分钟前
0
0
@SpringBootApplication 注解

@SpringBootApplication注解是一个组合注解,包含以下注解 @Target(ElementType.TYPE) 注解的作用目标 @Retention(RetentionPolicy.RUNTIME) Reteniton的作用是定义被它所注解的注解保留多久,...

java.刘
40分钟前
0
0
sentinel自定义DataSource实战

序 本文主要研究一下如何自定义sentinel的DataSource,这里以jdbc为例。 maven <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-sen......

go4it
56分钟前
1
0
xgboost/gbdt在调参时为什么树的深度很少就能达到很高的精度?

问题: 用xgboost/gbdt在在调参的时候把树的最大深度调成6就有很高的精度了。但是用DecisionTree/RandomForest的时候需要把树的深度调到15或更高。用RandomForest所需要的树的深度和Decisio...

tantexian
57分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部