\r\n# Create pv\r\n[root@localhost ~]# pvcreate \/dev\/sda\r\n[root@localhost ~]# pvcreate \/dev\/sdb\r\n[root@localhost ~]# pvcreate \/dev\/sdc\r\n# Create VG\r\n[root@localhost ~]# vgcreate vg_data \/dev\/sd[a-c]\r\n# Create LV\r\n[root@localhost ~]# lvcreate -L 25G -n lv_data vg_data\r\n[root@localhost ~]# lvcreate -L 25G -n lv_log vg_data\r\n<\/pre>\n\u4e0b\u9762\u5217\u51fa\u903b\u8f91\u5377\u7684\u5206\u914d\u4f7f\u7528\u4fe1\u606f\uff1a<\/p>\n
\r\n[root@localhost ~]# pvs\r\n PV VG Fmt Attr PSize PFree \r\n \/dev\/nvme0n1p2 cl lvm2 a-- <19.00g <2.00g\r\n \/dev\/sda vg_data lvm2 a-- <20.00g 0 \r\n \/dev\/sdb vg_data lvm2 a-- <20.00g <9.99g\r\n \/dev\/sdc vg_data lvm2 a-- <20.00g 0 \r\n[root@localhost ~]# vgs\r\n VG #PV #LV #SN Attr VSize VFree \r\n cl 1 2 0 wz--n- <19.00g <2.00g\r\n vg_data 3 2 0 wz--n- <59.99g <9.99g\r\n[root@localhost ~]# lvs -a -o +devices\r\n LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices \r\n root cl -wi-ao---- 15.00g \/dev\/nvme0n1p2(512)\r\n swap cl -wi-ao---- 2.00g \/dev\/nvme0n1p2(0) \r\n lv_data vg_data -wi-a----- 25.00g \/dev\/sda(0) \r\n lv_data vg_data -wi-a----- 25.00g \/dev\/sdb(0) \r\n lv_log vg_data -wi-a----- 25.00g \/dev\/sdc(0) \r\n lv_log vg_data -wi-a----- 25.00g \/dev\/sdb(1281) \r\n<\/pre>\n
\n\u5728\u6839\u76ee\u5f55\u521b\u5efa\u4e24\u4e2a\u6587\u4ef6\u5939\/data\u548c\/log\uff0c\u683c\u5f0f\u5316\u903b\u8f91\u5377\uff0c\u6302\u8f7d\u903b\u8f91\u5377\uff0c\u5e76\u5b58\u653e\u4e00\u4e9b\u6570\u636e\uff1a<\/p>\n
\r\n[root@localhost ~]# mkdir \/data \/logs\r\n[root@localhost ~]# mkfs.xfs \/dev\/vg_data\/lv_data \r\n[root@localhost ~]# mkfs.xfs \/dev\/vg_data\/lv_log \r\n[root@localhost ~]# mount \/dev\/vg_data\/lv_data \/data\r\n[root@localhost ~]# mount \/dev\/vg_data\/lv_log \/data\r\n[root@localhost ~]# df -h\r\nFilesystem Size Used Avail Use% Mounted on\r\ndevtmpfs 880M 0 880M 0% \/dev\r\ntmpfs 897M 0 897M 0% \/dev\/shm\r\ntmpfs 897M 8.7M 888M 1% \/run\r\ntmpfs 897M 0 897M 0% \/sys\/fs\/cgroup\r\n\/dev\/mapper\/cl-root 15G 1.9G 14G 13% \/\r\n\/dev\/nvme0n1p1 976M 183M 726M 21% \/boot\r\ntmpfs 180M 0 180M 0% \/run\/user\/0\r\n\/dev\/mapper\/vg_data-lv_log 25G 211M 25G 1% \/data\r\n[root@localhost ~]# touch \/data\/file{1..10}.txt\r\n[root@localhost ~]# touch \/logs\/text{1..10}.log\r\n<\/pre>\n\u5c06\u78c1\u76d8\u8bbe\u7f6e\u4e3a\u6545\u969c\u6216\u5220\u9664\u78c1\u76d8<\/strong><\/div>\n\u8fd9\u4e24\u79cd\u60c5\u51b5\u662f\u610f\u5916\u5220\u9664\u7684\u7269\u7406\u5377\u6216\u53d1\u751f\u6545\u969c\u7684\u78c1\u76d8\uff0c\u901a\u8fc7\u8fd0\u884cpvremove\u547d\u4ee4\u5220\u9664\u4e86\u4efb\u4f55\u4e00\u4e2a\u7269\u7406\u5377\uff0c\u6216\u8005\u4ece\u865a\u62df\u673a\u4e2d\u79fb\u9664\u67d0\u4e00\u5757\u7269\u7406\u78c1\u76d8\u3002<\/p>\n
\u4e0b\u9762\u4ece\u865a\u62df\u673a\u4e2d\u79fb\u9664\u4e00\u5757\u7269\u7406\u78c1\u76d8\uff1a
\n
\n\u91cd\u542f\u7cfb\u7edf\u4e4b\u540e\uff0c\u53d1\u73b0\u4e0d\u80fd\u6302\u8f7dlv_data\u548clv_log\u903b\u8f91\u5377\u4e86\uff0c\/dev\u76ee\u5f55\u4e2d\u627e\u4e0d\u5230vg_data<\/code>\u5377\u7ec4\u3002<\/p>\n\u5982\u679c\u8be5\u903b\u8f91\u5377\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u52a8\u542f\u52a8\u4e86\uff0c\u78c1\u76d8\u53d1\u751f\u6545\u969c\u540e\uff0c\u7531\u4e8e\u4e24\u4e2a\u903b\u8f91\u5377\u65e0\u6cd5\u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf\uff0c\u56e0\u6b64\u91cd\u65b0\u5f15\u5bfc\u4e0d\u80fd\u8fdb\u5165\u7cfb\u7edf\u3002\u53ea\u80fd\u901a\u8fc7\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u5e76\u6ce8\u91cafstab<\/code>\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u548c\u8be5\u903b\u8f91\u5377\u76f8\u5173\u7684\u6761\u76ee\u3002<\/p>\n\u6dfb\u52a0\u65b0\u7269\u7406\u786c\u76d8<\/strong><\/div>\n\u4e0b\u9762\u4ece\u865a\u62df\u673a\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u7269\u7406\u78c1\u76d8\uff0c\u65b0\u6dfb\u52a0\u7684\u78c1\u76d8\u4f1a\u53d8\u6210\/dev\/sdc<\/p>\n
\r\n[root@localhost ~]# lsblk -S\r\nNAME HCTL TYPE VENDOR MODEL REV TRAN\r\nsda 6:0:0:0 disk VMware, VMware Virtual S 1.0 spi\r\nsdb 6:0:2:0 disk VMware, VMware Virtual S 1.0 spi\r\nsdc 6:0:3:0 disk VMware, VMware Virtual S 1.0 spi\r\nsr0 3:0:0:0 rom NECVMWar VMware SATA CD01 1.00 sata\r\n<\/pre>\n<\/p>\n
\u6062\u590d\u5df2\u5220\u9664\u7269\u7406\u5377\u7684\u5143\u6570\u636e<\/strong><\/div>\n\u73b0\u5728\u8ba9\u6211\u4eec\u5f00\u59cb\u4e3a\u5df2\u5220\u9664\u7684\u7269\u7406\u5377\u6062\u590d\u5143\u6570\u636e\u3002\u5f53\u4f7f\u7528pvs,vgs,lvs\u547d\u4ee4\u65f6\uff0c\u5b83\u5c06\u8b66\u544a\u7f3a\u5c11xxxxx UUID\u7684\u8bbe\u5907\u4e4b\u4e00\u3002
\n
\n\u53ea\u9700\u590d\u5236UUID\u5e76\u4f7f\u7528grep\u67e5\u770b\u5b58\u6863\u548c\u5907\u4efd\u3002\u5728\u8fdb\u884c\u91cd\u65b0\u5f15\u5bfc\u4e4b\u524d\uff0c\u62a5\u544a\u7684UUID\u6307\u7684\u662f\/dev\/sdb\u8bbe\u5907\u3002<\/p>\n
\r\n[root@localhost ~]# cat \/etc\/lvm\/archive\/vg_data_00002-1587647360.vg |grep -B 2 -A 9 \"v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD\"\r\n\r\npv1 {\r\nid = \"v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD\"\r\ndevice = \"\/dev\/sdb\" # Hint only\r\n\r\nstatus = [\"ALLOCATABLE\"]\r\nflags = []\r\ndev_size = 41943040 # 20 Gigabytes\r\npe_start = 2048\r\npe_count = 5119 # 19.9961 Gigabytes\r\n}\r\n[root@localhost ~]# cat \/etc\/lvm\/backup\/vg_data |grep -B 2 -A 9 \"v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD\"\r\n\r\npv1 {\r\nid = \"v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD\"\r\ndevice = \"\/dev\/sdb\" # Hint only\r\n\r\nstatus = [\"ALLOCATABLE\"]\r\nflags = []\r\ndev_size = 41943040 # 20 Gigabytes\r\npe_start = 2048\r\npe_count = 5119 # 19.9961 Gigabytes\r\n}\r\n<\/pre>\n
\n\u8ba9\u6211\u4eec\u5148\u4f7f\u7528pvcreate --test<\/code>\u8fdb\u884c\u8bd5\u8fd0\u884c\uff1a<\/p>\n\r\n[root@localhost ~]# pvcreate --test --uuid \"v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD\" --restorefile \/etc\/lvm\/archive\/vg_data_00002-1587647360.vg \/dev\/sdc \r\n TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.\r\n Couldn't find device with uuid l5rSrt-SRfc-KQNw-Tm29-gx4D-ihBw-Xzum3L.\r\n Couldn't find device with uuid v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD.\r\n Couldn't find device with uuid UYyDyH-vc6D-XbQ7-ga1X-DKeM-ObLe-tdBLxR.\r\n Physical volume \"\/dev\/sdc\" successfully created.\r\n<\/pre>\n<\/p>\n
\n- --test \u8bd5\u8fd0\u884c<\/li>\n
- --uuid \u7528\u4e8e\u6307\u5b9a\u65b0\u521b\u5efa\u7684\u7269\u7406\u5377\u7684uuid\u503c\u3002\u5982\u679c\u6ca1\u6709\u6b64\u9009\u9879\uff0c\u5c06\u751f\u6210\u968f\u673aUUID\u3002\u5728\u672c\u5b9e\u9a8c\u4e2d\u6307\u5b9a\u7684uuid\u503c\u662f\u4e4b\u524d\u5220\u9664\u7269\u7406\u5377\u7684uuid\u503c\u3002<\/li>\n
- --restorefile \u8bfb\u53d6\u7531vgcfgbackup\u751f\u6210\u7684\u5b58\u6863\u6587\u4ef6<\/li>\n<\/ul>\n
\u53bb\u6389--test<\/code>\u9009\u9879\uff0c\u6b63\u5f0f\u521b\u5efa\u7269\u7406\u5377\uff1a<\/p>\n\r\n[root@localhost ~]# pvcreate --uuid \"v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD\" --restorefile \/etc\/lvm\/archive\/vg_data_00002-1587647360.vg \/dev\/sdc \r\n Couldn't find device with uuid l5rSrt-SRfc-KQNw-Tm29-gx4D-ihBw-Xzum3L.\r\n Couldn't find device with uuid v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD.\r\n Couldn't find device with uuid UYyDyH-vc6D-XbQ7-ga1X-DKeM-ObLe-tdBLxR.\r\n Physical volume \"\/dev\/sdc\" successfully created.\r\n[root@localhost ~]# pvs\r\n PV VG Fmt Attr PSize PFree \r\n \/dev\/nvme0n1p2 cl lvm2 a-- <19.00g <2.00g\r\n \/dev\/sda vg_data lvm2 a-- <20.00g 0 \r\n \/dev\/sdb vg_data lvm2 a-- <20.00g 0 \r\n \/dev\/sdc vg_data lvm2 a-- <20.00g <9.99g\r\n[root@localhost ~]# vgs\r\n VG #PV #LV #SN Attr VSize VFree \r\n cl 1 2 0 wz--n- <19.00g <2.00g\r\n vg_data 3 2 0 wz--n- <59.99g <9.99g\r\n[root@localhost ~]# lvs -o +devices\r\n LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices \r\n root cl -wi-ao---- 15.00g \/dev\/nvme0n1p2(512)\r\n swap cl -wi-ao---- 2.00g \/dev\/nvme0n1p2(0) \r\n lv_data vg_data -wi-a----- 25.00g \/dev\/sda(0) \r\n lv_data vg_data -wi-a----- 25.00g \/dev\/sdc(0) \r\n lv_log vg_data -wi-a----- 25.00g \/dev\/sdb(0) \r\n lv_log vg_data -wi-a----- 25.00g \/dev\/sdc(1281) \r\n<\/pre>\n<\/p>\n
\u6062\u590d\u5377\u7ec4<\/strong><\/div>\n\u7136\u540e\u4f7f\u7528lvm\u7684\u5907\u4efd\u8fd8\u539f\u5377\u7ec4\u3002\u9996\u5148\u52a0\u5165--test<\/code>\u8bd5\u8fd0\u884c\u4e00\u4e0b\uff1a<\/p>\n\r\n[root@localhost ~]# vgcfgrestore --test -f \/etc\/lvm\/backup\/vg_data vg_data\r\n TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.\r\n Volume group vg_data has active volume: lv_log.\r\n Volume group vg_data has active volume: lv_data.\r\n WARNING: Found 2 active volume(s) in volume group \"vg_data\".\r\n Restoring VG with active LVs, may cause mismatch with its metadata.\r\nDo you really want to proceed with restore of volume group \"vg_data\", while 2 volume(s) are active? [y\/n]: y\r\n Restored volume group vg_data.\r\n<\/pre>\n
\n\u4e0b\u9762\u6b63\u5f0f\u8fd0\u884c\u4e00\u4e0b\uff0c\u53bb\u6389--test<\/code>\u9009\u9879\uff1a<\/p>\n\r\n[root@localhost ~]# vgcfgrestore -f \/etc\/lvm\/backup\/vg_data vg_data\r\n Volume group vg_data has active volume: lv_log.\r\n Volume group vg_data has active volume: lv_data.\r\n WARNING: Found 2 active volume(s) in volume group \"vg_data\".\r\n Restoring VG with active LVs, may cause mismatch with its metadata.\r\nDo you really want to proceed with restore of volume group \"vg_data\", while 2 volume(s) are active? [y\/n]: y\r\n Restored volume group vg_data.\r\n<\/pre>\n
\n\u5982\u679c\u5377\u7ec4\u548c\u903b\u8f91\u5377\u672a\u6fc0\u6d3b\uff0c\u8bf7\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u6fc0\u6d3b\uff1a<\/p>\n
\r\n# \u626b\u63cf\u5377\u7ec4\r\n[root@localhost ~]# vgscan \r\n Reading all physical volumes. This may take a while...\r\n Found volume group \"cl\" using metadata type lvm2\r\n Found volume group \"vg_data\" using metadata type lvm2\r\n# \u6fc0\u6d3b\u5377\u7ec4vg_data\r\n[root@localhost ~]# vgchange -ay vg_data\r\n 2 logical volume(s) in volume group \"vg_data\" now active\r\n# \u626b\u63cf\u903b\u8f91\u5377\r\n[root@localhost ~]# lvscan \r\n ACTIVE '\/dev\/cl\/swap' [2.00 GiB] inherit\r\n ACTIVE '\/dev\/cl\/root' [15.00 GiB] inherit\r\n ACTIVE '\/dev\/vg_data\/lv_data' [25.00 GiB] inherit\r\n ACTIVE '\/dev\/vg_data\/lv_log' [25.00 GiB] inherit\r\n<\/pre>\n<\/p>\n
\u603b\u7ed3<\/strong><\/div>\n\u5728lvm\u4e2d\uff0c\u9700\u8981\u6267\u884c\u4e00\u4e9b\u6b65\u9aa4\u6765\u6062\u590d\u5df2\u5220\u9664\u7684\u7269\u7406\u5377\uff0c\u65b9\u6cd5\u662f\u6dfb\u52a0\u65b0\u78c1\u76d8\u5e76\u7528\u73b0\u6709UUID\u6307\u5411\u65b0\u78c1\u76d8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Centos8 \u4e0b\u9762\u4f7f\u7528\u4e86\/dev\/sd[a-c]\u4e09\u5757\u78c1\u76d8\uff0c\u5c06\u4ed6\u4eec\u5212\u5165\u4e00\u4e2a\u5377\u7ec4\uff0c\u521b\u5efa\u4e24\u4e2a\u903b\u8f91\u5377\uff1a # Crea […]<\/p>\n","protected":false},"author":309,"featured_media":216298,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-216297","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=216297"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216297\/revisions"}],"predecessor-version":[{"id":216309,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216297\/revisions\/216309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/216298"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=216297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=216297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=216297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}