一、查看磁盘容量
其中关键是两个命令,vgscan命令实现扫描所有磁盘得到卷组信息,并创建文件卷组数据文件/etc/lvmtab和/etc/lvmtab.d/*;vgchange -a y命令激活系统所有卷组。
[root@gflinux102 ~]# rpm -qa|grep lvm
lvm2-2.02.74-5.el5
system-config-lvm-1.1.5-8.el5
[root@gflinux102 ~]# fdisk -l
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 10443 81682492+ 8e Linux LVM
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
二、使用sdb创建基于磁盘的物理卷
[root@gflinux102 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@gflinux102 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup00
PV Size 77.90 GB / not usable 24.06 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 2492
Free PE 0
Allocated PE 2492
PV UUID Zli22u-1d8k-y3NW-B9AE-jvjP-d7Yc-ObC8F2
"/dev/sdb" is a new physical volume of "200.00 GB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 200.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID N3icYj-Q2lN-2Eb0-mVmt-QZf6-Nukz-M6NDOH
三、将新的物理卷添加到现有卷组
[root@gflinux102 ~]# vgextend VolGroup00 /dev/sdb
Volume group "VolGroup00" successfully extended
[root@gflinux102 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 277.84 GB
PE Size 32.00 MB
Total PE 8891
Alloc PE / Size 2492 / 77.88 GB
Free PE / Size 6399 / 199.97 GB
VG UUID 51xYkk-Y1jX-n7e8-B6yE-f2Ng-nb0R-2LIJjD
四、创建快照
[root@gflinux102 ~]# lvcreate -L 200M -s -n mysqlbackup201510 /dev/VolGroup00/data
Rounding up size to full physical extent 224.00 MB
Logical volume "mysqlbackup201510" created
[root@gflinux102 ~]# mkdir /home/mysqlbackup
[root@gflinux102 ~]# mount /dev/VolGroup00/data /mnt
[root@gflinux102 ~]# cp -R /mnt/* /home/mysqlbackup/
[root@gflinux102 ~]# cd /home/mysqlbackup/
[root@gflinux102 mysqlbackup]# ll
total 8
drwxr-xr-x 5 root root 4096 Jan 30 10:31 data
drwx------ 2 root root 4096 Jan 30 10:24 lost+found
[root@gflinux102 mysqlbackup]# cd data/
[root@gflinux102 data]# ll
total 110732
-rw-r----- 1 root root 56 Jan 30 10:31 auto.cnf
-rw-r----- 1 root root 5 Jan 30 10:31 gflinux.pid
-rw-r----- 1 root root 12582912 Jan 30 10:31 ibdata1
-rw-r----- 1 root root 50331648 Jan 30 10:31 ib_logfile0
-rw-r----- 1 root root 50331648 Jan 30 10:31 ib_logfile1
drwx------ 2 root root 4096 Jan 30 10:31 mysql
drwx------ 2 root root 4096 Jan 30 10:31 performance_schema
drwx------ 2 root root 4096 Jan 30 10:31 test
[root@gflinux102 data]#