이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 10. CRUSH Rules


CRUSH rules define how a Ceph client selects buckets and the primary OSD within them to store object, and how the primary OSD selects buckets and the secondary OSDs to store replicas (or coding chunks). For example, you might create a rule that selects a pair of target OSDs backed by SSDs for 2 object replicas, and another rule that select 3 target OSDs backed by SAS drives in different data centers for 3 replicas.

A rule takes the following form:

rule <rulename> {

    ruleset <ruleset>
    type [ replicated | raid4 ]
    min_size <min-size>
    max_size <max-size>
    step take <bucket-type>
    step [choose|chooseleaf] [firstn|indep] <N> <bucket-type>
    step emit
}
Copy to Clipboard Toggle word wrap

ruleset

Description
A means of classifying a rule as belonging to a set of rules. Activated by setting the ruleset in a pool.
Purpose
A component of the rule mask.
Type
Integer
Required
Yes
Default
0

type

Description
Describes a rule for either a storage drive (replicated) or a RAID.
Purpose
A component of the rule mask.
Type
String
Required
Yes
Default
replicated
Valid Values
Currently only replicated

min_size

Description
If a pool makes fewer replicas than this number, CRUSH will NOT select this rule.
Type
Integer
Purpose
A component of the rule mask.
Required
Yes
Default
1

max_size

Description
If a pool makes more replicas than this number, CRUSH will NOT select this rule.
Type
Integer
Purpose
A component of the rule mask.
Required
Yes
Default
10

step take <bucket-name>

Description
Takes a bucket name, and begins iterating down the tree.
Purpose
A component of the rule.
Required
Yes
Example
step take data

step choose firstn <num> type <bucket-type>

Description

Selects the number of buckets of the given type. The number is usually the number of replicas in the pool (i.e., pool size). +

  • If <num> == 0, choose pool-num-replicas buckets (all available).
  • If <num> > 0 && < pool-num-replicas, choose that many buckets.
  • If <num> < 0, it means pool-num-replicas - {num}.
Purpose
A component of the rule.
Prerequisite
Follows step take or step choose.
Example
step choose firstn 1 type row

step chooseleaf firstn <num> type <bucket-type>

Description

Selects a set of buckets of {bucket-type} and chooses a leaf node from the subtree of each bucket in the set of buckets. The number of buckets in the set is usually the number of replicas in the pool (i.e., pool size). +

  • If <num> == 0, choose pool-num-replicas buckets (all available).
  • If <num> > 0 && < pool-num-replicas, choose that many buckets.
  • If <num> < 0, it means pool-num-replicas - <num>.
Purpose
A component of the rule. Usage removes the need to select a device using two steps.
Prerequisite
Follows step take or step choose.
Example
step chooseleaf firstn 0 type row

step emit

Description
Outputs the current value and empties the stack. Typically used at the end of a rule, but may also be used to pick from different trees in the same rule.
Purpose
A component of the rule.
Prerequisite
Follows step choose.
Example
step emit
Important

To activate one or more rules with a common ruleset number to a pool, set the ruleset number of the pool.

10.1. List Rules

To list CRUSH rules from the command line, execute the following:

ceph osd crush rule list
ceph osd crush rule ls
Copy to Clipboard Toggle word wrap

10.2. Dump a Rule

To dump the contents of a specific CRUSH rule, execute the following:

ceph osd crush rule dump {name}
Copy to Clipboard Toggle word wrap

10.3. Add a Simple Rule

To add a CRUSH rule, you must specify a rule name, the root node of the hierarchy you wish to use, the type of bucket you want to replicate across (e.g., rack, row, etc) and the mode for choosing the bucket.

ceph osd crush rule create-simple {rulename} {root} {bucket-type} {first|indep}
Copy to Clipboard Toggle word wrap

Ceph will create a rule with chooseleaf and 1 bucket of the type you specify.

For example:

ceph osd crush rule create-simple deleteme default host firstn
Copy to Clipboard Toggle word wrap

Create the following rule:

{ "rule_id": 1,
  "rule_name": "deleteme",
  "ruleset": 1,
  "type": 1,
  "min_size": 1,
  "max_size": 10,
  "steps": [
        { "op": "take",
          "item": -1,
          "item_name": "default"},
        { "op": "chooseleaf_firstn",
          "num": 0,
          "type": "host"},
        { "op": "emit"}]}
Copy to Clipboard Toggle word wrap

10.4. Add an Erasure Code Rule

To add a CRUSH rule for use with an erasure coded pool, you may specify a rule name and an erasure code profile.

ceph osd crush rule create-erasure {rulename} {profilename}
Copy to Clipboard Toggle word wrap

10.5. Remove a Rule

To remove a rule, execute the following and specify the CRUSH rule name:

ceph osd crush rule rm {name}
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat