免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2175 | 回复: 0
打印 上一主题 下一主题

Notes on LVM [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-12 18:18 |只看该作者 |倒序浏览

                                                                                                                                                                                                               
                ** Elements of LVM
    /dev/rdsk/c0t0d0    /dev/rdsk/c0t1d0     
   

file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/moz-screenshot-1.jpg
file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/moz-screenshot-2.jpg
file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/moz-screenshot.jpg
          Note:
    A Physical Volume is an entirely initialized disk for use by LVM. (Without LVM, a volume can be either a disk partition or an entire disk.)
    A Physical Extent (PE) is a set of contiguous disk blocks on a Physical Volume. LVM uses the PE as the unit for allocating disk space to logical volumes. A small PE size for fine granularity and large PE size for coarse granularity for defining LV.  default size = 4MB
    PV Links provides dual SCSI or FI links to the same disk.
** LV Manager Rules
    a) each PV only belongs to one VG
    b) each VG has 255 LVs at max
    c) each PV has 65536 PEs at max, default value = 1016
        ( vgcreate -e )
    d) each VG has 255 PVs at max, default value = 16
        ( vgcreate -p )
** Operation Steps
    a) Creating the Physical Volume
        #pvcreate /dev/rdsk/c0t1d0


        Note:
        Boot disk would have the LIF Directory, BDRA, and LIF components that are not shown here. (mkboot, lvlnboot)
    b) Creating the Volume Group directory
        #mkdir /dev/vg01
    c) Creating the Volume Group device file
        #mknod /dev/vg01/group c 64 0x010000
    d) Creating the Volume Group
        #vgcreate /dev/vg01 /dev/dsk/c0t1d0
        #vgcreate -s 8 /dev/vg01 /dev/dsk/c0t1d0     (PE size = 8MB, for disk larger than 256GB)
        ('vgcreate' creates or updates /etc/lvmtab)
        the default PE size is 4MB, so the limit: 4 x 65536 = 256GB
        PE size: 8KB ~ 512MB, power of 2
        -l: max logical volumes [255]
        -p: max physical volumes [255]
        kernel parameter - maxvgs defines the VG number, 10 by default (max 256)
  

    e) Creating a Logical Volume lvtest of size 100M
        #lvcreate -L 100 -n lvtest vg01

            f) Creating a new file system
        #newfs /dev/vg01/rlvtest   ( -F  hfs/vxfs -o largefiles )
        ('newfs' uses logical volume one's character device file to create a 100MB file system)
    g) Creating a mount point
        #mkdir /test
    h) Mounting
        #mount /dev/vg01/lvtest  /test
        (vi /etc/fstab)
    i) Extending the Logical Volume
        #umount /test
        #lvextend -L 100 /dev/vg01/lvtest
        #extendfs /dev/vg01/rlvtest
        #mount /dev/vg01/lvtest /test
** Displaying LVM information
    a) for Physical Volumes
        #pvdisplay -v /dev/dsk/cCtTdD
    b) for Volume Groups
        #vgdisplay -v /dev/vg*
    c) for Logical Volumes
        #lvdisplay -v /dev/vg*/lvol*
    d) display kernel devices on LVM and bootable disks
        #lvlnboot -v
    e) display LVM info
        #string /etc/lvmtab
        (/etc/lvmtab is not an ascii file, and it can be rebuilt with vgscan./sbin/lvmrc starts each VG by reading the contents of this file at boot time.)
** LVM data structure backup/restore
    #vgcfgbackup vg01  (vg01.conf)
    #vgcfgrestore -n vg01 /dev/rdsk/c0t2d0
