·þÎñÆ÷ϵͳ¼¯³É¼°Êý¾Ý·þÎñÖÐÐÄ

 

Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
Ò»¼¶À¸Ä¿
¡¾æŠ€æœ¯èµ„æ–?uppage=news.asp¡¿¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­>>>

linux´ÅÅ̹ÜÀíϵÁÐÖ®LVMµÄʹÓÃ2

À©Õ¹LVM

ÉÏÃæÎÒÃǵIJâÊÔÊÇvgÊÇ4G£¬ÎÒÃǵĴ´½¨µÄlvÊÇ2GµÄ£¬ÎÒÃÇÏë¸ø´´½¨µÄlvÀ©Õ¹1G¿Õ¼ä¡£

¸´ÖÆ´úÂë
[root@centos7 ~]$ lvextend -L +1G /dev/vg_test_01/lv_test_01                 # ÎÒÃÇÀ©´ó1G£¬ +1G±íʾÔÚÔ­Óлù´¡ÉÏÀ©´ó1G,ÎÒÃÇÕâÀïÊÇÓÐvgÊÇÓпռäµÄ£¬Ã»ÓеĻ°¾ÍÐèÒª´´½¨pv£¬À©´óvgÔÚ×ö 
  Size of logical volume vg_test_01/lv_test_01 changed from 2.00 GiB (512 extents) to 3.00 GiB (768 extents). 
  Logical volume vg_test_01/lv_test_01 successfully resized. 
[root@centos7 ~]$ df -h                                                      # ÉÏÃæµÄÃüÁîÌáʾlvÒѾ­µ½3GÁË£¬ µ«ÊÇʹÓÃdf-h ²é¿´»¹ÊÇ2g 
Filesystem                         Size  Used Avail Use% Mounted on 
/dev/sda3                           48G  4.9G   41G  11% / 
devtmpfs                           979M  4.0K  979M   1% /dev 
tmpfs                              993M     0  993M   0% /dev/shm 
tmpfs                              993M   22M  971M   3% /run 
tmpfs                              993M     0  993M   0% /sys/fs/cgroup 
/dev/sda1                          976M  130M  780M  15% /boot 
/dev/sda5                           20G  307M   18G   2% /app 
tmpfs                              199M   32K  199M   1% /run/user/0 
/dev/sr0                           8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64 
/dev/mapper/vg_test_01-lv_test_01  2.0G   33M  2.0G   2% /mnt/test_01 
[root@centos7 ~]$ resize2fs /dev/mapper/vg_test_01-lv_test_01              # ÐèÒªÔö³¤ÏÂÎļþϵͳµÄ£¬ÈÃÎļþϵͳºÍlv´óСƥÅäÏ 
meta-data=/dev/mapper/vg_test_01-lv_test_01 isize=512    agcount=4, agsize=131072 blks 
         =                       sectsz=512   attr=2, projid32bit=1 
         =                       crc=1        finobt=0 spinodes=0 
data     =                       bsize=4096   blocks=524288, imaxpct=25 
         =                       sunit=0      swidth=0 blks 
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1 
log      =internal               bsize=4096   blocks=2560, version=2 
         =                       sectsz=512   sunit=0 blks, lazy-count=1 
realtime =none                   extsz=4096   blocks=0, rtextents=0 
data blocks changed from 524288 to 786432 
[root@centos7 ~]$ df -h                                                    # Ôٴβ鿴¾ÍÊÇÒ»ÖµÄÁË 
Filesystem                         Size  Used Avail Use% Mounted on 
/dev/sda3                           48G  4.9G   41G  11% / 
devtmpfs                           979M  4.0K  979M   1% /dev 
tmpfs                              993M     0  993M   0% /dev/shm 
tmpfs                              993M   22M  971M   3% /run 
tmpfs                              993M     0  993M   0% /sys/fs/cgroup 
/dev/sda1                          976M  130M  780M  15% /boot 
/dev/sda5                           20G  307M   18G   2% /app 
tmpfs                              199M   32K  199M   1% /run/user/0 
/dev/sr0                           8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64 
/dev/mapper/vg_test_01-lv_test_01  3.0G   33M  3.0G   2% /mnt/test_01
¸´ÖÆ´úÂë

