RAID 1 = mirrored pair of two hard disks
If one disk fail, the raid will continue to be operational.
Read performance will be increased for parallel read operations.
Write performance will be likely the same (almost the same).
yum install mdadm
mkfs.xfs -f -L DISK1 /dev/sda
-f = force
-L = hdd label
mkfs.xfs -f -L DISK2 /dev/sdb
mdadm --verbose --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sda /dev/sdb
mkfs.xfs /dev/md0
mkdir /data1
mount /dev/md0 /data1
Edit /etc/fstab and add:
/dev/md0 /data1 xfs defaults 0 0
mdadm --detail --scan --verbose >> /etc/mdadm.conf
mdadm -D /dev/md0
/dev/md0: Version : 1.2 Creation Time : Mon Apr 13 03:07:50 2020 Raid Level : raid1 Array Size : 3906886464 (3725.90 GiB 4000.65 GB) Used Dev Size : 3906886464 (3725.90 GiB 4000.65 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Intent Bitmap : Internal Update Time : Mon Apr 13 15:24:47 2020 State : clean, resyncing Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Consistency Policy : bitmap Resync Status : 90% complete Name : medjavaro:0 (local to host medjavaro) UUID : 257d9837:5eda9e27:59a51c12:d139b615 Events : 15822 Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sda 1 8 32 1 active sync /dev/sdb
Suppose the /dev/sdb hard disk failed.
To replace it with a good hdd, set it as failed and remove it from the array:
mdadm /dev/md0 --fail /dev/sdb --remove /dev/sdb
Add the new device to the array:
mdadm --add /dev/md0 /dev/sdb
After reinserting the hard disk, it may be mounted now on a different device letter.
Ckeck it by running:
fdisk -l
Output:
... Disk /dev/sdd: 4000.8 GB, 4000787029504 bytes, 7814037167 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
After identifying it, re-add it to the raid array with:
mdadm --manage /dev/md0 --add /dev/sdd