旅途

如果想飞得高,就该把地平线忘掉

LVM介绍

LVM为Logical Volume Manager的缩写,起源于早期的UNIX系统,lvm提供了一种更高级的磁盘管理服务和工具集,为了方便磁盘管理和划分,它将几个物理磁盘或分区组成 一个更大的磁盘组,再在磁盘组上进行分区划分或者裸设备划分.跟单个磁盘的管理比起来它提供了一种更加灵活的磁盘管理服务,可以在线动态的调整分区的大小 和容量扩展,可以实现文件系统跨域不同的磁盘和分区,实现磁盘的条带。随着技术的发展,LVM还已经融入到了cluster当中.RedHat的 LVM2(对LVM的升级)就可以支持cluster 环境了.cluster 环境中,一台主机对共享存储建立了LVM后,可以动态同步到其他节点。

  • LVM结构

basic-lvm-volume

LVM总体有三部分组成, 底层是组成LV的物理卷,LV的数据都存储在这些物理卷上,这些物理卷可以是整块磁盘也可以是单个分区,这些磁盘或分区在加入LVM卷组前必须通过LVM 提供的命令进行格式化,将每个磁盘或分区格式化成可以被LVM识别的PE(Physical Extents)单位;中间是卷组,由物理卷组成的一个大的逻辑磁盘组;最上面一层就是逻辑卷了, 相当于一个磁盘分区,跟磁盘分区不同的是我们可以创建Linear(直线)、striped(条带),mirrord(镜像)三种逻辑卷,linear的 创建方式就是类似于我们在普通磁盘上创建的分区模式,每个逻辑卷底层又被分割成最小的LE(Logical Extents) 可被寻址的基本单位,在同一个卷组中LE跟每一个PE是对应的.

  • LVM基本概念

    物理介质
    系统的存储设备:硬盘,如:/dev/hda1、/dev/sda等等,是存储系统最低层的存储单元。

    物理卷

    LVM的底层存储容器,LVM的基本存储块,是LVM格式化后的物理介质,最终是由被LVM格式化的PE单元组成.。

    卷组

    类似于非LVM系统中的物理硬盘,由物理卷组成。可以在卷组上创建一个或多个LVM分区(逻辑卷),LVM卷组由一个或多个物理卷组成。

    逻辑卷
    类似于非LVM系统中的硬盘分区,在逻辑卷之上可以建立文件系统(比如/home、/oracle),或者可以当裸设备使用。

    PE
    每个物理卷被划分为称为PE(Physical Extents)的基本单元,具有唯一编号的PE是可以被LVM寻址的最小单元。PE的大小是可以配置的,默认为4MB。

    LE
    逻辑卷也被划分为被称为LE(Logical Extents) 的可被寻址的基本单位。同一个卷组中,LE的大小和PE是相同的,并且一一对应。

  • LVM管理工具

    每个操作系统都提供了自己的一系列LVM管理工具,比如RedHat下可以通过GUI进行管理,还可以通过CLI借口进行管理, 在RedHat AS 4中,对LVM进行升级,

    推出了一个LVM管理平台,我们在命令提示符下输入LVM,就会进入这个平台

[root@mayp lvm]# lvm
lvm> help
  Available lvm commands:
  Use 'lvm help <command>' for more information
  dumpconfig      Dump active configuration
  formats         List available metadata formats
  help            Display help for commands
  lvchange        Change the attributes of logical volume(s)
  lvconvert       Change logical volume layout
  lvcreate        Create a logical volume
  lvdisplay       Display information about a logical volume
  lvextend        Add space to a logical volume
  lvmchange       With the device mapper, this is obsolete and does nothing.
  lvmdiskscan     List devices that may be used as physical volumes
  lvmsadc         Collect activity data
  lvmsar          Create activity report
  lvreduce        Reduce the size of a logical volume
  lvremove        Remove logical volume(s) from the system
  lvrename        Rename a logical volume
  lvresize        Resize a logical volume
  lvs             Display information about logical volumes
  lvscan          List all logical volumes in all volume groups
  pvchange        Change attributes of physical volume(s)
  pvresize        Resize physical volume(s)
  pvcreate        Initialize physical volume(s) for use by LVM
  pvdata          Display the on-disk metadata for physical volume(s)
  pvdisplay       Display various attributes of physical volume(s)
  pvmove          Move extents from one physical volume to another
  pvremove        Remove LVM label(s) from physical volume(s)
  pvs             Display information about physical volumes
  pvscan          List all physical volumes
  segtypes        List available segment types
  vgcfgbackup     Backup volume group configuration(s)
  vgcfgrestore    Restore volume group configuration
  vgchange        Change volume group attributes
  vgck            Check the consistency of volume group(s)
  vgconvert       Change volume group metadata format
  vgcreate        Create a volume group
  vgdisplay       Display volume group information
  vgexport        Unregister volume group(s) from the system
  vgextend        Add physical volumes to a volume group
  vgimport        Register exported volume group with system
  vgmerge         Merge volume groups
  vgmknodes       Create the special files for volume group devices in /dev
  vgreduce        Remove physical volume(s) from a volume group
  vgremove        Remove volume group(s)
  vgrename        Rename a volume group
  vgs             Display information about volume groups
  vgscan          Search for all volume groups
  vgsplit         Move physical volumes into a new volume group
  version         Display software and driver version information
lvm> version
  LVM version:     2.02.06 (2006-05-12)
  Library version: 1.02.07 (2006-05-11)
  Driver version:  4.5.0
lvm>
lvm> vgs -h
  vgs: Display information about volume groups

vgs
        [--aligned]
        [-a|--all]
        [-d|--debug]
        [-h|--help]
        [--ignorelockingfailure]
        [--noheadings]
        [--nosuffix]
        [-o|--options [+]Field[,Field]]
        [-O|--sort [+|-]key1[,[+|-]key2[,...]]]
        [-P|--partial]
        [--separator Separator]
        [--unbuffered]
        [--units hsbkmgtHKMGT]
        [-v|--verbose]
        [--version]
        [VolumeGroupName [VolumeGroupName...]]

lvm> pvcreate -h
  pvcreate: Initialize physical volume(s) for use by LVM

pvcreate
        [--restorefile file]
        [-d|--debug]
        [-f[f]|--force [--force]]
        [-h|-?|--help]
        [--labelsector sector]
        [-M|--metadatatype 1|2]
        [--metadatacopies #copies]
        [--metadatasize MetadataSize[kKmMgGtT]]
        [--setphysicalvolumesize PhysicalVolumeSize[kKmMgGtT]
        [-t|--test]
        [-u|--uuid uuid]
        [-v|--verbose]
        [-y|--yes]
        [-Z|--zero {y|n}]
        [--version]
        PhysicalVolume [PhysicalVolume...]

lvm>

 原文地址 http://shadowfalao.spaces.live.com/Blog/cns!80DF4F7FDCD57166!153.entry

posted on 2009-10-07 00:17 旅途 阅读(662) 评论(0)  编辑 收藏 引用 所属分类: LINUX基础、管理


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理