×¢Ò⣺

  1. ¡¡¡¡ extϵÁпÉÒÔʹÓÃresieze2fsÈ¥µ÷Õû¡£ÆäËûµÄÎļþϵͳ¿ÉÒԲο¼http://tldp.org/HOWTO/LVM-HOWTO/extendlv.html
  2. ¡¡¡¡ lvextentd Óиö-rÑ¡Ï×Ô¶¯È¥µ÷Õû´óС£¬Æ¥ÅälvºÍÎļþϵͳ´óСµÄ¡£

Ëõ¼õLVM

Âß¼­¾íµÄ´óС¿ÉÒÔ¼õС£¬Ò²¿ÉÒÔÔö¼Ó¡£ µ«ÊÇ£¬ÔÚËõС¾í±¾Éí֮ǰ£¬Çë¼ÇסËõСÎļþϵͳµÄ´óС»ò´æÔÚÓÚ¾íÖеÄÈκÎÎļþÊǷdz£ÖØÒªµÄ£¬·ñÔò¿ÉÄܻᶪʧÊý¾Ý¡£

×¢Ò⣺ xfs,jsfÎļþϵͳÊÇû·¨Ëõ¼õlvmµÄ£¬ÒòΪÕâ2¸öÎļþϵͳû·¨Ëõ¼õÎļþϵͳ´óСµÄ¡£²Î¿¼http://tldp.org/HOWTO/LVM-HOWTO/reducelv.html

Ö÷Òª²½Ö裺

  1. ¡¡¡¡¼ì²é¿Õ¼äʹÓÃÇé¿öºÍ·ÖÎö
  2. ¡¡¡¡umountÉ豸
  3. ¡¡¡¡Ëõ¼õÎļþϵͳ´óС
  4. ¡¡¡¡Ëõ¼õlv´óС
  5. ¡¡¡¡»Ö¸´¹ÒÔØÉ豸

ÉÏÃæÎÒÃǵÄÂß¼­¾íÊÇ3GµÄ´óС£¬ÔÚËõ¼õ֮ǰÎÒÃÇÐèҪȷ±£Ëõ¼õµÄ¿Õ¼ä²»ÄÜÓ°ÏìÊý¾ÝµÄ´æ·ÅµÄ¡£

¼ì²é¹¤×÷

¸´ÖÆ´úÂë
[root@centos7 ~]$ cp -a /etc/ /mnt/test_01/                              # ÎÒÕâÀïÄ£ÄâÏ£¬Ö»ÄÜĿ¼ÓÐÎļþµÄÇé¿ö  
[root@centos7 ~]$ du -sh /mnt/test_01/                                   # ²é¿´Ï´óС 
42M    /mnt/test_01/ 
[root@centos7 ~]$ df -h                                                   # ²é¿´Âß¼­¾í·ÖÇøÀûÓÃÇé¿ö £¬Êý¾Ý²Å´æ·Å76M,ÎÒÃǵÄÂß¼­¾í¶¼3GÄØ£¬ Èç¹ûÎÒÃÇÏëËõ¼õ1G,ÍêȫûÓÐÎÊÌâµÄ¡£ 
Filesystem                         Size  Used Avail Use% Mounted on 
/dev/sda3                           48G  4.9G   41G  11% / 
devtmpfs                           979M  4.0K  979M   1% /dev 
tmpfs                              993M     0  993M   0% /dev/shm 
tmpfs                              993M   22M  971M   3% /run 
tmpfs                              993M     0  993M   0% /sys/fs/cgroup 
/dev/sda1                          976M  130M  780M  15% /boot 
/dev/sda5                           20G  307M   18G   2% /app 
tmpfs                              199M   32K  199M   1% /run/user/0 
/dev/sr0                           8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64 
/dev/mapper/vg_test_01-lv_test_01  3.0G   76M  3.0G   3% /mnt/test_01
¸´ÖÆ´úÂë

Ëõ¼õ¿Õ¼ä