** Mirror
       LVs can be mirrored one or more times (A LE may map to more than one PE).
    Mirroring is done on a LV basis.
    Mirroring policy - strict
         n  -- not a strict policy, the mirror can share the same PV.
        y  -- strict policy, mirrored copies cannot share the same PV.
        g  -- PVG strict policy, mirrored data will not be on the same Physical Volume Group as the
              original data.
    a) one-way mirroring
        #lvcreate -L 40 -m 1 /dev/vg01
        #lvextend -m 1 /dev/vg01/lvol2
        #lvextend -m 1 /dev/vg01/lvol2 /dev/dsk/c0t4d0
    b) split mirrored LV
        #lvsplit -s backup /dev/vg02/lvol1
    c) merge split LV
        #lvmerge /dev/vg02/lvol1backup /dev/vg02/lvol1
    d) mirror a boot disk
        #pvcreate -B /dev/rdsk/c0t8d0           ; create physical volume for disk to be used as mirror
        #vgextend /dev/vg00 /dev/dsk/c0t8d0     ; extend vg00 to include disk to be used as mirror
        #mkboot /dev/rdsk/c0t8d0                ; mkboot places boot utilities in boot area
        #mkboot -a "hpux -lq" /dev/rdsk/c0t8d0     ; add the AUTO file and specify low quorum
           #mkboot -a "hpux -lq" /dev/rdsk/c0t5d0     ; update the AUTO file on primary disk low quorum
        #lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c0t8d0        ; mirror each logical volume on primary ...
        #lvextend -m 1 /dev/vg00/lvol2 /dev/dsk/c0t8d0
        #lvextend -m 1 /dev/vg00/lvol3 /dev/dsk/c0t8d0
        #lvextend -m 1 /dev/vg00/lvol4 /dev/dsk/c0t8d0
        #lvextend -m 1 /dev/vg00/lvol5 /dev/dsk/c0t8d0
        #lvextend -m 1 /dev/vg00/lvol6 /dev/dsk/c0t8d0
        #lvextend -m 1 /dev/vg00/lvol7 /dev/dsk/c0t8d0
        #lvextend -m 1 /dev/vg00/lvol8 /dev/dsk/c0t8d0
        # setboot -a 8/8.6.0               ; have alternate boot path point to H/W path of new mirror disk
