Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2997397
  • 博文数量: 454
  • 博客积分: 4860
  • 博客等级: 上校
  • 技术积分: 6375
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-13 10:08
个人简介

10年工作经验,专研网站运维。

文章分类

全部博文(454)

文章存档

2017年(11)

2016年(13)

2015年(47)

2014年(36)

2013年(147)

2012年(64)

2011年(136)

分类: LINUX

2012-10-15 13:05:59

1. lvm基础设置
[root@corshdwpro01 ~]# pvcreate /dev/sdj /dev/sdk /dev/sdl
  Physical volume "/dev/sdj" successfully created
  Physical volume "/dev/sdk" successfully created
  Physical volume "/dev/sdl" successfully created
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 64.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj                     lvm2 --    64.00G 64.00G
  /dev/sdk                     lvm2 --    64.00G 64.00G
  /dev/sdl                     lvm2 --    64.00G 64.00G
[root@corshdwpro01 ~]# vgcreate aic_vg /dev/sdj /dev/sdk /dev/sdl
 Volume group "aic_vg" successfully created
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 64.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj   aic_vg            lvm2 a-    64.00G 64.00G
  /dev/sdk   aic_vg            lvm2 a-    64.00G 64.00G
  /dev/sdl   aic_vg            lvm2 a-    64.00G 64.00G
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   0   0 wz--n- 191.99G 191.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   1   0 wz--n- 191.99G 127.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# lvcreate -L 20G -n dmadmin_lv aic_vg
  Logical volume "dmadmin_lv" created
[root@corshdwpro01 ~]# lvcreate -L 120G -n dbproaic_lv aic_vg
  Logical volume "dbproaic_lv" created
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   1   0 wz--n- 191.99G 127.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# mkfs.ext3 /dev/aic_vg/dmadmin_lv
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# mkfs.ext3 /dev/aic_vg/dbproaic_lv
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
15728640 inodes, 31457280 blocks
1572864 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
960 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# useradd dmadmin
[root@corshdwpro01 ~]# passwd dmadmin
Changing password for user dmadmin.
You can now choose the new password.
The new password must be between 8 and 15 characters in length.
The new password must contain:
2 or more digits
  o  MUST NOT appear in positions: 1, last
1 or more lowercase characters
0 or more uppercase characters
0 or more space characters
0 or more characters from the class [-@_.]
Enter new password:
Re-type new password:
passwd: all authentication tokens updated successfully.
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# mkdir dmadmin
[root@corshdwpro01 ~]# mount -a
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# lvs
  LV          VG                Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  dbproaic_lv aic_vg            -wi-a- 120.00G                                     
  dmadmin_lv  aic_vg            -wi-ao  20.00G                                     
  oradat1d_lv corshdwdev01_vol  -wi-a-  64.00G                                     
  oradcs1d_lv corshdwdev01_vol  -wi-a-  30.00G                                     
  oradat1p_lv corshdwpro01_vol  -wi-ao  64.00G                                     
  etlstg1_lv  corshetlstg01_vol -wi-ao  64.00G                                     
  rootvol     rootvg            -wi-ao  60.00G                                     
  swapvol     rootvg            -wi-ao   8.00G                                     
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# mkdir /dbproaic
[root@corshdwpro01 ~]# vim /etc/fstab
/dev/rootvg/rootvol     /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/rootvg/swapvol     swap                    swap    defaults        0 0
/dev/corshdwpro01_vol/oradat1p_lv  /oradata1p   ext3    defaults        1 1
/dev/corshetlstg01_vol/etlstg1_lv /stage1        ext3    defaults        1 1
/dev/aic_vg/dmadmin_lv          /dmadmin        ext3    defaults        1 1
/dev/aic_vg/dbproaic_lv         /dbproaic        ext3    defaults        1 1

