A’ dèanamh lethbhreac de mheudan gu siostaman stòraidh tro fhrithealaiche Linux a’ cleachdadh XCOPY

Tha e a’ tachairt gum feum thu leth-bhreac slàn fhaighinn de leabhar taobh a-staigh aon shiostam stòraidh dàta (DSS), chan e dealbh, clon, ach leabhar iomlan. Ach chan eil an siostam stòraidh an-còmhnaidh a’ leigeil le seo a dhèanamh air an taobh a-staigh a’ cleachdadh a dhòighean fhèin. Tha e coltach gur e an aon roghainn lethbhreac a dhèanamh tron ​​​​fhrithealaiche, ach anns a 'chùis seo thèid an àireamh iomlan de dhàta a ghluasad tron ​​​​fhrithealaiche fhèin, an lìonra chun an t-siostam stòraidh agus na puirt stòraidh, a' luchdachadh na co-phàirtean sin uile. Ach tha òrdughan SCSI ann a leigeas leat a h-uile càil a dhèanamh taobh a-staigh an t-siostam stòraidh fhèin, agus ma tha an siostam agad a’ toirt taic do VAAI bho VMware, tha e faisg air 100% gu bheil an àithne XCOPY (EXTENDED COPY) a’ faighinn taic, a tha ag innse don raon dè agus far an dèan thu lethbhreac, gun a bhith a’ toirt a-steach frithealaiche pròiseas agus lìonra.

Tha e coltach gum bu chòir a h-uile dad a bhith sìmplidh, ach cha b’ urrainn dhomh sgriobtaichean deiseil a lorg anns a ’bhad, agus mar sin bha agam ris a’ chuibhle ath-thòiseachadh. Chaidh Linux a thaghadh airson OS an fhrithealaiche, agus chaidh an àithne ddpt (http://sg.danny.cz/sg/ddpt.html) a thaghadh mar an inneal copaidh. A’ cleachdadh a’ chothlamadh seo, faodaidh tu leabhraichean a chopaigeadh bho OS sam bith, leis gu bheil copaidh a’ tachairt bloc-air-bloc air taobh an t-siostam stòraidh. Leis gu bheil e riatanach bloc a chopaigeadh le bloc, agus feumar an àireamh de bhlocaichean a chunntadh, chaidh an àithne blockdev a chleachdadh gus an àireamh de dh’ ath-aithrisean mar sin a chunntadh. Chaidh am meud bloca as àirde fhaighinn gu deuchainneach; cha do dh’ obraich ddpt le bloc mòr. B’ e an toradh an sgriobt gu math sìmplidh a leanas:

#!/bin/bash
# first parameter = input device
# second parameter = output device
# device size must be the same
# changing bs variable can reduce speed, max speed should be at bs=32768. 32768 is max setting, lower settings should be calculated dividing by 2

set -o nounset
bs=32768
s=`blockdev --getsz $1`
i=0
while [ $i -le $s ]
do
ddpt of=$2 bs=512 oflag=xcopy,direct if=$1 iflag=xcopy,direct count=$bs verbose=-1 skip=$i seek=$i
i=$(( $i+$bs ))
done

Feuch an dèan sinn sgrùdadh beag! Uill, mar fhear beag, cha deach faidhle 1TB a chruthachadh gu sgiobalta agus a sgrùdadh le md5sum :)

root@sales-demo-05:/home/vasilyk# blockdev --getsz /dev/mapper/mpathfs
2516582400
root@sales-demo-05:/home/vasilyk# blockdev --getsz /dev/mapper/mpathfr
2516582400
root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfs /xcopy_source/
mount: /xcopy_source: wrong fs type, bad option, bad superblock on /dev/mapper/mpathfs, missing codepage or helper program, or other error.
root@sales-demo-05:/home/vasilyk# mkfs /dev/mapper/mpathfs
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 314572800 4k blocks and 78643200 inodes
Filesystem UUID: bed3ea00-c181-4b4e-b52e-d9bb498be756
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfs /xcopy_source/
root@sales-demo-05:/home/vasilyk# ls -l /xcopy_source/
total 16
drwx------ 2 root root 16384 Aug 19 15:35 lost+found
root@sales-demo-05:/home/vasilyk# head -c 1T </dev/urandom > /xcopy_source/1TB_file
root@sales-demo-05:/home/vasilyk# ls -l /xcopy_source/
total 1074791444
-rw-r--r-- 1 root root 1099511627776 Aug 19 17:25 1TB_file
drwx------ 2 root root         16384 Aug 19 15:35 lost+found
root@sales-demo-05:/home/vasilyk# umount /xcopy_source
root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfr /xcopy_dest/
mount: /xcopy_dest: wrong fs type, bad option, bad superblock on /dev/mapper/mpathfr, missing codepage or helper program, or other error.
root@sales-demo-05:/home/vasilyk# cat xcopy.sh
#!/bin/bash
# first parameter = input device
# second parameter = output device
# device size must be the same
# changing bs variable can reduce speed, max speed should be at bs=32768. 32768 is max setting, lower settings should be calculated dividing by 2

bs=32768
s=`blockdev --getsz $1`
i=0
while [ $i -le $s ]
do
ddpt of=$2 bs=512 oflag=xcopy,direct if=$1 iflag=xcopy,direct count=$bs verbose=-1 skip=$i seek=$i
i=$(( $i+$bs ))
done
root@sales-demo-05:/home/vasilyk# time ./xcopy.sh /dev/mapper/mpathfs /dev/mapper/mpathfr
real    11m30.878s
user    2m3.000s
sys     1m11.657s

Na bha a’ tachairt air an t-siostam stòraidh aig an àm sin:

A’ dèanamh lethbhreac de mheudan gu siostaman stòraidh tro fhrithealaiche Linux a’ cleachdadh XCOPY
Leanaidh sinn oirnn le Linux.

root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfr /xcopy_dest/
root@sales-demo-05:/home/vasilyk# ls -l /xcopy_dest/
total 1074791444
-rw-r--r-- 1 root root 1099511627776 Aug 19 17:25 1TB_file
drwx------ 2 root root         16384 Aug 19 15:35 lost+found
root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfs /xcopy_source/
root@sales-demo-05:/home/vasilyk# md5sum /xcopy_source/1TB_file
53dc6dfdfc89f099c0d5177c652b5764  /xcopy_source/1TB_file
root@sales-demo-05:/home/vasilyk# md5sum /xcopy_dest/1TB_file
53dc6dfdfc89f099c0d5177c652b5764  /xcopy_dest/1TB_file
root@sales-demo-05:/home/vasilyk#

Dh’ obraich a h-uile càil a-mach, ach dèan deuchainn agus cleachd air do chunnart fhèin! Mar stòr meud, tha e nas fheàrr dealbhan a thogail, airson tòiseachadh.

Source: www.habr.com

Cuir beachd ann