** Examples
    Replace a Non-Mirrored Disk
        /etc/lvmconf/vgXX.conf, vgcfgbackup
                   # vgcfgrestore - /dev/vgXX /dev/rdsk/cxtxdx   ; volume group configuration restore
        # vgchange -a y /dev/vgXX                     ; change volume group to available (-a y)
        # newfs -F fstype /dev/vgXX/rlvolx            ; create filesystem for every lvol on physical volume
        # mount /mountpointname                       ; mount every new filesystem
    Replace a Mirrored Disk
        # vgcfgrestore -n /dev/vgXX /dev/rdsk/cxtxdx   ; volume group configuration restore
        # vgchange -a y /dev/vgXX                      ; change volume group to available (-a y)
        # vgsync /dev/vgXX                             ; resync logical volumes in volume group
    Replace Mirrored Disk Boot Disk
        /etc/lvmconf/vgXX.conf, vgcfgbackup
        # vgcfgrestore -n /dev/vgXX /dev/rdsk/cxtxdx  ; volume group configuration restore
        # vgchange -a y /dev/vgXX                     ; change volume group to available (-a y)
        # vgsync /dev/vgXX                            ; resync logical volumes in volume group
        # mkboot /dev/rdsk/cxtxdx                     ; create bootarea on disk
        # mkboot -a "hpux lq" /dev/rdsk/cxtxdx        ; specify low quorum in boot area
        # shutdown                   ; reboot system to take effect
  
    Exporting (Removing) and Importing a Volume Group Onto Another System
        On system 1:
        # vgchange -a n /dev/vg01                    ; change volume group to unavailable (-a n) on 1st sys
        # vgexport -v -m /tmp/mapfile -s /dev/vg01   ; make volume group unavailable on 1st system
        (# vgexport -p -s -m /tmp/mapfile /dev/vg01) ; use -p -s -m options if you need shared for HA
        # rcp /tmp/mapfile system2:/tmp/mapfile      ; copy mapfile to target or second system.
                On system 2:
        # mkdir /dev/vg01                            ; make directory on 2nd system for volume group
        # mknod /dev/vg01/group c 64 0x010000        ; create special file for vol group
         # vgimport -v -m mapfile -s /dev/vg01        ; import volume group using mapfile copied from
                                                     ; 1st system or specify device filenames
        (# vgimport -s -m mapfile /dev/vg01)         ; (use -s and -m in HA cluster)
        # vgchange -a y /dev/vg01                    ; make volume group available
        # mkdir /backup
        # mount /dev/vg01/backup /backup             ; add to /etc/fstab if you want this mounted at boot
    Extend VxFS File System Using OnlineJFS
        # lvextend -L 800 /dev/vgXX/lvolY            ; extend logical volume rlvolY by 800 MBytes
        # fsadm -F vxfs -b 800M /mountpointname      ; use fsadm to extend or extendfs on non-JFS
   
** Reference
    = Physical Volume Commands =
    * pvchange
    * pvcreate
        /usr/sbin/pvcreate [-b] [-B] [-d soft_defects] [-s disk_size] [-f] [-t disk_type] pv_path
    * pvdisplay
        /usr/sbin/pvdisplay [-v] [-b BlockList] pv_path ...
    * pvremove ( move PEs from one PV to other PVs )
        /usr/sbin/pvmove [-A autobackup] [-n lv_path] source_pv_path [dest_pv_path ... | dest_pvg_name ...]
    + mknod  (create VGs)
   
    = Volume Group Commands =
        * vgcfgbackup
        /usr/sbin/vgcfgbackup [-f vg_conf_path] [-u] vg_name
    * vgcfgrestore
    * vgchange ( make a VG active or inactive )
        /usr/sbin/vgchange -a availability [-l] [-p] [-q quorum] [-s] [-P resync_daemon_count] [vg_name...]
    * vgcreate
        /usr/sbin/vgcreate [-f] [-A autobackup] [-x extensibility] [-e max_pe] [-l max_lv] [-p max_pv]
                   [-s pe_size] [-g pvg_name] vg_name pv_path ...
    * vgdisplay
        /usr/sbin/vgdisplay [-v] [vg_name ...]
    * vgexport ( remove a VG from the system but with LV info remained on the PVs )
        e.g.
            # vgchange -a n /dev/vg01
            # vgexport -v -m /etc/lvmconf/vg01.map /dev/vg01
    * vgextend ( add new PVs to VG )
        /usr/sbin/vgextend [-f] [-A autobackup] [-g pvg_name] [-x extensibility] [-z sparepv] vg_name pv_path ...
        e.g.
            # vgextend /dev/rdsk/c0t2d0
            # vgextend /dev/vg01 /dev/dsk/c0t2d0
    * vgimport ( import a PV to another system )
        e.g.
            # mkdir /dev/vg01
            # mknod /dev/vg01/group c 64 0x010000
            # vgimport -v -m /dev/lvmconf/vg01.map /dev/vg01 /dev/dsk/c0t2d0
            # vgchange -a y /dev/vg01
            # vgcfgbackup vg01
        
    * vgreduce ( reduce VG size by removing PVs )
    * vgremove ( remove a VG completely but with VG entry in /dev remained )
        /usr/sbin/vgremove vg_name ...
        e.g.
            # vgchange -a n /dev/vg01
            # lvremove /dev/vg01/lvol1          ;run for all lvols in vg
            # vgremove /dev/vg01
    * vgscan ( rescan the system and rebuild the /etc/lvmtab, -p for preview )
        /usr/sbin/vgscan [-a] [-p] [-v]
    * vgsync ( sync the PEs in each mirrored LV in a VG,  for "stale" or out-of-date mirrored data )
        /usr/sbin/vgsync vg_name ...
    = Logical Volume Commands =
        * lvcreate
        /usr/sbin/lvcreate [-A autobackup] [-c mirror_consistency] [-C contiguous] [-d schedule] [-D distributed]
             [-i stripes -I stripe_size] [-l le_number | -L lv_size] [-m mirror_copies] [-M mirror_write_cache] [-n lv_name]
             [-p permission] [-r relocate] [-s strict] vg_name
        cannot specify a PV on which to create the LV directly
        -->  run lvcreate specifying no size, then two lvextend commands for the original and mirror copies
        e.g
               # lvcreate /dev/vg03/lvol3
            # lvextend -L 400 /dev/vg03/lvol3 /dev/dsk/c0t2d0
            # lvextend -m 1 /dev/vg03/lvol3 /dev/dsk/c2t2d0
    * lvchange
        /usr/sbin/lvchange [-a availability] [-A autobackup] [-c mirror_consistency] [-C contiguous]
             [-d schedule] [-D distributed] [-M mirror_write_cache] [-p permission] [-r relocate] [-s strict]
             [-t IO_timeout] lv_path
    * lvdisplay
        /usr/sbin/lvdisplay [-k] [-v] lv_path  ...
    * lvextend ( increase the number of PEs allocated to a LV )
        /usr/sbin/lvextend [-A autobackup] {-l le_number | -L lv_size | -m mirror_copies} lv_path [pv_path ... | pvg_name ...]
    * extendfs ( expand the filesystem within the LV, after lvextend command )
        /usr/sbin/extendfs [-F FStype] [-q] [-v] [-s size] special
        e.g.
            # umount /dev/vg01/lvol1              ;use fsadm if online
            # extendfs -f vxfs /dev/vg01/rlvol1   ;JFS installed
            # mount /dev/vg01/lvol1 /backup
    * mkboot ( place boot utilities in boot area )
    * lvlnboot ( set a LV to a root, boot, primary swap, or dump volume, -v for current settings )
        /usr/sbin/lvlnboot [[-A autobackup { -b boot_lv | -d dump_lv | -r root_lv | -R | -s swap_lv }] [-v] [vg_name]
    * lvsplit ( split mirrored LVs, atomic split )
        /usr/sbin/lvsplit [-A autobackup] [-s suffix] [-g PhysicalVolumeGroup] lv_path ...
            e.g.
            # lvsplit -s backup /dev/vg01/lvol1 /dev/vg01/lvol4
            # fsck -f vxfs -p /dev/vg01/rlvol1backup
            # fsck -f vxfs -p /dev/vg01/rlvol4backup
               # mount /dev/vg01/lvol1 backuplvol1
            # mount /dev/vg01/rlvol4 backuplvol4
                   * lvmerge ( merge mirrored LVs,
        /usr/sbin/lvmerge [-A autobackup] dest_lv_path src_lv_path
        e.g.
            # lvmerge /dev/vg00/lvol1backup /dev/vg00/lvol1
    * lvmmigrate ( convert a disk partition to a LV )
    * lvreduce ( decrease the number of PEs )
    * lvremove
        /usr/sbin/lvremove [-A autobackup] [-f] lv_path ...
    * lvrmboot ( the converse of lvlnboot )
        /usr/sbin/lvrmboot [-A autobackup] [-d dump_lv] [-r] [-s] [-v] vg_name
    * lvsync ( sync the PEs in a LV, for "stale" or out-of-date mirrored data )
    + newfs ( place a file system on a newly created LV )
        /usr/sbin/newfs [-F FStype] [-o specific_options] [-V] special
    = JFS & OnlineJFS Commands =
        * fsck
    * fsadm ( for OnlineJFS )
        /usr/sbin/fsadm [-F FStype] [-V] [-o specific_options] special
        e.g.
            fsadm -F vxfs [-d][-D][-d][-E] /mount_point      ( defragmentation )
            fsadm -F vxfs -b new_size /mount_point           ( increase OnlineJFS filesystem)
            fsadm -f vxfs -b new_size /mount_point           ( reduce OnlineJFS filesystem )
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/16112/showart_320090.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP