OpenShift Container Storage is now OpenShift Data Foundation starting with version 4.9.
Chapter 4. Configuring Red Hat Ceph Storage stretch cluster
Once the Red Hat Ceph Storage cluster is fully deployed using cephadm, use the following procedure to configure the stretch cluster mode. The new stretch mode is designed to handle the 2-site case.
Procedure
Check the current election strategy being used by the monitors with the ceph mon dump command. By default in a ceph cluster, the connectivity is set to classic.
ceph mon dump | grep election_strategy
ceph mon dump | grep election_strategyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
dumped monmap epoch 9 election_strategy: 1
dumped monmap epoch 9 election_strategy: 1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change the monitor election to connectivity.
ceph mon set election_strategy connectivity
ceph mon set election_strategy connectivityCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the previous ceph mon dump command again to verify the election_strategy value.
ceph mon dump | grep election_strategy
$ ceph mon dump | grep election_strategyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
dumped monmap epoch 10 election_strategy: 3
dumped monmap epoch 10 election_strategy: 3Copy to Clipboard Copied! Toggle word wrap Toggle overflow To know more about the different election strategies, see Configuring monitor election strategy.
Set the location for all our Ceph monitors:
ceph mon set_location ceph1 datacenter=DC1 ceph mon set_location ceph2 datacenter=DC1 ceph mon set_location ceph4 datacenter=DC2 ceph mon set_location ceph5 datacenter=DC2 ceph mon set_location ceph7 datacenter=DC3
ceph mon set_location ceph1 datacenter=DC1 ceph mon set_location ceph2 datacenter=DC1 ceph mon set_location ceph4 datacenter=DC2 ceph mon set_location ceph5 datacenter=DC2 ceph mon set_location ceph7 datacenter=DC3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that each monitor has its appropriate location.
ceph mon dump
$ ceph mon dumpCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a CRUSH rule that makes use of this OSD crush topology by installing the
ceph-baseRPM package in order to use thecrushtoolcommand:dnf -y install ceph-base
$ dnf -y install ceph-baseCopy to Clipboard Copied! Toggle word wrap Toggle overflow To know more about CRUSH ruleset, see Ceph CRUSH ruleset.
Get the compiled CRUSH map from the cluster:
ceph osd getcrushmap > /etc/ceph/crushmap.bin
$ ceph osd getcrushmap > /etc/ceph/crushmap.binCopy to Clipboard Copied! Toggle word wrap Toggle overflow Decompile the CRUSH map and convert it to a text file in order to be able to edit it:
crushtool -d /etc/ceph/crushmap.bin -o /etc/ceph/crushmap.txt
$ crushtool -d /etc/ceph/crushmap.bin -o /etc/ceph/crushmap.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following rule to the CRUSH map by editing the text file
/etc/ceph/crushmap.txtat the end of the file.vim /etc/ceph/crushmap.txt
$ vim /etc/ceph/crushmap.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe rule
idhas to be unique. In the example, we only have one more crush rule with id 0 hence we are using id 1. If your deployment has more rules created, then use the next free id.The CRUSH rule declared contains the following information:
Rule name:- Description: A unique whole 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
min_size:- Description: If a pool makes fewer replicas than this number, CRUSH will not select this rule.
-
Value:
1
max_size:- Description: If a pool makes more replicas than this number, CRUSH will not select this rule.
-
Value:
10
step take DC1- Description: Takes a bucket name (DC1), and begins iterating down the tree.
step chooseleaf firstn 2 type host- Description: Selects the number of buckets of the given type, in this case is two different hosts located in DC1.
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.
step take DC2- Description: Takes a bucket name (DC2), and begins iterating down the tree.
step chooseleaf firstn 2 type host- Description: Selects the number of buckets of the given type, in this case, is two different hosts located in DC2.
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.
Compile the new CRUSH map from the file
/etc/ceph/crushmap.txtand convert it to a binary file called/etc/ceph/crushmap2.bin:crushtool -c /etc/ceph/crushmap.txt -o /etc/ceph/crushmap2.bin
$ crushtool -c /etc/ceph/crushmap.txt -o /etc/ceph/crushmap2.binCopy to Clipboard Copied! Toggle word wrap Toggle overflow Inject the new crushmap we created back into the cluster:
ceph osd setcrushmap -i /etc/ceph/crushmap2.bin
$ ceph osd setcrushmap -i /etc/ceph/crushmap2.binCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
17
17Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe number 17 is a counter and it will increase (18,19, and so on) depending on the changes you make to the crush map.
Verify that the stretched rule created is now available for use.
ceph osd crush rule ls
ceph osd crush rule lsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
replicated_rule stretch_rule
replicated_rule stretch_ruleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the stretch cluster mode.
ceph mon enable_stretch_mode ceph7 stretch_rule datacenter
$ ceph mon enable_stretch_mode ceph7 stretch_rule datacenterCopy to Clipboard Copied! Toggle word wrap Toggle overflow In this example,
ceph7is the arbiter node,stretch_ruleis the crush rule we created in the previous step anddatacenteris the dividing bucket.Verify all our pools are using the
stretch_ruleCRUSH rule we have created in our Ceph cluster:for pool in $(rados lspools);do echo -n "Pool: ${pool}; ";ceph osd pool get ${pool} crush_rule;done$ for pool in $(rados lspools);do echo -n "Pool: ${pool}; ";ceph osd pool get ${pool} crush_rule;doneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This indicates that a working Red Hat Ceph Storage stretched cluster with arbiter mode is now available.