¸´ÖÆ´úÂë
[root@centos7 ~]$ umount /dev/vg_test_01/lv_test_01                           # È¡Ïû¹ÒÔØ 
[root@centos7 ~]$ resize2fs  /dev/vg_test_01/lv_test_01  1G                   # resieze2fs¶¨ÒåÏÂÎļþϵͳ´óС 
resize2fs 1.42.9 (28-Dec-2013) 
Please run ¡¯e2fsck -f /dev/vg_test_01/lv_test_01¡¯ first. 

[root@centos7 ~]$ e2fsck -f /dev/vg_test_01/lv_test_01                        #ÉÏÃæµÄÃüÁîÒª¼ì²é£¬ÄǾͼì²éÏ 
e2fsck 1.42.9 (28-Dec-2013) 
Pass 1: Checking inodes, blocks, and sizes 
Pass 2: Checking directory structure 
Pass 3: Checking directory connectivity 
Pass 4: Checking reference counts 
Pass 5: Checking group summary information 
/dev/vg_test_01/lv_test_01: 3614/196608 files (0.1% non-contiguous), 42361/786432 blocks 
[root@centos7 ~]$ resize2fs  /dev/vg_test_01/lv_test_01  1G                   # ¼ì²éÍ꣬ÄǾÍÖ´ÐÐËõ¼õÎļþϵͳ´óС 
resize2fs 1.42.9 (28-Dec-2013) 
Resizing the filesystem on /dev/vg_test_01/lv_test_01 to 262144 (4k) blocks. 
The filesystem on /dev/vg_test_01/lv_test_01 is now 262144 blocks long. 
[root@centos7 ~]$ lvreduce  -L 1G /dev/vg_test_01/lv_test_01                  # Ëõ¼õÏÂÂß¼­¾íµ½1G£¬ÕâÀïÓÐÌáʾ£¬Ëõ¼õ¿ÉÄܻᶪʧÊý¾Ý£¬ÊäÈëy¼´¿É 
  WARNING: Reducing active logical volume to 1.00 GiB. 
  THIS MAY DESTROY YOUR DATA (filesystem etc.) 
Do you really want to reduce vg_test_01/lv_test_01? [y/n]: yG                  
  Size of logical volume vg_test_01/lv_test_01 changed from 3.00 GiB (768 extents) to 1.00 GiB (256 extents). 
  Logical volume vg_test_01/lv_test_01 successfully resized. 
[root@centos7 ~]$ mount /dev/vg_test_01/lv_test_01  /mnt/test_01/            # »Ö¸´¹ÒÔØ 
[root@centos7 ~]$ ll /mnt/test_01/ 
total 28 
drwxr-xr-x. 140 root root 12288 Dec  7 13:54 etc 
drwx.   2 root root 16384 Dec  7 15:47 lost+found 
[root@centos7 ~]$ df -h                                                     # ¼ì²éÏ 
Filesystem                         Size  Used Avail Use% Mounted on 
/dev/sda3                           48G  4.9G   41G  11% / 
devtmpfs                           979M  4.0K  979M   1% /dev 
tmpfs                              993M     0  993M   0% /dev/shm 
tmpfs                              993M   22M  971M   3% /run 
tmpfs                              993M     0  993M   0% /sys/fs/cgroup 
/dev/sda1                          976M  130M  780M  15% /boot 
/dev/sda5                           20G  307M   18G   2% /app 
tmpfs                              199M   32K  199M   1% /run/user/0 
/dev/sr0                           8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64 
/dev/mapper/vg_test_01-lv_test_01  944M   52M  825M   6% /mnt/test_01
¸´ÖÆ´úÂë

ǨÒÆLVMµÄvg

Òƶ¯vgµ½ÁíÍâÒ»¸ö»úÆ÷ÉÏ

Ö÷Òª²½Ö裺

  1. ¡¡¡¡¼ì²éºÍ·ÖÎö
  2. һЩԤ´¦Àí¹¤×÷
  3. umountÎļþϵͳ
  4. ¡¡¡¡ÉèÖþí×é·Ç»î¶¯
  5. ¡¡¡¡µ¼³ö¾í×é
  6. ¡¡¡¡È¡³öÉ豸£¬²åÈ뵽лúÆ÷
  7. ¡¡¡¡µ¼Èë¾í×é
  8. ¡¡¡¡¼¤»î¾í×é
  9. ¡¡¡¡¹ÒÔØÎļþϵͳ

