250 likes | 493 Views
LVM & Mirror. QIAN Yun 2004.4. 中国惠普有限公司 支持服务事业部. / dev/rdsk/c0t1d0. / dev/rdsk/c0t0d0. physical. Volumes 物理卷. volume. VG01. VG01. Group 卷组. logical. lvol3. Volumes 逻辑卷. lvol1. lvol2. Elements of LVM( 逻辑卷管理器). 一块物理硬盘( PV) 只能属于一个卷组( VG) 一个 VG 里的最大逻辑卷( LV) 数目是255
E N D
LVM & Mirror QIAN Yun 2004.4 中国惠普有限公司 支持服务事业部
/dev/rdsk/c0t1d0 /dev/rdsk/c0t0d0 physical Volumes 物理卷 volume VG01 VG01 Group 卷组 logical lvol3 Volumes 逻辑卷 lvol1 lvol2 Elements of LVM(逻辑卷管理器)
一块物理硬盘(PV)只能属于一个卷组(VG) 一个VG里的最大逻辑卷(LV)数目是255 每个PV最大PE数目是65536,默认值是1016,可在创建VG时通过vgcreate –e 设定 每个VG中最大PV数目是255,默认值是16, 可在创建VG时通过 vgcreate –p 设定 Logical Volume Manager Rules
1) 创建物理卷Physical Volume # pvcreate /dev/rdsk/c0t1d0 NEW LVM DISK Physical Volume Reserved Area P V R A Contents: ID's for volume group and physical volumes Physical extent size Physical volume size Bad block directory Size and location of other disk structures Transparent software sparing is not supported on HPIB BAD BLOCK POOL or the root disk (only used if disk hardware sparing fails) Creating a Logical Volume with a File System on a New Disk
NEW LVM DISK ROOT DISK P V R A / dev vg01 BAD BLOCK POOL Creating a Logical Volume with a File System on a New Disk 2) 创建卷组所用目录 # mkdir /dev/vg01
ROOT DISK NEW LVM DISK P V R A / dev vg01 group BAD BLOCK POOL Creating a Logical Volume with a File System on a New Disk 3) 创建卷组设备文件 # mknod /dev/vg01/group c 64 0x010000
# vgcreate /dev/vg01 /dev/dsk/c0t1d0 NEW LVM DISK P V R A Volume Group Reserved Area Contents V G R A Volume Group Descriptor Area (VGDA) Identifies logical and physical volumes Physical to logical extent mapping Volume Group Status Area (VGSA) Physical volume status (missing/present) Physical extent status (stale/ok) Mirror Consistency Record (MCR) BAD BLOCK POOL Lists disk writes in progress 'vgcreate' creates or updates '/etc/lvmtab' Adds volume group information to '/etc/lvmtab' Creating a Logical Volume with a File System on a New Disk 4) 创建卷组
NEW LVM DISK ROOT DISK P V R A / V G R A etc dev lvmtab vg01 rlvtest group lvtest BAD BLOCK POOL CHARACTER BLOCK DEVICE FILE DEVICE FILE Creating a Logical Volume with a File System on a New Disk 5) 创建大小为100M的逻辑卷lvtest # lvcreate -L 100 –n lvtest vg01
NEW LVM DISK P V R A V G R A lost+found Creating a Logical Volume with a File System on a New Disk 6) 创建文件系统 # newfs /dev/vg01/rlvtest Newfs uses logical volume one's character device file to create a 100 MB filesystem in the space allocated by lvcreate. Newfs creates a 'lost+found' directory in the new filesystem. BAD BLOCK POOL
/ etc dev test lvmtab vg01 rlvtest group lvtest Creating a Logical Volume with a File System on a New Disk 7) 创建挂起点 # mkdir /test NEW LVM DISK ROOT DISK P V R A V G R A lost+found BAD BLOCK POOL
ROOT DISK NEW LVM DISK P V R A / V G R A etc dev vg01lvol1 lost+found lvmtab vg01 group lvol1 rlvol1 BAD BLOCK POOL Creating a Logical Volume with a File System on a New Disk 8) 执行挂起 # mount /dev/vg01/lvtest /test # vi /etc/fstab
Creating a Logical Volume with a File System on a New Disk 9) 扩大逻辑卷 # umount /test # lvextend –L 100 /dev/vg01/lvtest # extendfs /dev/vg01/rlvtest # mount //dev/vg01/lvtest /test
For Physical Volumes Displaying LVM Information # pvdisplay [-v] /dev/dsk/cCtTdD Displays information about the physical volume(s) specified
Displaying LVM Information For Volume Groups # vgdisplay [-v] /dev/vg* Displays information about all the volume groups
Displaying LVM Information For Logical Volumes # lvdisplay [-v] /dev/vg*/lvol* Displays information about all the logical volumes in all the volume groups
Display Kernel Devices on LVM and Bootable Disks • lvlnboot -vShows definitions for • boot • root • swap • dump • Physical volumes in root volume group
Displaying LVM Information The contents of '/etc/lvmtab' # strings /etc/lvmtab Displays volume group to physical volume relationships
vg01.conf P V R A P V R A P V R A V G R A V G R A V G R A vg01 lvol 5 vg01 lvol 3 vg01 lvol 1 vg01 lvol 4 vg01 lvol 6 vg01 lvol 2 Bad Block Pool Bad Block Pool Bad Block Pool Disk 3 Disk 1 Disk 2 # vgcfgbackup vg01 LVM Data Structure Backup
Disk 1 Disk 2 Disk 3 P V R A P V R A P V R A V G R A V G R A V G R A v g 0 1 v g 0 1 v g 0 1 l v o l 1 l v o l 3 l v o l 5 v g 0 1 v g 0 1 v g 0 1 l v o l 4 l v o l 2 l v o l 6 Bad Block Pool Bad Block Pool Bad Block Pool vg01.conf Disk 2 LVM structures corrupted LVM Data Structure Restore # vgcfgrestore -n vg01 /dev/rdsk/c0t2d0
Mirror: 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
Split Mirrored LV # lvsplit -s backup /dev/vg02/lvol1 Logical volume "/dev/vg02/lvol1backup" has been successfully created with lv number 5. Logical volume "/dev/vg02/lvol1" has been successfully split.
Merge split LV # lvmerge /dev/vg02/lvol1backup /dev/vg02/lvol1
Mirror a BOOT disk • pvcreate -B /dev/rdsk/c0t8d0 • vgextend /dev/vg00 /dev/dsk/c0t8d0 • mkboot /dev/dsk/c0t8d0 • lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c0t8d0 • 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 • mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/dsk/c0t5d0 • mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/dsk/c0t8d0 • lvlnboot -R • lvlnboot -b /dev/vg00/lvol1 • lvlnboot -r /dev/vg00/lvol3 • lvlnboot -s /dev/vg00/lvol2 • lvlnboot -d /dev/vg00/lvol2 • lvlnboot -R