4.3.2. ストレッチモード用の CRUSH マップを設定する
この情報を使用して、ストレッチモードの CRUSH マップを設定します。
前提条件
始める前に、次の前提条件が満たされていることを確認してください。
- ノードへの root レベルのアクセス。
- CRUSH ロケーションがホストに設定されている。
手順
crushtoolコマンドを使用するために ceph-base RPM パッケージをインストールして、この OSD クラッシュトポロジーを利用する CRUSH ルールを作成します。構文
dnf -y install ceph-baseコンパイルされた CRUSH マップをクラスターから取得します。
構文
ceph osd getcrushmap > /etc/ceph/crushmap.binCRUSH マップを逆コンパイルし、テキストファイルに変換して編集します。
構文
crushtool -d /etc/ceph/crushmap.bin -o /etc/ceph/crushmap.txtファイルの末尾にある
/etc/ceph/crushmap.txtを編集して、以下のルールを CRUSH マップに追加します。このルールは、読み取りと書き込みをデータセンター全体に均等に分散します。構文
rule stretch_rule { id 1 type replicated step take default step choose firstn 0 type datacenter step chooseleaf firstn 2 type host step emit }必要に応じて、データセンター 1 に対する読み取り/書き込みアフィニティーを持つクラスターを作成します。
構文
rule stretch_rule { id 1 type replicated step take DC1 step chooseleaf firstn 2 type host step emit step take DC2 step chooseleaf firstn 2 type host step emit }The CRUSH rule declared contains the following information: Rule name Description: A unique name for identifying the rule. Value: stretch_rule id Description: A unique whole number for identifying the rule. Value: 1 type Description: Describes a rule for either a storage drive replicated or erasure-coded. Value: replicated step take default Description: Takes the root bucket called default, and begins iterating down the tree. step take DC1 Description: Takes the bucket called DC1, and begins iterating down the tree. step choose firstn 0 type datacenter Description: Selects the datacenter bucket, and goes into its subtrees. step chooseleaf firstn 2 type host Description: Selects the number of buckets of the given type. In this case, it is two different hosts located in the datacenter it entered at the previous level. 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.
/etc/ceph/crushmap.txtから新しい CRUSH マップをコンパイルし、バイナリーファイル/etc/ceph/crushmap2.binに変換します。構文
crushtool -c /path/to/crushmap.txt -o /path/to/crushmap2.bin例
[ceph: root@host01 /]# crushtool -c /etc/ceph/crushmap.txt -o /etc/ceph/crushmap2.bin新しく作成された CRUSH マップをクラスターに再度注入します。
構文
ceph osd setcrushmap -i /path/to/compiled_crushmap例
[ceph: root@host01 /]# ceph osd setcrushmap -i /path/to/compiled_crushmap 17注記数字 17 はカウンターであり、CRUSH マップに加えられた変更に応じて増加します (18、19 など)。
検証
新しく作成された stretch_rule が使用可能であることを確認します。
構文
ceph osd crush rule ls
例
[ceph: root@host01 /]# ceph osd crush rule ls
replicated_rule
stretch_rule
4.3.2.1. ストレッチモードへの切り替え リンクのコピーリンクがクリップボードにコピーされました!
ストレッチモードは 2 つのサイトを処理するように設計されています。2 サイトクラスターでは、コンポーネントの可用性が失われるリスクが低くなります。
前提条件
始める前に、次の前提条件が満たされていることを確認してください。
- ノードへの root レベルのアクセス。
- CRUSH ロケーションがホストに設定されている。
- ストレッチルールを含むように設定された CRUSH マップ。
- クラスター内にイレイジャーコーディングされたプールがない。
- 2 つのサイトの重みが同じである。
手順
モニターが使用する現在の選出ストラテジーを確認します。
構文
ceph mon dump | grep election_strategy注記Ceph クラスターの
election_strategyは、デフォルトで1に設定されています。例
[ceph: root@host01 /]# ceph mon dump | grep election_strategy dumped monmap epoch 9 election_strategy: 1選出ストラテジーを
connectivityに変更します。構文
ceph mon set election_strategy connectivity選出ストラテジーの設定の詳細は、モニター選択ストラテジーの設定 を参照してください。
ceph mon dumpコマンドを使用して、選出ストラテジーが3に更新されたことを確認します。例
[ceph: root@host01 /]# ceph mon dump | grep election_strategy dumped monmap epoch 22 election_strategy: 3tiebreaker モニターの場所を、データセンター間で分割するように設定します。
構文
ceph mon set_location TIEBREAKER_HOST datacenter=DC3例
[ceph: root@host01 /]# ceph mon set_location host07 datacenter=DC3tiebreaker モニターが期待どおりに設定されていることを確認します。
構文
ceph mon dump例
[ceph: root@host01 /]# ceph mon dump epoch 8 fsid 4158287e-169e-11f0-b1ad-fa163e98b991 last_changed 2025-04-11T07:14:48.652801+0000 created 2025-04-11T06:29:24.974553+0000 min_mon_release 19 (squid) election_strategy: 3 0: [v2:10.0.57.33:3300/0,v1:10.0.57.33:6789/0] mon.host07; crush_location {datacenter=DC3} 1: [v2:10.0.58.200:3300/0,v1:10.0.58.200:6789/0] mon.host05; crush_location {datacenter=DC2} 2: [v2:10.0.58.47:3300/0,v1:10.0.58.47:6789/0] mon.host02; crush_location {datacenter=DC1} 3: [v2:10.0.58.104:3300/0,v1:10.0.58.104:6789/0] mon.host04; crush_location {datacenter=DC2} 4: [v2:10.0.58.38:3300/0,v1:10.0.58.38:6789/0] mon.host01; crush_location {datacenter=DC1} dumped monmap epoch 8 0ストレッチモードに入ります。
構文
ceph mon enable_stretch_mode TIEBREAKER_HOST STRETCH_RULE STRETCH_BUCKET以下の例では、下記の点を前提としています。
- tiebreaker ノードは host07 として設定されている。
- ストレッチルールは、xx で作成された stretch_rule である。
- ストレッチバケットはデータセンターとして設定されている。
[ceph: root@host01 /]# ceph mon enable_stretch_mode host07 stretch_rule datacenter
検証
CROSREF を続行して、ストレッチモードが正しく実装されていることを確認します。