¼ì²é·ÖÎö

¸´ÖÆ´úÂë
[root@centos7 ~]$ vgs 
  VG         #PV #LV #SN Attr   VSize VFree 
  vg_test_01   4   1   0 wzn- 3.98g 2.98g 
[root@centos7 ~]$ pvs 
l  PV         VG         Fmt  Attr PSize    PFree    
  /dev/sdb1  vg_test_01 lvm2 a  1020.00m       0  
  /dev/sdb2             lvm2 -     1.00g    1.00g 
  /dev/sdc1  vg_test_01 lvm2 a  1020.00m 1016.00m 
  /dev/sdc2             lvm2 -     1.00g    1.00g 
  /dev/sdd1  vg_test_01 lvm2 a  1020.00m 1020.00m 
  /dev/sdd2             lvm2 -     5.00g    5.00g 
  /dev/sde1  vg_test_01 lvm2 a  1020.00m 1020.00m 
  /dev/sde2             lvm2 -     2.00g    2.00g 
[root@centos7 ~]$ lvs 
  LV         VG         Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert 
  lv_test_01 vg_test_01 -wi-ao 1.00g                                                    
¸´ÖÆ´úÂë

ÎÒÃÇʹÓÃlvs,vgs,pvs·Ö±ð²é¿´ÐÅÏ¢¡£·¢ÏÖÎÒÃÇvgÊÇ3GµÄ´óС¡£lvÊÇ1GµÄ´óС¡£µ«ÊÇvgµÄpvÀ´×Ô²»Í¬µÄ´ÅÅ̵ġ£ÎÒÃÇҪǨÒÆvg¡£²»ÄÜ°Ñ°üº¬pv¶¼Ç¨ÒƹýÈ¥°Ñ¡£ ÄÇÕâÒ»ÏÂ×ÓÐèÒª4¸öÅ̵ġ£

ÎÒÃÇ°ÑpvÊý¾ÝǨÒÆÏ£¬µ½Ê±ºòÕªÅ̵ÄʱºòÖ»ÄÇÒ»¸ö¾Í¿ÉÒÔ¶àºÃ¡£ ·¢ÏÖ/dev/sdd2ÊÇÒ»¸ö5GµÄÅÌ¡£ ´òËãʹÓÃ/dev/sddÕâ¸öÅÌ×÷ΪǨÒÆÅÌÀ´Ç¨ÒÆÊý¾Ý¡£

һЩԤ´¦Àí¹¤×÷

¸´ÖÆ´úÂë
[root@centos7 ~]$ umount /mnt/test_01/                                    # È¥³ý¹ÒÔØ
[root@centos7 ~]$ vgchange  -an vg_test_01                                # ÉèÖÃvg²»¼¤»î 
  0 logical volume(s) in volume group "vg_test_01" now active
[root@centos7 ~]$ pvmove /dev/sd{b1,c1,e1}                                 # ǨÒÆpvÊý¾Ý 
  /dev/sdb1: Moved: 0.00% 
  /dev/sdb1: Moved: 100.00% 
[root@centos7 ~]$ pvs                                                      # È·±£pv¶¼Êǿյģ¬Ã»ÓÐÊý¾Ý´æ·ÅÁË¡£ 
  PV         VG         Fmt  Attr PSize    PFree    
  /dev/sdb1  vg_test_01 lvm2 a  1020.00m 1020.00m 
  /dev/sdb2             lvm2 -     1.00g    1.00g 
  /dev/sdc1  vg_test_01 lvm2 a  1020.00m 1016.00m 
  /dev/sdc2             lvm2 -     1.00g    1.00g 
  /dev/sdd1  vg_test_01 lvm2 a  1020.00m       0  
  /dev/sdd2  vg_test_01 lvm2 a    <5.00g   <5.00g 
  /dev/sde1  vg_test_01 lvm2 a  1020.00m 1020.00m 
  /dev/sde2             lvm2 -     2.00g    2.00g 
 
