blob: 79b214915d9950d0bbc6edd96910ca875bfa6e19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/env bash
set -x
./bin/ceph config set osd osd_crush_update_on_start false
./bin/ceph osd crush move osd.0 host=host1-1 datacenter=site1 root=default
./bin/ceph osd crush move osd.1 host=host1-2 datacenter=site1 root=default
./bin/ceph osd crush move osd.2 host=host2-1 datacenter=site2 root=default
./bin/ceph osd crush move osd.3 host=host2-2 datacenter=site2 root=default
./bin/ceph osd getcrushmap > crush.map.bin
./bin/crushtool -d crush.map.bin -o crush.map.txt
cat <<EOF >> crush.map.txt
rule stretch_rule {
id 1
type replicated
step take site1
step chooseleaf firstn 2 type host
step emit
step take site2
step chooseleaf firstn 2 type host
step emit
}
rule stretch_rule2 {
id 2
type replicated
step take site1
step chooseleaf firstn 2 type host
step emit
step take site2
step chooseleaf firstn 2 type host
step emit
}
rule stretch_rule3 {
id 3
type replicated
step take site1
step chooseleaf firstn 2 type host
step emit
step take site2
step chooseleaf firstn 2 type host
step emit
}
EOF
./bin/crushtool -c crush.map.txt -o crush2.map.bin
./bin/ceph osd setcrushmap -i crush2.map.bin
./bin/ceph mon set election_strategy connectivity
./bin/ceph mon set_location a datacenter=site1
./bin/ceph mon set_location b datacenter=site2
./bin/ceph mon set_location c datacenter=site3
./bin/ceph osd pool create test_stretch1 1024 1024 replicated
./bin/ceph mon enable_stretch_mode c stretch_rule datacenter
|