1.磁盘分区
[root@ol6-121-rac1 ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xd8bb2864. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1305, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +5G Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (655-1305, default 655): Using default value 655 Last cylinder, +cylinders or +size{K,M,G} (655-1305, default 1305): Using default value 1305 Command (m for help): p Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xd8bb2864 Device Boot Start End Blocks Id System /dev/sdb1 1 654 5253223+ 83 Linux /dev/sdb2 655 1305 5229157+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@ol6-121-rac1 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. [root@ol6-121-rac1 ~]# fdisk -l /dev/sdb Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xd8bb2864 Device Boot Start End Blocks Id System /dev/sdb1 1 654 5253223+ 83 Linux /dev/sdb2 655 1305 5229157+ 83 Linux
2.创建PV
[root@ol6-121-rac1 ~]# pvcreate /dev/sdb{1,2}
Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdb2" successfully created [root@ol6-121-rac1 ~]# pvscan PV /dev/sda2 VG vg_ol6121rac1 lvm2 [11.51 GiB / 0 free] PV /dev/sdb1 lvm2 [5.01 GiB] PV /dev/sdb2 lvm2 [4.99 GiB] Total: 3 [21.50 GiB] / in use: 1 [11.51 GiB] / in no VG: 2 [10.00 GiB] [root@ol6-121-rac1 ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name vg_ol6121rac1 PV Size 11.51 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2946 Free PE 0 Allocated PE 2946 PV UUID YEG40A-wEWW-9F8Z-bgcL-PWvA-7sef-FP12my "/dev/sdb1" is a new physical volume of "5.01 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 5.01 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID p2nXS7-MmpX-Pawj-ThU3-k1NQ-t5Rc-hqKtb4 "/dev/sdb2" is a new physical volume of "4.99 GiB" --- NEW Physical volume --- PV Name /dev/sdb2 ----PV名 VG Name ----分配的VG,因为没有分配,所以是空 PV Size 4.99 GiB ----PV的大小 Allocatable NO ---是否被分配 PE Size 0 ---PE的大小 Total PE 0 ----共分配的PE数 Free PE 0 ----没有被LV用掉的PE Allocated PE 0 ----尚可被分配的PE数量 PV UUID M31k1o-JGJx-3OrN-DmNf-W8uJ-SXBB-JdSviW 由于PE是在创建VG的时候才指定,所以这里的PE都显示0 [root@ol6-121-rac1 ~]# pvdisplay ---这里显示已经被VG使用的PV(与上面做个对比) --- Physical volume --- PV Name /dev/sdb1 VG Name datavg PV Size 5.01 GiB / not usable 10.10 MiB Allocatable yes PE Size 512.00 MiB Total PE 10 Free PE 10 Allocated PE 0 PV UUID p2nXS7-MmpX-Pawj-ThU3-k1NQ-t5Rc-hqKtb4
创建格式:vgcreate -s N[mgt] VG名称 PV名称
[root@ol6-121-rac1 ~]# vgcreate -s 512M datavg /dev/sdb1 ---“-s”后面加PE的大小,单位可以是m, g,t Volume group "datavg" successfully created [root@ol6-121-rac1 ~]# vgscan Reading all physical volumes. This may take a while... Found volume group "datavg" using metadata type lvm2 Found volume group "vg_ol6121rac1" using metadata type lvm2 [root@ol6-121-rac1 ~]# pvscan PV /dev/sdb1 VG datavg lvm2 [5.00 GiB / 5.00 GiB free] PV /dev/sda2 VG vg_ol6121rac1 lvm2 [11.51 GiB / 0 free] PV /dev/sdb2 lvm2 [4.99 GiB] ---,没有被使用的PV Total: 3 [21.49 GiB] / in use: 2 [16.51 GiB] / in no VG: 1 [4.99 GiB] [root@ol6-121-rac1 ~]# vgdisplay datavg --- Volume group --- VG Name datavg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 5.00 GiB PE Size 512.00 MiB Total PE 10 Alloc PE / Size 0 / 0 Free PE / Size 10 / 5.00 GiB VG UUID wtuMSA-qOM7-eslo-BeiR-N8pJ-PVic-ZQXDXu 扩展VG [root@ol6-121-rac1 ~]# vgextend datavg /dev/sdb2 Volume group "datavg" successfully extended [root@ol6-121-rac1 ~]# vgdisplay datavg --- Volume group --- VG Name datavg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 9.50 GiB PE Size 512.00 MiB Total PE 19 Alloc PE / Size 0 / 0 Free PE / Size 19 / 9.50 GiB VG UUID wtuMSA-qOM7-eslo-BeiR-N8pJ-PVic-ZQXDXu
创建格式:lvcreate -L N[mgt] -n LV名称 VG名称 或者 lvcreate -l N -n LV名称 VG名称 说明:-L 后面加容量 -l 后面加PE的个数 [root@ol6-121-rac1 ~]# lvcreate -L 5G -n datalv datavg 创建一个5G的LV Logical volume "datalv" created [root@ol6-121-rac1 ~]# vgdisplay datavg --- Volume group --- VG Name datavg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 9.50 GiB PE Size 512.00 MiB Total PE 19 Alloc PE / Size 10 / 5.00 GiB Free PE / Size 9 / 4.50 GiB VG UUID wtuMSA-qOM7-eslo-BeiR-N8pJ-PVic-ZQXDXu [root@ol6-121-rac1 ~]# lvdisplay --- Logical volume --- LV Path /dev/datavg/datalv LV Name datalv VG Name datavg LV UUID sZ5JSE-YkRc-QxLA-GzWT-lLSR-s0WY-b0R8Pv LV Write Access read/write LV Creation host, time ol6-121-rac1.localdomain, 2014-03-18 10:09:29 +0800 LV Status available # open 0 LV Size 5.00 GiB Current LE 10 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 [root@ol6-121-rac1 ~]# ll /dev/datavg/datalv lrwxrwxrwx 1 root root 7 Mar 18 10:09 /dev/datavg/datalv -> ../dm-2 删除LV:lvremove /dev/datavg/datalv ---注意:要加绝对路径 扩展LV [root@ol6-121-rac1 ~]# lvresize -l +9 /dev/datavg/datalv 绝对路径 Extending logical volume datalv to 9.50 GiB Logical volume datalv successfully resized [root@ol6-121-rac1 ~]# lvdisplay --- Logical volume --- LV Path /dev/datavg/datalv LV Name datalv VG Name datavg LV UUID j5Wvb3-ZFiz-5PyG-gfdp-NPb4-BdRq-PhT1wm LV Write Access read/write LV Creation host, time ol6-121-rac1.localdomain, 2014-03-18 10:14:28 +0800 LV Status available # open 0 LV Size 9.50 GiB Current LE 19 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2
[root@ol6-121-rac1 ~]# mkfs -t ext4 /dev/datavg/datalv ---格式化,注意LV全名 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 622592 inodes, 2490368 blocks 124518 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2550136832 76 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@ol6-121-rac1 ~]# mount /dev/datavg/datalv /oradata/ ---挂载 [root@ol6-121-rac1 ~]# df -lhT ---查看 Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/vg_ol6121rac1-lv_root ext4 9.4G 3.9G 5.1G 43% / tmpfs tmpfs 499M 100K 499M 1% /dev/shm /dev/sda1 ext4 485M 55M 405M 12% /boot /dev/sr0 iso9660 3.5G 3.5G 0 100% /media/OL6.4 x86_64 Disc 1 20130225 /dev/mapper/datavg-datalv ext4 9.4G 150M 8.8G 2% /oradata
——————————————————————————
Lookers-on see most of the game.-- Smedley
旁观者清
——————————————————————————