[root@centos7 ~]$ vgreduce vg_test_01  /dev/sd{b1,c1,e1}                   # Ëõ¼õvg È¥³ýb1,c1,e1 
  Removed "/dev/sdb1" from volume group "vg_test_01" 
  Removed "/dev/sdc1" from volume group "vg_test_01" 
  Removed "/dev/sde1" from volume group "vg_test_01" 
[root@centos7 ~]$ pvremove /dev/sd{b1,c1,e1}                               # ÒƳýpv£¬ÕâÀïÌáʾ£¬ 
  Lables on physical volume "/dev/sdb1" sucdessfully wiped. 
  Labels on physical volume "/dev/sdc1" successfully wiped. 
  Labels on physical volume "/dev/sde1" successfully wiped.
¸´ÖÆ´úÂë

µ¼³övg

¸´ÖÆ´úÂë
[root@centos7 ~]$ vgdisplay                                       # µ¼³öÇ°µÄÈ·ÈÏ 
  - Volume group - 
  VG Name               vg_test_01 
  System ID              
  Format                lvm2 
  Metadata Areas        2 
  Metadata Sequence No  24 
  VG Access             read/write 
  VG Status             resizable 
  MAX LV                0 
  Cur LV                1 
  Open LV               0 
  Max PV                0 
  Cur PV                2 
  Act PV                2 
  VG Size               5.99 GiB 
  PE Size               4.00 MiB 
  Total PE              1534 
  Alloc PE / Size       256 / 1.00 GiB 
  Free  PE / Size       1278 / 4.99 GiB 
  VG UUID               sZwHea-LabA-SJaV-Wz40-qFp3-Um2w-pvmJAY 
    
[root@centos7 ~]$ vgexport vg_test_01                                    # µ¼³övg·¢ÏÖÓ줻îµÄÉ豸£¬ÐèÒª¹Ø±Õ 
  Volume group "vg_test_01" has active logical volumes 
[root@centos7 ~]$ vgchange -an vg_test_01                                # ÉèÖÃΪ·Ç¼¤»î 
¡¡¡¡0 logical volume(s) in volume group "vg_test_01" now active 
[root@centos7 ~]$ vgexport vg_test_01                                    # µ¼³ö£¬ Òª¿´µ½³É¹¦µ¼³ö²Å¿ÉÒÔ£¬ÕâÀï×¢ÒâÁË£¬ Èç¹ûÕâ¸övgÃû×ÖºÍÄ¿±ê»úÆ÷ÓÐÖØÃûµÄ»°£¬ ÕâÀïʹÓÃrename¸ÄÏÂÔÚµ¼³ö 
¡¡¡¡Volume group "vg_test_01" successfully exported 

[root@centos7 ~]$ sync                                                   # ¶àÖ´Ðм¸´Îsync¡£ ·ÀÖ¹ÄÚ´æºÍ´ÅÅÌûÓÐͬ²½µÄÎÊÌâ¡£ 
[root@centos7 ~]$ sync 
[root@centos7 ~]$ sync 
[root@centos7 ~]$ sync
¸´ÖÆ´úÂë

ÎÒÕâÀï°ÑÕâ¸ö´ÅÅÌÈ¡³öÀ´°²×°µ½ÁíÍâÒ»¸ö»úÆ÷ÉÏÃæ¡£ÏÂÃæµÄÒ»²¿·Ö²Ù×÷ÔÚлúÆ÷ÉÏÖ´ÐС£×¢ÒâÀ²¡£

ʶ±ðÓ²¼þ

