Edw*_*118 6 linux hard-drive software-raid centos-7
服务器运行 CentOS,并且已成功运行两磁盘软件 RAID。我希望添加第三个磁盘以实现冗余,因此当一个磁盘发生故障时,系统仍然有两个磁盘在运行,直到出现故障的磁盘的替代品到达为止。
当从 DVD-ROM 安装 CentOS 时,我过去就是在其中设置软件两个磁盘 RAID 的。但是,如何将第三个磁盘添加到正在运行的系统中现有的两个磁盘软件 RAID 中呢?
2 个磁盘和冗余表明已使用 RAID1。为了增加冗余,我不认为 RAID5 是一种选择,因为它提供了更多空间,但是 - 对于 3 个磁盘,它与具有 2 个磁盘的 RAID1 相同,并且允许丢失一个磁盘。
所以假设 RAID1:
mdadm --add /dev/mdX /dev/sdY
mdadm --grow --raid-devices=3 /dev/mdX
Run Code Online (Sandbox Code Playgroud)
使用lvm2(镜像或dm-raid)它将是:
vgextend VG /dev/sdY
lvconvert -m2 VG/LV
Run Code Online (Sandbox Code Playgroud)
您想要将 RAID-1重塑为三磁盘 RAID-5 设置。 md幸运的是,您可能正在使用的软件 RAID 支持重塑。
\n\n\n\xef\xbc\xb7\xef\xbc\xa1\xef\xbc\xb2\xef\xbc\xae\xef\xbc\xa9\xef\xbc\xae\xef\xbc\xa7\xef\xbc\x9a 确保您已经备份了数据,以防出现灾难性错误(不太可能,但总是有可能)。
\n
您没有提供有关您的设置的任何详细信息,因此我将从头开始做一个完整的示例,任何人都可以尝试。
\n\nroot@node51 [/tmp]# truncate -s 1G 1.img\nroot@node51 [/tmp]# truncate -s 1G 2.img\nroot@node51 [/tmp]# losetup /dev/loop1 1.img\nroot@node51 [/tmp]# losetup /dev/loop2 2.img\nroot@node51 [/tmp]# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/loop{1,2}\nmdadm: Note: this array has metadata at the start and\n may not be suitable as a boot device. If you plan to\n store \'/boot\' on this device please ensure that\n your boot-loader understands md/v1.x metadata, or use\n --metadata=0.90\nmdadm: size set to 1048000K\nContinue creating array? yes\nmdadm: Defaulting to version 1.2 metadata\nmdadm: array /dev/md0 started.\nRun Code Online (Sandbox Code Playgroud)\n\nRAID-1 阵列的外观:
\n\nroot@node51 [/tmp]# mdadm --detail /dev/md0\n/dev/md0:\n Version : 1.2\n Creation Time : Wed Mar 9 15:30:18 2016\n Raid Level : raid1\n Array Size : 1048000 (1023.61 MiB 1073.15 MB)\n Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)\n Raid Devices : 2\n Total Devices : 2\n Persistence : Superblock is persistent\n\n Update Time : Wed Mar 9 15:30:24 2016\n State : clean\n Active Devices : 2\nWorking Devices : 2\n Failed Devices : 0\n Spare Devices : 0\n\n Name : node51:0 (local to host node51)\n UUID : 9f03708b:dfe27926:16485757:02cbc146\n Events : 17\n\n Number Major Minor RaidDevice State\n 0 7 1 0 active sync /dev/loop1\n 1 7 2 1 active sync /dev/loop2\nRun Code Online (Sandbox Code Playgroud)\n\n我将在此处演示一个简单的文件系统设置和调整大小,但您可以在其他地方找到更详细的调整大小提示(请参阅本答案底部的“其他资源”)。
\n\nroot@node51 [/tmp]# mkfs.ext4 /dev/md0\nmke2fs 1.42.9 (4-Feb-2014)\nDiscarding device blocks: done\nFilesystem label=\nOS type: Linux\nBlock size=4096 (log=2)\nFragment size=4096 (log=2)\nStride=0 blocks, Stripe width=0 blocks\n65536 inodes, 262000 blocks\n13100 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=268435456\n8 block groups\n32768 blocks per group, 32768 fragments per group\n8192 inodes per group\nSuperblock backups stored on blocks:\n 32768, 98304, 163840, 229376\n\nAllocating group tables: done\nWriting inode tables: done\nCreating journal (4096 blocks): done\nWriting superblocks and filesystem accounting information: done\n\nroot@node51 [/tmp]# mount /dev/md0 /mnt\nroot@node51 [/tmp]# df -hT /mnt\nFilesystem Type Size Used Avail Use% Mounted on\n/dev/md0 ext4 992M 1.3M 923M 1% /mnt\nRun Code Online (Sandbox Code Playgroud)\n\nroot@node51 [/tmp]# truncate -s 1G 3.img\nroot@node51 [/tmp]# losetup /dev/loop3 3.img\nroot@node51 [/tmp]# mdadm --add /dev/md0 /dev/loop3\nmdadm: added /dev/loop3\nRun Code Online (Sandbox Code Playgroud)\n\n添加第三个磁盘后,您应该将其视为备用磁盘:
\n\nroot@node51 [/tmp]# mdadm --detail /dev/md0\n/dev/md0:\n Version : 1.2\n Creation Time : Wed Mar 9 15:30:18 2016\n Raid Level : raid1\n Array Size : 1048000 (1023.61 MiB 1073.15 MB)\n Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)\n Raid Devices : 2\n Total Devices : 3\n Persistence : Superblock is persistent\n\n Update Time : Wed Mar 9 15:31:10 2016\n State : clean\n Active Devices : 2\nWorking Devices : 3\n Failed Devices : 0\n Spare Devices : 1\n\n Name : node51:0 (local to host node51)\n UUID : 9f03708b:dfe27926:16485757:02cbc146\n Events : 18\n\n Number Major Minor RaidDevice State\n 0 7 1 0 active sync /dev/loop1\n 1 7 2 1 active sync /dev/loop2\n\n 2 7 3 - spare /dev/loop3\nRun Code Online (Sandbox Code Playgroud)\n\nroot@node51 [/tmp]# mdadm --grow /dev/md0 --level=5 --raid-devices=3\nmdadm: level of /dev/md0 changed to raid5\nmdadm: Need to backup 128K of critical section..\nRun Code Online (Sandbox Code Playgroud)\n\n这可能需要很长时间。 您可以检查cat /proc/mdstat一下进度:
root@node51 [/tmp]# cat /proc/mdstat\nPersonalities : [raid1] [raid6] [raid5] [raid4]\nmd0 : active raid5 loop3[2] loop2[1] loop1[0]\n 1048000 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/3] [UUU]\n [=====>...............] reshape = 25.0% (262208/1048000) finish=0.1min speed=87360K/sec\n\nunused devices: <none>\nRun Code Online (Sandbox Code Playgroud)\n\nroot@node51 [/tmp]# mdadm --detail /dev/md0\n/dev/md0:\n Version : 1.2\n Creation Time : Wed Mar 9 15:30:18 2016\n Raid Level : raid5\n Array Size : 2096000 (2047.22 MiB 2146.30 MB)\n Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)\n Raid Devices : 3\n Total Devices : 3\n Persistence : Superblock is persistent\n\n Update Time : Wed Mar 9 15:31:49 2016\n State : clean\n Active Devices : 3\nWorking Devices : 3\n Failed Devices : 0\n Spare Devices : 0\n\n Layout : left-symmetric\n Chunk Size : 64K\n\n Name : node51:0 (local to host node51)\n UUID : 9f03708b:dfe27926:16485757:02cbc146\n Events : 41\n\n Number Major Minor RaidDevice State\n 0 7 1 0 active sync /dev/loop1\n 1 7 2 1 active sync /dev/loop2\n 2 7 3 2 active sync /dev/loop3\nRun Code Online (Sandbox Code Playgroud)\n\n在这里,你可以看到我通过ext4的在线扩展功能1GiB变成的大约文件系统:2GiB
root@node51 [/tmp]# df -hT /mnt\nFilesystem Type Size Used Avail Use% Mounted on\n/dev/md0 ext4 992M 1.3M 923M 1% /mnt\nroot@node51 [/tmp]# resize2fs /dev/md0\nresize2fs 1.42.9 (4-Feb-2014)\nFilesystem at /dev/md0 is mounted on /mnt; on-line resizing required\nold_desc_blocks = 1, new_desc_blocks = 1\nThe filesystem on /dev/md0 is now 524000 blocks long.\n\nroot@node51 [/tmp]# df -hT /mnt\nFilesystem Type Size Used Avail Use% Mounted on\n/dev/md0 ext4 2.0G 1.5M 1.9G 1% /mnt\nRun Code Online (Sandbox Code Playgroud)\n\n对于其他文件系统大小调整方案,请参阅本答案末尾的“其他资源”。
\n\n以下是如何拆除和删除上面的示例:
\n\nroot@node51 [/tmp]# umount /mnt\nroot@node51 [/tmp]# mdadm --stop /dev/md0\nmdadm: stopped /dev/md0\nroot@node51 [/tmp]# losetup -d /dev/loop1\nroot@node51 [/tmp]# losetup -d /dev/loop2\nroot@node51 [/tmp]# losetup -d /dev/loop3\nroot@node51 [/tmp]# rm -fv /tmp/{1,2,3}.img\nremoved \xe2\x80\x98/tmp/1.img\xe2\x80\x99\nremoved \xe2\x80\x98/tmp/2.img\xe2\x80\x99\nremoved \xe2\x80\x98/tmp/3.img\xe2\x80\x99\nRun Code Online (Sandbox Code Playgroud)\n\n我写了一些关于文件系统调整大小的其他答案。您可以使用相同的概念来扩展 RAID 中的文件系统。
\n\n\n| 归档时间: |
|
| 查看次数: |
4498 次 |
| 最近记录: |