[root@corshdwpro01 ~]# mount -a
[root@corshdwpro01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
                       59G   39G   17G  70% /
/dev/sda1             251M   34M  205M  15% /boot
tmpfs                  16G  7.3G  8.5G  47% /dev/shm
/dev/mapper/corshdwpro01_vol-oradat1p_lv
                       63G   40G   21G  66% /oradata1p
/dev/mapper/corshetlstg01_vol-etlstg1_lv
                       63G  241M   60G   1% /stage1
/dev/mapper/aic_vg-dmadmin_lv
                       20G  173M   19G   1% /dmadmin
/dev/mapper/aic_vg-dbproaic_lv
                      119G  188M  112G   1% /dbproaic
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# useradd dbproaic
[root@corshdwpro01 ~]# passwd dbproaic
Changing password for user dbproaic.
You can now choose the new password.
The new password must be between 8 and 15 characters in length.
The new password must contain:
2 or more digits
  o  MUST NOT appear in positions: 1, last
1 or more lowercase characters
0 or more uppercase characters
0 or more space characters
0 or more characters from the class [-@_.]
Enter new password:
Re-type new password:
passwd: all authentication tokens updated successfully.
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# chown -R dmadmin.dmadmin /dmadmin/
[root@corshdwpro01 ~]# chown -R dbproaic.dbproaic /dbproaic/
[root@corshdwpro01 ~]# usermod -g oinstall -G dba dbproaic
[root@corshdwpro01 ~]# id dbproaic
uid=52469(dbproaic) gid=12117(oinstall) groups=12118(dba),12117(oinstall)
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# usermod -G oinstall,dba dmadmin
[root@corshdwpro01 ~]# chmod -R 755 /dbproaic/
[root@corshdwpro01 ~]# chmod -R 755 /dmadmin/
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# chown -R .oinstall /dbproaic/
[root@corshdwpro01 ~]# chown -R .dba /dmadmin/
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# ll -d /dbproaic/
drwxr-xr-x 3 dbproaic oinstall 4096 Oct 15 10:48 /dbproaic/
[root@corshdwpro01 ~]# ll -d /dmadmin/
drwxr-xr-x 3 dmadmin dba 4096 Oct 15 10:45 /dmadmin/
[root@corshdwpro01 ~]#
???etl??,?corshdwpro01_vol??
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   1   0 wz--n- 191.99G 127.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# lvcreate -L 21G -n etl_lv corshdwpro01_vol
  Logical volume "etl_lv" created
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# vim /etc/fstab
/dev/rootvg/rootvol     /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/rootvg/swapvol     swap                    swap    defaults        0 0
/dev/corshdwpro01_vol/oradat1p_lv  /oradata1p   ext3    defaults        1 1
/dev/corshetlstg01_vol/etlstg1_lv /stage1        ext3    defaults        1 1
/dev/aic_vg/dmadmin_lv          /dmadmin        ext3    defaults        1 1
/dev/aic_vg/dbproaic_lv         /dbproaic        ext3    defaults        1 1
/dev/corshdwpro01_vol/etl_lv    /etl            ext3    defaults        1 1
~
[root@corshdwpro01 ~]# mount -a
?bipro????????
[root@corshbipro01 ~]# fdisk -l
Disk /dev/sda: 146.1 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          33      265041   83  Linux
/dev/sda2              34       17769   142464420   8e  Linux LVM
Disk /dev/sdb: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
[root@corshbipro01 ~]#
[root@corshbipro01 ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created
[root@corshbipro01 ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda2  rootvg lvm2 a-   135.84G  52.84G
  /dev/sdb          lvm2 --   272.25G 272.25G
[root@corshbipro01 ~]# vgcreate approaic_vg /dev/sdb
  Volume group "approaic_vg" successfully created
[root@corshbipro01 ~]# lvcreate -L 20G -n approaic_lv approaic_vg
  Logical volume "approaic_lv" created
[root@corshbipro01 ~]# mkfs.ext3 /dev/approaic_vg/approaic_lv
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@corshbipro01 ~]#
[root@corshbipro01 ~]# mkdir /appproaic
[root@corshbipro01 ~]# useradd appsproaic
[root@corshbipro01 ~]# passwd appsproaic
Changing password for user appsproaic.
You can now choose the new password.
The new password must be between 8 and 15 characters in length.
The new password must contain:
2 or more digits
  o  MUST NOT appear in positions: 1, last
1 or more lowercase characters
0 or more uppercase characters
0 or more space characters
0 or more characters from the class [-@_.]
Enter new password:
Re-type new password:
passwd: all authentication tokens updated successfully.
[root@corshbipro01 ~]#
[root@corshbipro01 ~]#
[root@corshbipro01 ~]# chown -R appsproaic.appsproaic /appproaic/
[root@corshbipro01 ~]# chmod -R 755 /appproaic/
[root@corshbipro01 ~]#
[root@corshbipro01 ~]# vim /etc/fstab
/dev/rootvg/rootvol     /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/rootvg/swapvol     swap                    swap    defaults        0 0
corshdwpro01:/stage1/bipro01   /stage1          nfs    rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600
/dev/approaic_vg/approaic_lv    /appproaic      ext3    defaults        0 0
~
[root@corshbipro01 ~]# mount -a
??????
扩大/减小vg空间
1. pvremove: pvremove + 分区号
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 43.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj   aic_vg            lvm2 a-    64.00G 44.00G
  /dev/sdk   aic_vg            lvm2 a-    64.00G     0
  /dev/sdl   aic_vg            lvm2 a-    64.00G  7.99G
[root@corshdwpro01 ~]# pvcreate /dev/sdm
  Physical volume "/dev/sdm" successfully created
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# man pvremove
[root@corshdwpro01 ~]# pvremove /dev/sdm
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 43.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj   aic_vg            lvm2 a-    64.00G 44.00G
  /dev/sdk   aic_vg            lvm2 a-    64.00G     0
  /dev/sdl   aic_vg            lvm2 a-    64.00G  7.99G
  /dev/sdm                     lvm2 --    64.00G 64.00G
2. 添加/减小vg:
vgextend + vg名 + 分区
vgreduce + vg名 + 分区
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]# vgextend aic_vg /dev/sdm
  Volume group "aic_vg" successfully extended
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "aic_vg" using metadata type lvm2
  Found volume group "corshdwdev01_vol" using metadata type lvm2
  Found volume group "corshdwpro01_vol" using metadata type lvm2
  Found volume group "corshetlstg01_vol" using metadata type lvm2
  Found volume group "rootvg" using metadata type lvm2
[root@corshdwpro01 ~]# vsg
-bash: vsg: command not found
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              4   2   0 wz--n- 255.98G 115.98G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# vgreduce aic_vg /dev/sdm
  Removed "/dev/sdm" from volume group "aic_vg"
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]#
3。 搭建好环境
[root@corshdwpro01 ~]# pvcreate /dev/sdn
  Physical volume "/dev/sdn" successfully created