¸´ÖÆ´úÂë
[root@centos6 ~]$ /git/Bash/other/scan_scsi_device.sh                             # Ö´ÐÐÏÂɨÃèÓ²¼þ½Å±¾£¬ÎÒ×Ô¼ºÐ´µÄ£¬ºóÃæ°ÑÕâ¸öbash½Å±¾Ìù³öÀ´ 
start scan 
/sys/devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0/scan scan finished. 
/sys/devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1/scan scan finished. 
/sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan scan finished. 
end  scan 
please use lsblk check,  
[root@centos6 ~]$ lsblk                                                           # ʹÓÃlsblk²é¿´£¬¿ÉÒÔ·¢ÏÖ£¬Ê¶±ð³öÀ´¾ÍÊÇÄǸö/dev/sdc 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
sr0     11:0    1  3.7G  0 rom  /media/CentOS_6.9_Final 
sr1     11:1    1  8.1G  0 rom  /media/CentOS 7 x86_64 
sda      8:0    0  200G  0 disk  
©À©¤sda1   8:1    0    1G  0 part /boot 
©À©¤sda2   8:2    0 48.8G  0 part / 
©À©¤sda3   8:3    0 19.5G  0 part /app 
©À©¤sda5   8:5    0    2G  0 part [SWAP] 
©À©¤sda4   8:4    0    2M  0 part  
©¸©¤sda6   8:6    0    1G  0 part  
sdb      8:16   0  100G  0 disk  
©À©¤sdb1   8:17   0    1G  0 part  
©À©¤sdb2   8:18   0   20G  0 part  
©À©¤sdb3   8:19   0    1G  0 part  
©À©¤sdb4   8:20   0    1K  0 part  
©À©¤sdb5   8:21   0   20G  0 part  
©À©¤sdb6   8:22   0    1G  0 part  
©¸©¤sdb7   8:23   0    1G  0 part  
sr2     11:2    1  3.7G  0 rom  /media/CentOS_6.9_Final_ 
sr3     11:3    1    2G  0 rom  /media/CentOS_6.9_Final__ 
sdc      8:32   0   20G  0 disk  
©À©¤sdc1   8:33   0    1G  0 part  
©¸©¤sdc2   8:34   0    5G  0 part 
¸´ÖÆ´úÂë

½Å±¾ÄÚÈÝÈçÏÂ

¸´ÖÆ´úÂë
[root@centos6 ~]$ cat /git/Bash/other/scan_scsi_device.sh  
#!/bin/bash 
#================================================ 
#FileName   :scan_scsi_device 
#Author     :zhaojiedi 
#Description:Èç¹ûÄãÌí¼ÓÁËÒ»¸öеÄÓ²ÅÌÉ豸£¬ µ«ÊÇûÓб»ÏµÍ³Ê¶±ð£¬Ê¹ÓÃÈçϽű¾¿ÉÒÔʶ±ð³öÀ´£¬  
#DateTime   :2017-11-30 18:03:27 
#Version    :V1.0 
#Other      :×îа汾½¨Òé´ÓÕâÀï»ñÈ¡https://github.com/zhaojiedi1992/Bash 
#================================================ 
#!/bin/bash 
echo "start scan" 
for i in `find /sys/devices/ -name scan` do  
    echo "- - -" > $i 
    echo  $i scan finished. 
done 
echo "end  scan" 
echo -e "\033[32mplease use lsblk check\033[0m"
¸´ÖÆ´úÂë

µ¼Èë²¢¹ÒÔØ

¸´ÖÆ´úÂë
[root@centos6 ~]$ vgscan                                               # vgɨÃè 
  Reading all physical volumes.  This may take a while... 
  Found exported volume group ", vg_test_01" using metadata type lvm2 
[root@centos6 ~]$ pvscan                                               # pvɨÃè 
  PV /dev/sdc1    is in exported VG vg_test_01 [1020.00 MiB / 0    free] 
  PV /dev/sdc2    is in exported VG vg_test_01 [5.00 GiB / 4.99 GiB free] 
  Total: 2 [5.99 GiB] / in use: 2 [5.99 GiB] / in no VG: 0 [0   ] 
[root@centos6 ~]$ vgimport vg_test_01                                  # È·ÈÏÎÞ´íÎóµÄ¾Íµ¼Èë¡£ 
  Volume group "vg_test_01" successfully imported 
[root@centos6 ~]$ vgs                                                  # ²é¿´ÏÂvgÐÅÏ¢ 
  VG         #PV #LV #SN Attr   VSize VFree 
  vg_test_01   2   1   0 wzn- 5.99g 4.99g 
[root@centos6 ~]$ vgchange -ay vg_test_01                              # ¼¤»îvg 
  1 logical volume(s) in volume group "vg_test_01" now active 
