{"id":7,"date":"2012-03-18T14:46:18","date_gmt":"2012-03-18T06:46:18","guid":{"rendered":"http:\/\/www.datarelab.com\/blog\/?p=7"},"modified":"2012-03-18T14:46:18","modified_gmt":"2012-03-18T06:46:18","slug":"lvm%e7%9a%84%e5%bb%ba%e7%ab%8b%e4%b8%8e%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.datarelab.com\/blog\/Technical_literature\/7.html","title":{"rendered":"LVM\u7684\u5efa\u7acb\u4e0e\u7ba1\u7406"},"content":{"rendered":"<p><span style=\"line-height:23px;font-family:verdana;webkit-border-horizontal-spacing:10px;webkit-border-vertical-spacing:10px;\" class=\"Apple-style-span\"> <\/p>\n<p><span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LVM\u662f Logical Volume Manager(\u903b\u8f91\u5377\u7ba1\u7406)\u7684\u7b80\u5199\uff0c\u5b83\u662fLinux\u73af\u5883\u4e0b\u5bf9\u78c1\u76d8\u5206\u533a\u8fdb\u884c\u7ba1\u7406\u7684\u4e00\u79cd\u673a\u5236\uff0c\u5b83\u7531Heinz Mauelshagen\u5728Linux 2.4\u5185\u6838\u4e0a\u5b9e\u73b0\uff0c\u76ee\u524d\u6700\u65b0\u7248\u672c\u4e3a\uff1a\u7a33\u5b9a\u72481.0.5\uff0c\u5f00\u53d1\u7248 1.1.0-rc2\uff0c\u4ee5\u53caLVM2\u5f00\u53d1\u7248\u3002<\/span><\/p>\n<p><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u4e00.LVM\u5377\u7684\u5efa\u7acb<\/span><\/strong><\/span><\/p>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"color:#ff0000;font-size:12px;\">&nbsp;1.\u4e3a\u4e86\u5728\u7ea2\u5e3d\u4f01\u4e1a\u7248\u7cfb\u7edf\u4e0a\u521d\u59cb\u5316LVM\uff0c\u5fc5\u987b\u6267\u884c\u547d\u4ee4vgscan<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:12px;\">\u6765\u67e5\u627e\u662f\u5426\u6709\u5377\u7ec4\u548c\u7269\u7406\u5377\u3002<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;2.fdisk \/dev\/sde&nbsp;&nbsp; ( \u5efa\u7acb\u4e00\u4e2a\u6807\u8bc6\u7b26\u4e3a\u201c8e\u201d\u7684\u5206\u533a)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp; fdisk \/dev\/sdd&nbsp;&nbsp; (\u540c\u4e0a)<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;3.\u5efa\u7acb\u7269\u7406\u5377\uff0c\u53ef\u4ee5\u540c\u65f6\u5199\u591a\u4e2a<br \/>\n<\/span><span style=\"font-size:12px;\">&nbsp;pvcreate \/dev\/sde1 \/dev\/sdf1&nbsp;<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;4.\u5efa\u7acb\u5377\u7ec4(\u6ce8\uff1a\u5377\u7ec4\u672a\u683c\u5f0f)<br \/>\n<\/span><span style=\"font-size:12px;\">&nbsp;vgcreate VG1 \/dev\/sde1 dev\/sdf1<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;5.\u5efa\u7acb\u903b\u8f91\u5377<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;lvcreate -n LV1&nbsp;-L 150 VG1 (-n\u662f\u5bf9\u903b\u8f91\u5377\u547d\u540d\uff0c-L\u662f\u5bf9<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:12px;\">\u903b\u8f91\u5377\u8bbe\u7f6e\u7a7a\u95f4\u5927\u5c0f\uff0c\u9ed8\u8ba4\u5355\u4f4d\u662f\"M\")<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;6.\u683c\u5f0f\u5316\uff1a<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;mke2fs -j \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;mkdir \/www&nbsp;&nbsp; (\u5728\u6839\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u76ee\u5f55)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;mount \/dev\/VG1\/LV1 \/www<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u4e8c.\u5378\u8f7d\u5377<\/span><\/strong><\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;1.\u5378\u8f7d\u903b\u8f91\u5377<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; lvremove \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;2.\u5378\u8f7d\u5377\u7ec4<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; vgremove \/VG1<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;3.\u5378\u8f7d\u7269\u7406\u5377<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; pvremove \/dev\/sde1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; pvremove \/dev\/sdd1<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u4e09.\u67e5\u770b\u7ba1\u4fe1\u606f<\/span><\/strong><\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;1.pvdisplay \/dev\/sde1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;2.vgdisplay VG1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;3.lvdisplay \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;4.vgdisplay -v VG1&nbsp; (\u53ef\u4ee5\u663e\u793a\u7269\u7406\u5377\uff0c\u5377\u7ec4\uff0c\u903b\u8f91\u5377\u7684\u6240<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:12px;\">\u6709\u4fe1\u606f)<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u56db.\u8c03\u6574\u5377\u7ec4<\/span><\/strong><\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;1.fdisk \/dev\/sdg ( \u5efa\u7acb\u4e00\u4e2a\u6807\u8bc6\u7b26\u4e3a\u201c8e\u201d\u7684\u5206\u533a)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;2.pvcreate \/dev\/sdg1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;3.vgextend VG1 \/dev\/sdg1 (\u5c06\/dev\/sdg1\u6dfb\u52a0\u5230VG1)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;<\/span><span style=\"color:#ff0000;font-size:12px;\">\u6ce8\uff1a\u8fd9\u91cc\u8c03\u6574\u662f\u65e0\u6cd5\u8c03\u6574\u7269\u7406\u5377\u7684\u5927\u5c0f\u7684\u3002<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;4.vgreduce VG1 \/dev\/sdg1 (\u5c06\/dev\/sdg1\u6dfb\u52a0\u5230VG1)<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;\u6ce8\uff1a\u5728\u7f29\u5c0f\u4e4b\u524d\u5148\u67e5\u4e00\u4e0b\u7269\u7406\u5377\u662f\u5426\u88ab\u4f7f\u7528\uff0c\u901a\u8fc7pvdisplay<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"color:#ff0000;font-size:12px;\">\u6765\u67e5\u3002\u7f29\u5c0f\u7269\u7406\u5377\uff0c\u5fc5\u987b\u662f\u7f29\u5c0f\u6ca1\u6709\u4f7f\u7528\u7684\u7269\u7406\u5377\u7684\u3002<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u4e94.\u4ea7\u751f\u903b\u8f91\u5377\u5feb\u7167<\/span><\/strong><\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;lvcreate -L 200M -s -n LV1kuaizhao \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;(-L\u662f\u6dfb\u52a0\u5feb\u7167\u7684\u5927\u5c0f\uff0c\u82e5\u5927\u5c0f\u6bd4\u5b9e\u9645\u7684\u5c0f\uff0c\u5219\u4f1a\u81ea\u52a8\u589e\u52a0\u5230<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:12px;\">\u5b9e\u9645\u7a7a\u95f4\u7684\u5927\u5c0f\u3002-s \u5feb\u7167\u7684\u610f\u601d -n \u7ed9\u5feb\u7167\u547d\u540d \/dev\/VG1\/LV1\u7ed9\u54ea<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:12px;\">\u4e2a\u903b\u8f91\u5377\u5feb\u7167)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;lvremove \/dev\/VG1\/LV1&nbsp; (\u5378\u8f7d\u524d\u5fc5\u987b\u5148\u89e3\u9664\u6302\u8f7d)<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;\u6ce8\uff1a\u5feb\u7167\u51fa\u6765\u7684\u5185\u5bb9\u53ef\u4ee5\u6302\u8f7d\uff0c\u4fee\u6539\uff0c\u5220\u9664\uff0c\u6dfb\u52a0\u5185\u5bb9\u7b49\u64cd<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"color:#ff0000;font-size:12px;\">\u4f5c\u3002\u82e5\u60f3\u8bfb\u53d6\u5feb\u7167\uff0c\u53ea\u9700\u6302\u8f7d\u4fbf\u53ef\u8bfb\u53d6\u3002<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u516d.\u79fb\u52a8\u5377<\/span><\/strong><\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;1.\u52a0\u5165\u65b0\u7684\u7269\u7406\u5377\u5230\u5377\u7ec4\u4e2d<br \/>\n<\/span><span style=\"font-size:12px;\">&nbsp; fdisk \/dev\/sdh ( \u5efa\u7acb\u4e00\u4e2a\u6807\u8bc6\u7b26\u4e3a\u201c8e\u201d\u7684\u5206\u533a)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; pvcreate \/dev\/sdh1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; vgextend VG1 \/dev\/sdh1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; pvscan (\u67e5\u770b\u5377\u7ec4\u7684\u72b6\u51b5)<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;2.\u79fb\u52a8\u7269\u7406\u5377\u7684\u6570\u636e\uff0c\u5230\u65b0\u52a0\u5165\u7684\u7269\u7406\u5377\u4e0a<br \/>\n<\/span><span style=\"font-size:12px;\">&nbsp; pvmove \/dev\/sde1 \/dev\/sdh1 (\u5c06sde1\u7684\u6570\u636e\u79fb\u52a8\u5230sdh1\u91cc<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:12px;\">)<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;3.\u5c06\u65e7\u7684\u7269\u7406\u5377\u4ece\u5377\u7ec4\u4e2d\u5378\u8f7d<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp; vgreduce VG1 \/dev\/sde1<\/span><br \/>\n<span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u4e03.\u8fc1\u79fb\u81f3\u5176\u5b83\u7cfb\u7edf<\/span><\/strong><\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;1.\u5728\u539f\u5148\u7684\u8ba1\u7b97\u673a\u4e2d\uff0c\u5bfc\u51fa\u5377\u7ec4<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; vgchange -a n VG1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; vgexport VG1<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;2.\u5c06LVM\u7684\u78c1\u76d8\uff0c\u5b89\u88c5\u5230\u76ee\u7684\u8ba1\u7b97\u673a\u4e2d<br \/>\n&nbsp;3.\u5728\u76ee\u7684\u8ba1\u7b97\u673a\u4e2d\uff0c\u8f93\u5165\u5377\u7ec4<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; pvscan<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; vgimport VG1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; vgchang -a y VG1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp; \u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u6302\u8f7d\u4e86mount \/dev\/VG1\/LV1 \/web<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"font-size:xx-small;\"><strong style=\"font-weight:bold;\"><span style=\"font-size:12px;\">\u516b.\u8c03\u6574\u903b\u8f91\u5377<\/span><\/strong><\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp; 1.\u589e\u5927\u903b\u8f91\u5377<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp; \u5fc5\u987b\u5148\u589e\u5927LV\uff0c\u518d\u589e\u5927\u6587\u4ef6\u7cfb\u7edf<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp; lvextend -L +100M \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp; e2fsck -f \/dev\/VG1\/LV1(\u68c0\u6d4b\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp; resize2fs \/dev\/VG1\/LV1&nbsp;<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp;<\/span><span style=\"color:#ff0000;font-size:12px;\">\u6ce8\uff1a\u5728\u505alv\u589e\u5927\u7684\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u8981\u6c42\u5fc5\u987b\u662f\u6ca1\u6709\u6302\u8f7d\u7684\u6587<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"color:#ff0000;font-size:12px;\">\u4ef6\u7cfb\u7edf\uff0c\u4e5f\u5c31\u662f\u8981\u5148\u89e3\u9664\u6302\u8f7d\u3002<br \/>\n&nbsp;&nbsp; 2.\u7f29\u5c0f\u903b\u8f91\u5377<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp; \u5148\u7f29\u5c0f\u6587\u4ef6\u7cfb\u7edf\uff0c\u518d\u7f29\u5c0fLV<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp; e2fsck -f \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp; resize2fs \/dev\/VG1\/LV1 212M (\u7f29\u5c0f\u540e\u7684\u7a7a\u95f4\u6570)<\/span><br \/>\n<span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp; lvreduce -L -40M \/dev\/VG1\/LV1<\/span><br \/>\n<span style=\"color:#ff0000;font-size:12px;\">&nbsp;&nbsp;&nbsp; \u6ce8\uff1a\u5728\u505alv\u7f29\u5c0f\u7684\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u8981\u6c42\u5fc5\u987b\u662f\u6ca1\u6709\u6302\u8f7d\u7684\u6587<\/span><\/div>\n<div style=\"padding-bottom:0px;border-right-width:0px;margin:0px auto;padding-left:0px;padding-right:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;\"><span style=\"color:#ff0000;font-size:12px;\">\u4ef6\u7cfb\u7edf\uff0c\u4e5f\u5c31\u662f\u8981\u5148\u89e3\u9664\u6302\u8f7d\u3002<\/span><\/div>\n<p><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LVM\u662f Logical [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14,12,122,13],"class_list":{"0":"post-7","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-Technical_literature","7":"tag-linux","8":"tag-lvm","10":"tag-13"},"views":1359,"_links":{"self":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":0,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}