[root@corshdwpro01 ~]# vgcreate test_vg /dev/sdm /dev/sdn
  Volume group "test_vg" successfully created
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 43.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj   aic_vg            lvm2 a-    64.00G 44.00G
  /dev/sdk   aic_vg            lvm2 a-    64.00G     0
  /dev/sdl   aic_vg            lvm2 a-    64.00G  7.99G
  /dev/sdm   test_vg           lvm2 a-    64.00G 64.00G
  /dev/sdn   test_vg           lvm2 a-    64.00G 64.00G
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
  test_vg             2   0   0 wz--n- 127.99G 127.99G
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# lvcreate -L 20G -n test_lv test_vg
  Logical volume "test_lv" created
[root@corshdwpro01 ~]#
增加lv空间
lvextend -L +size + lv绝对路径
[root@corshdwpro01 ~]# vgcreate test_vg /dev/sdm /dev/sdn
  Volume group "test_vg" successfully created
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 43.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj   aic_vg            lvm2 a-    64.00G 44.00G
  /dev/sdk   aic_vg            lvm2 a-    64.00G     0
  /dev/sdl   aic_vg            lvm2 a-    64.00G  7.99G
  /dev/sdm   test_vg           lvm2 a-    64.00G 64.00G
  /dev/sdn   test_vg           lvm2 a-    64.00G 64.00G
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
  test_vg             2   0   0 wz--n- 127.99G 127.99G
[root@corshdwpro01 ~]# lvcreate -L 20G -n test_lv test_vg
  Logical volume "test_lv" created
[root@corshdwpro01 ~]# mkfs.ext3 /dev/test_vg/test_lv
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# mkdir /test
[root@corshdwpro01 ~]# mount -t ext3 /dev/test_vg/test_lv /test
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# cd /test/
[root@corshdwpro01 test]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
                       59G   39G   17G  70% /
/dev/sda1             251M   34M  205M  15% /boot
tmpfs                  16G  7.3G  8.5G  47% /dev/shm
/dev/mapper/corshdwpro01_vol-oradat1p_lv
                       63G   40G   21G  66% /oradata1p