[root@centos6 ~]$ mkdir /mnt/new_test                                  # ´´½¨¹ÒÔصã 
[root@centos6 ~]$ mount /dev/vg_test_01/lv_test_01  /mnt/new_test/     # ¹ÒÔØ 
[root@centos6 ~]$ du -sh /mnt/new_test/                                # È·ÈÏÎļþûÓжªÊ§ 
45M    /mnt/new_test/
¸´ÖÆ´úÂë

¿ìÕÕLVM

·ÖÎöϵ±Ç°»·¾³£¬ÎÒ°ÑvgÒƶ¯µ½centos6ÉÏÁË¡£Ò»Ï²Ù×÷ÔÚcentos6ÉÏÖ´Ðеġ£

¸´ÖÆ´úÂë
[root@centos6 ~]$ vgs                                        # ²é¿´ÏÂvgÐÅÏ¢£¬ Ò»¹²6G,»¹ÓÐ5GÄØ¡£ 
  VG         #PV #LV #SN Attr   VSize VFree 
  vg_test_01   2   1   0 wzn- 5.99g 4.99g 
[root@centos6 ~]$ pvs                                       # ÓÐ2¸öpv 
  PV         VG         Fmt  Attr PSize    PFree 
  /dev/sdc1  vg_test_01 lvm2 au 1020.00m    0  
  /dev/sdc2  vg_test_01 lvm2 au    5.00g 4.99g
¸´ÖÆ´úÂë

ÎÒÃǸղŸø/mnt/new_testĿ¼¹ÒÔØÂß¼­¾ívg_test_01¡£¼ÙÈçÎÒÃǵÄ/mnt/new_testµÄÄÚÈÝÒ»Ö±Ôڱ仯¡£ÏëÈ¥±¸·ÝÊý¾Ý¾ÍÐèÒª¿ìÕÕ¾íÁË¡£

´´½¨¿ìÕÕ

[root@centos6 etc]$ lvcreate  -L 500M -s -p r -n vg_test_01_snapshot /dev/vg_test_01/lv_test_01       # -LÖ¸¶¨´óС£¬ -s ±íʾ´´½¨¿ìÕÕ¶ø²»ÊÇÆÕͨÂß¼­¾í£¬-p r Ö¸¶¨È¨ÏÞΪֻ¶ÁµÄ£¬ -nÖ¸¶¨Ãû×Ö 
  Logical volume "vg_test_01_snapshot" created.

×¢Ò⣺ Èç¹ûʹÓõÄxfsÎļþϵͳ£¬ ¹ÒÔصÄʱºòÐèÒª¼ÓÈënouuid,roÑ¡ÏÇÒ´´½¨¿ìÕÕµÄʱºò²»ÄÜÖ¸¶¨-p rÑ¡Ïî¡£¾ßÌå²Î¿¼£º http://tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html

Ä£ÄâһЩÊý¾ÝÐ޸IJÙ×÷

[root@centos6 etc]$ echo "zhaojiedi1992" >>/mnt/new_test/zhaojiedi1992.txt                            # ÖÆ×÷һЩÐÞ¸ÄÇé¿ö 
[root@centos6 etc]$ vim /mnt/new_test/etc/motd

¼à¿Ø¿ìÕÕÇé¿ö

¸´ÖÆ´úÂë
[root@centos6 ~]$ lvdisplay  /dev/vg_test_01/vg_test_01_snapshot  
  - Logical volume - 
  LV Path                /dev/vg_test_01/vg_test_01_snapshot 
  LV Name                vg_test_01_snapshot 
  VG Name                vg_test_01 
  LV UUID                pZ8x2u-lqPA-uLef-P816-dS8V-wZ0y-PKWWwL 
  LV Write Access        read only                                         #Ö»¶ÁµÄ 
  LV Creation host, time centos6.magedu.com, 2017-12-02 06:11:56 +0800 
  LV snapshot status     active destination for lv_test_01                 # ÕâÊÇlv_test_01µÄ¿ìÕÕ 
  LV Status              available 
  # open                 0 
  LV Size                1.00 GiB                                          # ¿ìÕÕµÄ×Ü´óС 
  Current LE             256 
  COW-table size         500.00 MiB 
  COW-table LE           125 
  Allocated to snapshot  0.01%                                             # Õâ¸öµØ·½¿ÉÒÔ¿´µ±Ç°¿ìÕÕÕ¼ÓÃÇé¿ö¡£  
  Snapshot chunk size    4.00 KiB 
  Segments               1 
  Allocation             inherit 
  Read ahead sectors     auto 
  - currently set to     256 
  Block device           253:3
