writeback cache_mode
[gnt-info] / doc / megaraid-to-md.txt
1 In our testing, md raid10 is about 30% faster than megaraid's internal raid10.
2
3 Here are steps to replace hardware megaraid with software md5 on ganeti.
4
5
6
7
8 root@lib30:/srv/gnt-info# gnt-node migrate lib28
9
10 root@lib30:/srv/gnt-info# gnt-node modify --drained yes lib28
11
12 root@lib30:/srv/gnt-info# hbal -L -X
13
14
15
16 This will migrate instances from node, marked it as drained and then hbal will re-distribute drbd disks
17 from it to rest of cluster.
18
19 Alternative is to use modify -t plain, but that requires instance reboot.
20
21
22 root@lib28:~# vgremove ffzgvg
23
24 root@lib28:~# pvremove /dev/bcache0 
25
26
27
28 Then, we need to find bcache block device and deactiate it:
29
30 root@lib28:~# cd /sys/fs/bcache/
31 root@lib28:/sys/fs/bcache# cd 4a61e966-f18d-4fab-836a-3ff027963781/
32
33 root@lib28:/sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781# ls -al bdev0
34 lrwxrwxrwx 1 root root 0 Sep 19 19:46 bdev0 -> ../../../devices/pci0000:00/0000:00:02.2/0000:03:00.0/host0/target0:2:0/0:2:0:0/block/sdb/bcache
35
36
37 root@lib28:~# echo 1 > /sys/block/sdb/bcache/stop 
38 [Wed Sep 19 20:05:53 2018] bcache: bcache_device_free() bcache0 stopped
39
40 root@lib28:~# megacli -CfgDsply -a0
41
42
43 Erase existing config
44
45 root@lib28:~# megacli -CfgLdDel -L0 -a0
46                                      
47 Adapter 0: Deleted Virtual Drive-0(target id-0)
48
49 Exit Code: 0x00
50
51
52 Convert all disks to jbod
53
54 root@lib28:~# megacli -PDMakeJBOD -PhysDrv[32:0] -a0
55                                      
56 Adapter: 0: EnclId-32 SlotId-0 state changed to JBOD.
57
58 Exit Code: 0x00
59
60 root@lib28:~# megacli -PDMakeJBOD -PhysDrv[32:1] -a0
61
62 ...
63
64 megacli -PDMakeJBOD -PhysDrv[32:6] -a0
65                                      
66 Adapter: 0: Failed to change PD state at EnclId-32 SlotId-6.
67
68 Exit Code: 0x01
69
70
71 This probably means that it has foreign config (makes sense, 7th disk
72 comes from another server with raid on it):
73
74 root@lib28:~# megacli -CfgForeign -Clear 0 -a0
75                                      
76 Foreign configuration 0 is cleared on controller 0.
77
78 Exit Code: 0x00
79
80
81 root@lib28:~# megacli -PDMakeJBOD -PhysDrv[32:6] -a0
82                                      
83 Adapter: 0: EnclId-32 SlotId-6 state changed to JBOD.
84
85 Exit Code: 0x00
86
87
88 root@lib28:~# lsblk --scsi -m
89 NAME HCTL       TYPE VENDOR   MODEL             REV TRAN NAME   SIZE OWNER GROUP MODE
90 sda  0:0:7:0    disk ATA      INTEL SSDSC2BW24 DC32      sda  223.6G root  disk  brw-rw----
91 sdb  0:0:0:0    disk ATA      ST1000NM0033-9ZM GA0A      sdb  931.5G root  disk  brw-rw----
92 sdc  0:0:1:0    disk ATA      ST1000NM0033-9ZM GA0A      sdc  931.5G root  disk  brw-rw----
93 sdd  0:0:2:0    disk ATA      ST1000NM0033-9ZM GA0A      sdd  931.5G root  disk  brw-rw----
94 sde  0:0:3:0    disk ATA      ST1000NM0033-9ZM GA0A      sde  931.5G root  disk  brw-rw----
95 sdf  0:0:4:0    disk ATA      ST1000NM0033-9ZM GA0A      sdf  931.5G root  disk  brw-rw----
96 sdg  0:0:5:0    disk ATA      ST1000NM0033-9ZM GA0A      sdg  931.5G root  disk  brw-rw----
97 sdh  0:0:6:0    disk ATA      ST1000NM0033-9ZM GA0A      sdh  931.5G root  disk  brw-rw----
98
99 root@lib28:~# mdadm --create /dev/md0 --level=10 --raid-devices=7 /dev/sd{b,c,d,e,f,g,h}
100 mdadm: cannot open /dev/sdb: Device or resource busy
101 root@lib28:~# lsblk 
102 NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
103 sda         8:0    0 223.6G  0 disk 
104 ├─sda1      8:1    0   260M  0 part /boot/efi
105 ├─sda2      8:2    0    10G  0 part /
106 └─sda3      8:3    0 213.3G  0 part 
107 sdb         8:16   0 931.5G  0 disk 
108 └─bcache0 254:0    0 931.5G  0 disk 
109 sdc         8:32   0 931.5G  0 disk 
110 └─bcache1 254:1    0 931.5G  0 disk 
111 sdd         8:48   0 931.5G  0 disk 
112 sde         8:64   0 931.5G  0 disk 
113 sdf         8:80   0 931.5G  0 disk 
114 sdg         8:96   0 931.5G  0 disk 
115 sdh         8:112  0 931.5G  0 disk 
116
117 Duh!
118
119 root@lib28:~# wipefs /dev/sda 
120 offset               type
121 ----------------------------------------------------------------
122 0x1018               bcache   [other]
123                      UUID:  2dbf6232-0e89-4d7b-87c7-79897b0a34f2
124
125 root@lib28:~# wipefs /dev/sdb
126 offset               type
127 ----------------------------------------------------------------
128 0x1018               bcache   [other]
129                      UUID:  2dbf6232-0e89-4d7b-87c7-79897b0a34f2
130
131 root@lib28:~# echo 1 > /sys/block/sda/bcache/stop 
132 root@lib28:~# [Wed Sep 19 20:25:14 2018] bcache: bcache_device_free() bcache0 stopped
133
134 root@lib28:~# echo 1 > /sys/block/sdb/bcache/stop 
135 root@lib28:~# [Wed Sep 19 20:25:20 2018] bcache: bcache_device_free() bcache1 stopped
136
137 root@lib28:~# lsblk 
138 NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
139 sda      8:0    0 931.5G  0 disk 
140 sdb      8:16   0 931.5G  0 disk 
141 sdc      8:32   0 931.5G  0 disk 
142 sdd      8:48   0 931.5G  0 disk 
143 sde      8:64   0 931.5G  0 disk 
144 sdf      8:80   0 931.5G  0 disk 
145 sdg      8:96   0 931.5G  0 disk 
146 sdh      8:112  0 223.6G  0 disk 
147 ├─sdh1   8:113  0   260M  0 part /boot/efi
148 ├─sdh2   8:114  0    10G  0 part /
149 └─sdh3   8:115  0 213.3G  0 part 
150
151 root@lib28:~# mdadm --create /dev/md0 --level=10 --raid-devices=7 /dev/sd{a,b,c,d,e,f,g}
152 mdadm: Defaulting to version 1.2 metadata
153 mdadm: array /dev/md0 started.
154
155 ...
156
157 Wait for rebuild, install bios update, reboot as needed.
158
159 root@lib28:~# dmidecode | grep 'BIOS Rev'
160         BIOS Revision: 2.7
161
162 root@lib28:~# hdparm -Tt /dev/sdh /dev/sda /dev/md0
163
164 # ssd
165 /dev/sdh:
166  Timing cached reads:   13856 MB in  1.99 seconds = 6950.11 MB/sec
167  Timing buffered disk reads: 940 MB in  3.00 seconds = 313.22 MB/sec
168
169 # single drive
170 /dev/sda:
171  Timing cached reads:   13722 MB in  1.99 seconds = 6883.27 MB/sec
172  Timing buffered disk reads: 572 MB in  3.01 seconds = 190.06 MB/sec
173
174 # raid10, 7 disks
175 /dev/md0:
176  Timing cached reads:   13826 MB in  1.99 seconds = 6935.19 MB/sec
177  Timing buffered disk reads: 1888 MB in  3.01 seconds = 628.05 MB/sec
178
179
180
181 root@lib28:~# cat /proc/mdstat 
182 Personalities : [raid10] [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] 
183 md127 : active (auto-read-only) raid10 sda[0] sdc[2] sdd[3] sdf[5] sdg[6] sdb[1] sde[4]
184       3418209280 blocks super 1.2 512K chunks 2 near-copies [7/7] [UUUUUUU]
185       bitmap: 0/26 pages [0KB], 65536KB chunk
186
187 root@lib28:~# make-bcache -B /dev/md127 
188 UUID:                   1c2c022b-5ed1-48d2-9ec9-499465af71a8
189 Set UUID:               83ad5994-b266-4e4b-ab6d-9be8fe419e62
190 version:                1
191 block_size:             1
192 data_offset:            16
193 [Thu Sep 20 02:23:12 2018] bcache: register_bdev() registered backing device md127
194
195
196 Now attach cache device back to it:
197
198 root@lib28:~# bcache-super-show /dev/sdh3 | grep cset.uuid
199 cset.uuid               4a61e966-f18d-4fab-836a-3ff027963781
200
201 root@lib28:~# echo 4a61e966-f18d-4fab-836a-3ff027963781 > /sys/block/bcache0/bcache/attach 
202 [Thu Sep 20 14:18:08 2018] bcache: bch_cached_dev_attach() Caching md127 as bcache0 on set 4a61e966-f18d-4fab-836a-3ff027963781
203
204
205 Verify that bcache is active (values should NOT be all zeros if it's working):
206
207 root@lib28:~# grep . /sys/fs/bcache/*/stats_total/*
208 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/bypassed:40.8M
209 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_bypass_hits:0
210 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_bypass_misses:11
211 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_hit_ratio:0
212 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_hits:0
213 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_miss_collisions:0
214 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_misses:128
215 /sys/fs/bcache/4a61e966-f18d-4fab-836a-3ff027963781/stats_total/cache_readaheads:0
216
217 root@lib26:~# cat /sys/block/bcache0/bcache/state
218 clean
219
220
221 Optionally you might want to turn on writeback mode and then state will change
222
223 root@lib28:~# echo writeback > /sys/block/bcache0/bcache/cache_mode
224 root@lib28:~# cat /sys/block/bcache0/bcache/state
225 dirty
226
227
228
229
230 root@lib28:~# pvcreate /dev/bcache0 
231   Configuration setting "activation/thin_check_executable" unknown.
232   Physical volume "/dev/bcache0" successfully created.
233
234 root@lib28:~# vgcreate ffzgvg /dev/bcache0 
235   Configuration setting "activation/thin_check_executable" unknown.
236   Volume group "ffzgvg" successfully created
237
238
239 root@lib30:~# gnt-node modify --drained no lib28
240
241
242 We should run hbal now to re-balance drbd, but we will first migrate all instances from next
243 node to upgrade to save one copy of data over cluster
244
245 root@lib30:~# gnt-node migrate lib24
246
247 root@lib30:~# gnt-node modify --drained yes lib24
248
249 root@lib30:~# hbal -L -X
250