{"id":116068,"date":"2018-08-21T08:55:08","date_gmt":"2018-08-21T00:55:08","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=116068"},"modified":"2018-08-20T08:59:13","modified_gmt":"2018-08-20T00:59:13","slug":"linux-raid","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-raid.html","title":{"rendered":"Linux\u7cfb\u7edf\u4e2d\u8f6fraid\u5b9e\u73b0\u65b9\u6848"},"content":{"rendered":"
Raid\u5927\u5bb6\u90fd\u77e5\u9053\u662f\u5197\u4f59\u78c1\u76d8\u7684\u610f\u601d\uff08Redundant Arrays of Independent Disks\uff0cRAID\uff09\uff0c\u53ef\u4ee5\u6309\u4e1a\u52a1\u7cfb\u7edf\u7684\u9700\u8981\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u5197\u4f59\u6027\uff0c\u76ee\u524d\u5e02\u9762\u4e0a\u6bd4\u8f83\u5e38\u89c1\u7684\u662f\u901a\u8fc7\u670d\u52a1\u5668\u7684raid\u9635\u5217\u5361\u6765\u5b9e\u73b0\u6b64\u529f\u80fd\u3002<\/p>\n
\u901a\u8fc7\u786c\u4ef6\u9635\u5217\u5361\u5b9e\u73b0raid\u5177\u6709\u53ef\u9760\u6027\u9ad8\uff0c\u6027\u80fd\u597d\u7b49\u7279\u70b9\uff0c\u4f46\u662f\u5bf9\u4e8e\u4e00\u822c\u7684\u4f01\u4e1a\u800c\u8a00\u786c\u4ef6\u9635\u5217\u5361\u56fa\u7136\u597d\uff0c\u5982\u679c\u5927\u89c4\u6a21\u5e94\u7528\u7684\u8bdd\u52a8\u8f84\u51e0\u5343\u4e0a\u4e07\u7684\u8d39\u7528\u4e5f\u4e0d\u662f\u4ed6\u4eec\u6240\u80fd\u627f\u53d7\u7684\uff0c\u96be\u9053\u5c31\u6ca1\u6709\u65e2\u80fd\u4fdd\u8bc1\u6570\u636e\u5b89\u5168\uff0c\u53c8\u80fd\u51cf\u5c11\u8d39\u7528\u652f\u6301\u7684IT\u65b9\u6848\u5417\uff1f\u5f53\u7136\u6709\uff0c\u8f6fraid\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u9700\u6c42\u3002<\/p>\n<\/div>\n
\u4e00\u53f0centos 7.2 VM\uff0c\u4e3b\u673a\u540d\u5206\u522b\u4e3ahost1\uff0chost1\u4e0a\u6302\u8f7d\u4e24\u575750G\u7684\u6570\u636e\u76d8\uff0c\u6211\u4eec\u7684\u5b9e\u9a8c\u5c31\u5728\u8fd9\u4e24\u5757\u6570\u636e\u76d8\u4e0a\u5b8c\u6210\u3002<\/p>\n
P.S:\u9700\u8981\u5f3a\u8c03\u7684\u662f\u751f\u4ea7\u73af\u5883\u4e0b\u4e24\u5757\u7ec4raid\u7684\u786c\u76d8\u5fc5\u987b\u662f\u540c\u54c1\u724c\u540c\u578b\u53f7\u540c\u5bb9\u91cf\u7684\uff0c\u5426\u5219\u6781\u5bb9\u6613\u51fa\u73b0\u8f6fraid\u5931\u6548\u7684\u60c5\u51b5\u3002<\/p>\n
1.\u786e\u8ba4\u64cd\u4f5c\u7cfb\u7edf\u662f\u5426\u5b89\u88c5\u4e86mdadm\u8f6f\u4ef6<\/p>\n
[root@host1 ~]# rpm -qa |grep mdadm<\/span> 2.\u5bf9\u4e24\u5757\u6570\u636e\u76d8\u8fdb\u884c\u5206\u533a\uff0c\u5e76\u8bbe\u7f6e\u5206\u533a\u7c7b\u578b\u4e3araid<\/p>\n <\/p>\n fdisk\u547d\u4ee4\u53ea\u80fd\u5bf9\u5bb9\u91cf\u57282T\u4ee5\u4e0b\u7684\u786c\u76d8\u8fdb\u884c\u5206\u533a\uff0c\u5982\u679c\u8d85\u8fc72T\u5219\u9700\u8981\u4f7f\u7528parted\u5de5\u5177\u4e86\u3002Parted\u547d\u4ee4\u4ee5\u540e\u4f1a\u4ecb\u7ecd\u4f7f\u7528\u65b9\u6cd5\uff0c\u672c\u8282\u4e0d\u8d58\u8ff0\u4e86\u3002<\/p>\n \u5728fdisk\u4e0braid\u7684\u5206\u533a\u7c7b\u578b\u4ee3\u7801\u662ffd\uff0c\u5728parted\u5de5\u5177\u4e0b\u9996\u5148\u9700\u8981\u4f7f\u7528mklabel\u5c06\u78c1\u76d8\u683c\u5f0f\u7531MBR\u6539\u6210GPT\uff0c\u7136\u540e\u624d\u80fd\u4f7f\u7528mkpart\u547d\u4ee4\u8fdb\u884c\u5206\u533a\uff0c\u5206\u5b8c\u533a\u4e4b\u540e\u4f7f\u7528set\u8bbe\u7f6e\u5206\u533aflag\u4e3araid\u5373\u53ef\u3002<\/p>\n 3.\u4f7f\u7528mdadm\u547d\u4ee4\u521b\u5efaraid1<\/p>\n <\/p>\n \u53ef\u4ee5\u770b\u5230\u521b\u5efa\u65f6\u6709\u4e2aNote\u7684\u63d0\u793a\uff0c\u662f\u8bf4\u8f6fraid\u4e0d\u80fd\u5f53\u542f\u52a8\u8bbe\u5907\uff0c\u8fd9\u5c31\u662f\u8f6fraid\u6bd4\u8f83\u9e21\u808b\u7684\u5730\u65b9\u4e86\u3002<\/p>\n<\/div>\n mdadm -C \/dev\/md0 -ayes -l1 -n2 \/dev\/xvd[b,c]1<\/span> <\/p>\n \u4e5f\u53ef\u4ee5\u4f7f\u7528mdadm -D \/dev\/md0<\/span>\u67e5\u770b\u9635\u5217\u7ec4\u7684\u72b6\u6001<\/p>\n <\/p>\n <\/p>\n 4.\u521b\u5efamd0\u7684\u914d\u7f6e\u6587\u4ef6 <\/p>\n \u539f\u6587\u6765\u81ea\uff1ahttp:\/\/blog.chinaunix.net\/uid-26252206-id-5785379.html<\/a><\/p>\n
\nmdadm-3.3.2-7.el7.x86_64<\/span><\/p>\n
\n\u547d\u4ee4\u8bf4\u660e\uff1a
\n-C<\/span>\u521b\u5efa\u9635\u5217;
\n-a<\/span>\u540c\u610f\u521b\u5efa\u8bbe\u5907\uff0c\u5982\u4e0d\u52a0\u6b64\u53c2\u6570\u65f6\u5fc5\u987b\u5148\u4f7f\u7528mknod \u547d\u4ee4\u6765\u521b\u5efa\u4e00\u4e2aRAID\u8bbe\u5907\uff0c\u4e0d\u8fc7\u63a8\u8350\u4f7f\u7528-a yes\u53c2\u6570\u4e00\u6b21\u6027\u521b\u5efa;
\n-l<\/span>\u9635\u5217\u6a21\u5f0f;
\n-n<\/span>\u9635\u5217\u4e2d\u6d3b\u52a8\u78c1\u76d8\u7684\u6570\u76ee\uff0c\u8be5\u6570\u76ee\u52a0\u4e0a\u5907\u7528\u78c1\u76d8\u7684\u6570\u76ee\u5e94\u8be5\u7b49\u4e8e\u9635\u5217\u4e2d\u603b\u7684\u78c1\u76d8\u6570\u76ee;
\n\/dev\/md0<\/span>\u9635\u5217\u7684\u8bbe\u5907\u540d\u79f0\uff0c\u5982\u679c\u8fd8\u6709\u5176\u4ed6\u9635\u5217\u7ec4\u53ef\u4ee5\u4ee5\u6b64\u7c7b\u63a8\uff1b
\n\u521b\u5efa\u5b8c\u6210\u540e\u53ef\u4ee5\u4f7f\u7528cat \/proc\/mdstat<\/span>\u67e5\u770b\u9635\u5217\u72b6\u6001\uff1a
\n\u4e0b\u56fe\u4e2d\u7b2c\u4e00\u6b21\u67e5\u770b\u7684\u65f6\u5019\u63d0\u793aresync\u5b8c\u6210\u4e8695.7%\uff0c\u7b2c\u4e8c\u6b21\u67e5\u8be2\u7684\u65f6\u5019\u4e24\u5757\u76d8\u624d\u771f\u6b63\u540c\u6b65\u5b8c\u3002<\/p>\n
\necho DEVICE \/dev\/sd{a,b}1 >> \/etc\/mdadm.conf<\/span>
\nmdadm -Evs >> \/etc\/mdadm.conf<\/span>
\nmdadm\u8fd0\u884c\u65f6\u4f1a\u81ea\u52a8\u68c0\u67e5\/etc\/mdadm.conf<\/span> \u6587\u4ef6\u5e76\u5c1d\u8bd5\u81ea\u52a8\u88c5\u914d\uff0c\u56e0\u6b64\u7b2c\u4e00\u6b21\u914d\u7f6eraid\u540e\u53ef\u4ee5\u5c06\u4fe1\u606f\u5bfc\u5165\u5230\/etc\/mdadm.conf<\/span> \u4e2d\u3002
\n5.\u4f7f\u7528\/dev\/md0
\n\u5728\/dev\/md0\u4e0a\u521b\u5efa\u6587\u4ef6\uff0c\u7136\u540e\u6302\u8f7d\u8fdb\u884c\u4f7f\u7528\u3002
\nmkfs.ext4 \/dev\/md0<\/span><\/p>\n\n