/dev/mapper/corshetlstg01_vol-etlstg1_lv
                       63G  241M   60G   1% /stage1
/dev/mapper/aic_vg-dmadmin_lv
                       20G  173M   19G   1% /dmadmin
/dev/mapper/aic_vg-dbproaic_lv
                      119G  188M  112G   1% /dbproaic
/dev/mapper/corshdwpro01_vol-etl_lv
                       21G  173M   20G   1% /etl
/dev/mapper/test_vg-test_lv
                       20G  173M   19G   1% /test
[root@corshdwpro01 test]#
[root@corshdwpro01 test]# touch aa
[root@corshdwpro01 test]# ls
aa  lost+found
[root@corshdwpro01 test]#
[root@corshdwpro01 test]#
减小lvm空间:
[root@corshdwpro01 test]# cd
[root@corshdwpro01 ~]# umount /test/
[root@corshdwpro01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
                       59G   39G   17G  70% /
/dev/sda1             251M   34M  205M  15% /boot
tmpfs                  16G  7.3G  8.5G  47% /dev/shm
/dev/mapper/corshdwpro01_vol-oradat1p_lv
                       63G   40G   21G  66% /oradata1p
/dev/mapper/corshetlstg01_vol-etlstg1_lv
                       63G  241M   60G   1% /stage1
/dev/mapper/aic_vg-dmadmin_lv
                       20G  173M   19G   1% /dmadmin
/dev/mapper/aic_vg-dbproaic_lv
                      119G  188M  112G   1% /dbproaic
/dev/mapper/corshdwpro01_vol-etl_lv
                       21G  173M   20G   1% /etl
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# e2fsck -f /dev/test_vg/test_lv
e2fsck 1.39 (29-May-2006)
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/test_vg/test_lv: 12/2621440 files (8.3% non-contiguous), 126323/5242880 blocks
[root@corshdwpro01 ~]# resize2fs /dev/test_vg/ 10G
resize2fs 1.39 (29-May-2006)
open: Is a directory while opening /dev/test_vg/
[root@corshdwpro01 ~]# resize2fs /dev/test_vg/test_lv 10G
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/test_vg/test_lv to 2621440 (4k) blocks.
The filesystem on /dev/test_vg/test_lv is now 2621440 blocks long.
[root@corshdwpro01 ~]# lvresize -L 10G /dev/test_vg/test_lv 10G
  Physical Volume "10G" not found in Volume Group "test_vg"
[root@corshdwpro01 ~]# mount -t ext3 /dev/test_vg/test_lv /test
[root@corshdwpro01 ~]# ls /test/
[root@corshdwpro01 ~]# mount -t ext3 /dev/test_vg/test_lv /test
[root@corshdwpro01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
                       59G   39G   17G  70% /
/dev/sda1             251M   34M  205M  15% /boot
tmpfs                  16G  7.3G  8.5G  47% /dev/shm
/dev/mapper/corshdwpro01_vol-oradat1p_lv
                       63G   40G   21G  66% /oradata1p
/dev/mapper/corshetlstg01_vol-etlstg1_lv
                       63G  241M   60G   1% /stage1
/dev/mapper/aic_vg-dmadmin_lv
                       20G  173M   19G   1% /dmadmin
/dev/mapper/aic_vg-dbproaic_lv
                      119G  188M  112G   1% /dbproaic
/dev/mapper/corshdwpro01_vol-etl_lv
                       21G  173M   20G   1% /etl
/dev/mapper/test_vg-test_lv
                      9.9G  165M  9.2G   2% /test
[root@corshdwpro01 ~]# ls
anaconda-ks.cfg             dmadmin          install.log.syslog  mptlinux-4.00.38.02-3dkms.noarch.rpm
Desktop                     etc20120514.tgz  md3000
dkms-2.0.19.1-1.noarch.rpm  install.log      md3000.zip
[root@corshdwpro01 ~]# ls /test/
aa  lost+found
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]#
删除 pv/vg/lv
[root@corshdwpro01 ~]# lvremove /dev/test_vg/test_lv
  Can't remove open logical volume "test_lv"
[root@corshdwpro01 ~]# lvremove /dev/test_vg/
[root@corshdwpro01 ~]# vgremove /dev/test_vg/
  Invalid volume group name: test_vg/
[root@corshdwpro01 ~]# pvremove /dev/sdm
  Can't pvremove physical volume "/dev/sdm" of volume group "test_vg" without -ff
[root@corshdwpro01 ~]# vgremove test_vg
Do you really want to remove volume group "test_vg" containing 1 logical volumes? [y/n]: y
  Can't remove open logical volume "test_lv"
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
  test_vg             2   1   0 wz--n- 127.99G 107.99G
[root@corshdwpro01 ~]# pvremove /dev/sdm
  Can't pvremove physical volume "/dev/sdm" of volume group "test_vg" without -ff
[root@corshdwpro01 ~]# vgremove test_vg
Do you really want to remove volume group "test_vg" containing 1 logical volumes? [y/n]: n
  Volume group "test_vg" not removed
  Command failed with status code 5.
[root@corshdwpro01 ~]# lvs
  LV          VG                Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  dbproaic_lv aic_vg            -wi-ao 120.00G                                     
  dmadmin_lv  aic_vg            -wi-ao  20.00G                                     
  oradat1d_lv corshdwdev01_vol  -wi-a-  64.00G                                     
  oradcs1d_lv corshdwdev01_vol  -wi-a-  30.00G                                     
  etl_lv      corshdwpro01_vol  -wi-ao  21.00G                                     
  oradat1p_lv corshdwpro01_vol  -wi-ao  64.00G                                     
  etlstg1_lv  corshetlstg01_vol -wi-ao  64.00G                                     
  rootvol     rootvg            -wi-ao  60.00G                                     
  swapvol     rootvg            -wi-ao   8.00G                                     
  test_lv     test_vg           -wi-ao  20.00G                                     
[root@corshdwpro01 ~]# lvremove /dev/test_vg/test_lv
  Can't remove open logical volume "test_lv"
[root@corshdwpro01 ~]# umount /test/
[root@corshdwpro01 ~]# lvremove /dev/test_vg/test_lv
Do you really want to remove active logical volume "test_lv"? [y/n]: y
  Logical volume "test_lv" successfully removed
[root@corshdwpro01 ~]# vgremove test_lv
  Volume group "test_lv" not found
[root@corshdwpro01 ~]# vgremove test_vg
  Volume group "test_vg" successfully removed
[root@corshdwpro01 ~]# pvremove /dev/sdm
  Labels on physical volume "/dev/sdm" successfully wiped
[root@corshdwpro01 ~]# pvremove /dev/sdn
  Labels on physical volume "/dev/sdn" successfully wiped
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]# pvs
  PV         VG                Fmt  Attr PSize   PFree
  /dev/sda2  rootvg            lvm2 a-   135.84G 67.84G
  /dev/sdc   corshetlstg01_vol lvm2 a-    64.00G     0
  /dev/sdd   corshetlstg01_vol lvm2 a-    64.00G 63.99G
  /dev/sde   corshdwpro01_vol  lvm2 a-    64.00G     0
  /dev/sdf   corshdwpro01_vol  lvm2 a-    64.00G 63.99G
  /dev/sdg   corshdwpro01_vol  lvm2 a-    64.00G 43.00G
  /dev/sdh   corshdwdev01_vol  lvm2 a-    64.00G     0
  /dev/sdi   corshdwdev01_vol  lvm2 a-    64.00G 34.00G
  /dev/sdj   aic_vg            lvm2 a-    64.00G 44.00G
  /dev/sdk   aic_vg            lvm2 a-    64.00G     0
  /dev/sdl   aic_vg            lvm2 a-    64.00G  7.99G
[root@corshdwpro01 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree 
  aic_vg              3   2   0 wz--n- 191.99G  51.99G
  corshdwdev01_vol    2   2   0 wz--n- 127.99G  34.00G
  corshdwpro01_vol    3   2   0 wz--n- 191.99G 106.99G
  corshetlstg01_vol   2   1   0 wz--n- 127.99G  63.99G
  rootvg              1   2   0 wz--n- 135.84G  67.84G
[root@corshdwpro01 ~]# rm -r /test/
rm: remove directory `/test/'? y
[root@corshdwpro01 ~]#
[root@corshdwpro01 ~]#
阅读(2890) | 评论(0) | 转发(0) |
0

上一篇:nagios监控内存

下一篇:lvm管理

给主人留下些什么吧!~~