¸´ÖÆ´úÂë

¹ÒÔØ¿ìÕÕ²¢±¸·Ý

¸´ÖÆ´úÂë
[root@centos6 etc]$ mkdir /mnt/test_bak                                            # ´´½¨Ò»¸ö¿ìÕÕ¹ÒÔØĿ¼ 
[root@centos6 etc]$ mount /dev/vg_test_01/vg_test_01_snapshot  /mnt/test_bak/      # ¹ÒÔØ£¬ÒòΪÎÒÃÇÉÏÃæ´´½¨¿ìÕÕµÄʱºòÖ¸¶¨-prÖ»¶ÁµÄ 
mount: block device /dev/mapper/vg_test_01-vg_test_01_snapshot is write-protected, mounting read-only 
[root@centos6 etc]$ cat /mnt/test_bak/                                             # ¿ìÕÕºóµÄzhaojiedi1992.txtûÓеġ£ 
etc/        lost+found/  
[root@centos6 etc]$ cat /mnt/test_bak/etc/motd                                     # Õâ¸öµØ·½µÄÎļþÒ²ÊÇ¿ìÕÕÇ°µÄÑù×Ó¡£Ã»ÓÐÎÊÌâ 
Welcom you this system 
[root@centos6 etc]$ tar -jcvf /root/test.tar.bz acl selinux  xattrs /mnt/test_bak/   # ±¸·ÝÊý¾Ý¸Ï½ôµÄ
¸´ÖÆ´úÂë

ÒƳý¿ìÕÕ

[root@centos6 etc]$ umount /mnt/test_bak/                                    # È¡Ïû¹ÒÔØ 
[root@centos6 etc]$ lvremove /dev/vg_test_01/vg_test_01_snapshot             # ÒƳýÁË¿ìÕÕ¾í 
Do you really want to remove active logical volume vg_test_01_snapshot? [y/n]: y 
  Logical volume "vg_test_01_snapshot" successfully removed

²Î¿¼×ÊÁÏ

redhat : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/create_lvm-x86

suse : https://www.suse.com/documentation/sles11/stor_admin/data/lvm.html

lvm how to : http://tldp.org/HOWTO/LVM-HOWTO/index.html

·¢²¼Ê±¼ä:2019/10/28 ÔĶÁ:7283´Î À´Ô´:
 


¡¡
技术资æ–?uppage=news.asp·ÖÀà
   
  ÐÐÒµÐÂÎÅ
 
  ¹«Ë¾¶¯Ì¬
 
  ¼¼Êõ×ÊÁÏ
 
  µçÄÔάÐÞ
 
  »Ö¸´°¸Àý
 
  SQLÊý¾Ý¿â
 
  ´ÅÅÌÕóÁÐ
 
  ·þÎñÆ÷
 
  ²ÆÎñÈí¼þ
 
  ÍøÂçÎÊÌâ
 
  linux-XFS
 
  Æ»¹ûµçÄÔ&ϵͳ
 
  °²×¿ÏµÍ³Ïà¹Ø
 
  °ì¹«Îļþ
 
  ²Ù×÷ϵͳ
 
  ÈÕ³£Éú»î(ÑĮ̀)
 
  ÍøÕ¾Ïà¹Ø
 
   
¡¡
ÓÑÇéÁ´½Ó
¡¡
¡¡
 
 
 
   
¹«Ë¾µØÖ·£ºÑĮ̀µçÄÔÊг¡#308
µç»°£º0535-6688830 E-Mail:163@163.com
Copyright©2011-2012 ÑĮ̀Èð³Û¿ÆóÓÐÏÞ¹«Ë¾ All Rights Reserved.
³ICP±¸11014811ºÅ-1
ÄúÊDZ¾Õ¾µÚ λ·ÃÎÊÕß