How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2 Commands
LVM stands for Logical Volume Manager.
With LVM, we can create logical partitions that can span across one or more physical hard drives.
First, the hard drives are divided into physical volumes, then those physical volumes are combined
together to create the
volume group and finally the logical volumes are created from volume group.
PHDISK >> PHVolumn >> Virtual Group VG >> LV
Before we start, install the lvm2 package as shown below.
$ sudo apt-get intall lvm2
Select the Physical Storage Devices for LVM – Use pvcreate, pvscan, pvdisplay Commands
[root@LINUX ~]# pvscan
PV /dev/sdb1 VG dbname lvm2 [600.00 GB / 41.00 GB free]
PV /dev/sda2 VG VolGroup00 lvm2 [29.88 GB / 0 free]
Total: 2 [629.87 GB] / in use: 2 [629.87 GB] / in no VG: 0 [0 ]
fdisk -l
pvcreate /dev/sdb1
You can view the list of physical volumes with attributes like size, physical extent size, total physical extent size,
the free space, etc., using pvdisplay command as shown below.
[root@LINUX ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name dbname
PV Size 600.00 GB / not usable 3.93 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 153599
Free PE 10495
Allocated PE 143104
PV UUID 7CaKIx-3bE9-9FGy-DdlU-2flY-sew2-0Wgmek
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 29.90 GB / not usable 24.06 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 956
Free PE 0
Allocated PE 956
PV UUID RpdbnameW-txLL-naS2-G3Xf-Pa3Y-fN8u-3zmKVT
Create the Volume Group – Use vgcreate, vgdisplay Commands
vgcreate dbname /dev/sdb1
[root@LINUX ~]# vgdisplay
--- Volume group ---
VG Name dbname
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 600.00 GB
PE Size 4.00 MB
Total PE 153599
Alloc PE / Size 143104 / 559.00 GB
Free PE / Size 10495 / 41.00 GB
VG UUID 3P0SQ5-BtSD-lzDa-XeE3-sEid-guic-HTsiCj
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.88 GB
PE Size 32.00 MB
Total PE 956
Alloc PE / Size 956 / 29.88 GB
Free PE / Size 0 / 0
VG UUID ecNnL2-WsfQ-78Dn-Lr4R-lRYp-q5Ee-uIcJ4W
LVM Create: Create Logical Volumes – Use lvcreate, lvdisplay command
man lvcreate
lvcreate -n dbname-oraredo2 -L 2g dbname
lvcreate -n dbname-flashback -L 2g dbname
lvcreate -n dbname-oradata1 -L 388g dbname
lvextend -L+22G /dev/dbname/dbname-flashback
[root@LINUX ~]# lvdisplay
--- Logical volume ---
LV Name /dev/dbname/dbname-oraredo2
VG Name dbname
LV UUID fT0MIr-Bls6-51iq-emPx-Qf42-pnvk-0iwaNk
LV Write Access read/write
LV Status available
# open 0
LV Size 2.00 GB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4
--- Logical volume ---
LV Name /dev/dbname/dbname-flashback
VG Name dbname
LV UUID c18sq1-3UMs-xOGt-d9al-y2D5-ohXh-ORU8Ai
LV Write Access read/write
LV Status available
# open 0
LV Size 24.00 GB
Current LE 6144
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:5
--- Logical volume ---
LV Name /dev/dbname/dbname-oradata1
VG Name dbname
LV UUID 0EqjlW-A1P3-5837-PuvV-E1dC-TseI-yA7CA8
LV Write Access read/write
LV Status available
# open 0
LV Size 388.00 GB
Current LE 99328
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:6
--- Logical volume ---
LV Name /dev/dbname/orasoft
VG Name dbname
LV UUID yuEZI6-ZTUy-GQze-rVz0-67La-7zSu-apuVQK
LV Write Access read/write
LV Status available
# open 0
LV Size 145.00 GB
Current LE 37120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:7
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID hA44xM-pgKG-1HCa-mvLa-JOew-FPYh-pxNT4w
LV Write Access read/write
LV Status available
# open 1
LV Size 7.00 GB
Current LE 224
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol02
VG Name VolGroup00
LV UUID etRJ9K-0Je9-2DGu-dulU-eiIF-WDzh-ssJHB1
LV Write Access read/write
LV Status available
# open 1
LV Size 7.00 GB
Current LE 224
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol03
VG Name VolGroup00
LV UUID 2npFKh-0kJ4-QAQ2-0MhJ-VCRs-vN2y-LpixJh
LV Write Access read/write
LV Status available
# open 1
LV Size 13.88 GB
Current LE 444
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID Ss2TiB-ps4H-tTWw-pvPJ-nadh-MhxY-xm06i3
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GB
Current LE 64
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
After creating the appropriate filesystem on the logical volumes, it becomes ready to use for the storage purpose.
mkfs -t ext3 /dev/dbname/dbname-flashback
mkfs -t ext3 /dev/dbname/dbname-oradata2
mkfs -t ext3 /dev/dbname/dbname-oradata1
mkdir -p /dbname/dbnameproddb/oraredo2
mkdir -p /dbname/dbnameproddb/flashback
mkdir -p /dbname/dbnameproddb/oradata1
mount /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
mount /dev/dbname/dbname-oradata1 /dbname/dbnameproddb/oradata1
df -h
mount -t ext3 /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
more /etc/fstab
man mkfs
lvs
mkfst -t ext3 /dev/dbname/dbname-flashback
mkfs -t ext3 /dev/dbname/dbname-flashback
mount /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
mkfs -t ext3 /dev/dbname/dbname-oradata1
mount /dev/dbname/dbname-oradata1 /dbname/dbnameproddb/oradata1
mkfs -t ext3 /dev/dbname/dbname-oradata2
lvs
mkfs -t ext3 /dev/dbname/dbname-oraredo2
mount /dev/dbname/dbname-dbname-oraredo2 /dbname/dbnameproddb/oraredo2
mount /dev/dbname/dbname-oraredo2 /dbname/dbnameproddb/oraredo2
[root@LINUX ~]# mount /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
[root@LINUX ~]# mount /dev/dbname/dbname-oraredo2 /dbname/dbnameproddb/oraredo2
mount /dev/dbname/dbname-oradata1 /dbname/dbnameproddb/oradata1
mount /dev/dbname/orasoft /dbname/prod/orasoft
/dev/mapper/dbname-dbname--flashback
24770940 176200 23336452 1% /dbname/dbnameproddb/flashback
/dev/mapper/dbname-dbname--oraredo2
2064208 68680 1890672 4% /dbname/dbnameproddb/oraredo2
/dev/mapper/dbname-dbname--oradata1
400463896 158907264 221214260 42% /dbname/dbnameproddb/oradata1
/dev/mapper/dbname-orasoft
149657900 20823352 121232372 15% /dbname/prod/orasoft
LVM stands for Logical Volume Manager.
With LVM, we can create logical partitions that can span across one or more physical hard drives.
First, the hard drives are divided into physical volumes, then those physical volumes are combined
together to create the
volume group and finally the logical volumes are created from volume group.
PHDISK >> PHVolumn >> Virtual Group VG >> LV
Before we start, install the lvm2 package as shown below.
$ sudo apt-get intall lvm2
Select the Physical Storage Devices for LVM – Use pvcreate, pvscan, pvdisplay Commands
[root@LINUX ~]# pvscan
PV /dev/sdb1 VG dbname lvm2 [600.00 GB / 41.00 GB free]
PV /dev/sda2 VG VolGroup00 lvm2 [29.88 GB / 0 free]
Total: 2 [629.87 GB] / in use: 2 [629.87 GB] / in no VG: 0 [0 ]
fdisk -l
pvcreate /dev/sdb1
You can view the list of physical volumes with attributes like size, physical extent size, total physical extent size,
the free space, etc., using pvdisplay command as shown below.
[root@LINUX ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name dbname
PV Size 600.00 GB / not usable 3.93 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 153599
Free PE 10495
Allocated PE 143104
PV UUID 7CaKIx-3bE9-9FGy-DdlU-2flY-sew2-0Wgmek
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 29.90 GB / not usable 24.06 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 956
Free PE 0
Allocated PE 956
PV UUID RpdbnameW-txLL-naS2-G3Xf-Pa3Y-fN8u-3zmKVT
Create the Volume Group – Use vgcreate, vgdisplay Commands
vgcreate dbname /dev/sdb1
[root@LINUX ~]# vgdisplay
--- Volume group ---
VG Name dbname
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 600.00 GB
PE Size 4.00 MB
Total PE 153599
Alloc PE / Size 143104 / 559.00 GB
Free PE / Size 10495 / 41.00 GB
VG UUID 3P0SQ5-BtSD-lzDa-XeE3-sEid-guic-HTsiCj
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.88 GB
PE Size 32.00 MB
Total PE 956
Alloc PE / Size 956 / 29.88 GB
Free PE / Size 0 / 0
VG UUID ecNnL2-WsfQ-78Dn-Lr4R-lRYp-q5Ee-uIcJ4W
LVM Create: Create Logical Volumes – Use lvcreate, lvdisplay command
man lvcreate
lvcreate -n dbname-oraredo2 -L 2g dbname
lvcreate -n dbname-flashback -L 2g dbname
lvcreate -n dbname-oradata1 -L 388g dbname
lvextend -L+22G /dev/dbname/dbname-flashback
[root@LINUX ~]# lvdisplay
--- Logical volume ---
LV Name /dev/dbname/dbname-oraredo2
VG Name dbname
LV UUID fT0MIr-Bls6-51iq-emPx-Qf42-pnvk-0iwaNk
LV Write Access read/write
LV Status available
# open 0
LV Size 2.00 GB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4
--- Logical volume ---
LV Name /dev/dbname/dbname-flashback
VG Name dbname
LV UUID c18sq1-3UMs-xOGt-d9al-y2D5-ohXh-ORU8Ai
LV Write Access read/write
LV Status available
# open 0
LV Size 24.00 GB
Current LE 6144
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:5
--- Logical volume ---
LV Name /dev/dbname/dbname-oradata1
VG Name dbname
LV UUID 0EqjlW-A1P3-5837-PuvV-E1dC-TseI-yA7CA8
LV Write Access read/write
LV Status available
# open 0
LV Size 388.00 GB
Current LE 99328
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:6
--- Logical volume ---
LV Name /dev/dbname/orasoft
VG Name dbname
LV UUID yuEZI6-ZTUy-GQze-rVz0-67La-7zSu-apuVQK
LV Write Access read/write
LV Status available
# open 0
LV Size 145.00 GB
Current LE 37120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:7
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID hA44xM-pgKG-1HCa-mvLa-JOew-FPYh-pxNT4w
LV Write Access read/write
LV Status available
# open 1
LV Size 7.00 GB
Current LE 224
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol02
VG Name VolGroup00
LV UUID etRJ9K-0Je9-2DGu-dulU-eiIF-WDzh-ssJHB1
LV Write Access read/write
LV Status available
# open 1
LV Size 7.00 GB
Current LE 224
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol03
VG Name VolGroup00
LV UUID 2npFKh-0kJ4-QAQ2-0MhJ-VCRs-vN2y-LpixJh
LV Write Access read/write
LV Status available
# open 1
LV Size 13.88 GB
Current LE 444
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID Ss2TiB-ps4H-tTWw-pvPJ-nadh-MhxY-xm06i3
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GB
Current LE 64
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
After creating the appropriate filesystem on the logical volumes, it becomes ready to use for the storage purpose.
mkfs -t ext3 /dev/dbname/dbname-flashback
mkfs -t ext3 /dev/dbname/dbname-oradata2
mkfs -t ext3 /dev/dbname/dbname-oradata1
mkdir -p /dbname/dbnameproddb/oraredo2
mkdir -p /dbname/dbnameproddb/flashback
mkdir -p /dbname/dbnameproddb/oradata1
mount /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
mount /dev/dbname/dbname-oradata1 /dbname/dbnameproddb/oradata1
df -h
mount -t ext3 /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
more /etc/fstab
man mkfs
lvs
mkfst -t ext3 /dev/dbname/dbname-flashback
mkfs -t ext3 /dev/dbname/dbname-flashback
mount /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
mkfs -t ext3 /dev/dbname/dbname-oradata1
mount /dev/dbname/dbname-oradata1 /dbname/dbnameproddb/oradata1
mkfs -t ext3 /dev/dbname/dbname-oradata2
lvs
mkfs -t ext3 /dev/dbname/dbname-oraredo2
mount /dev/dbname/dbname-dbname-oraredo2 /dbname/dbnameproddb/oraredo2
mount /dev/dbname/dbname-oraredo2 /dbname/dbnameproddb/oraredo2
[root@LINUX ~]# mount /dev/dbname/dbname-flashback /dbname/dbnameproddb/flashback
[root@LINUX ~]# mount /dev/dbname/dbname-oraredo2 /dbname/dbnameproddb/oraredo2
mount /dev/dbname/dbname-oradata1 /dbname/dbnameproddb/oradata1
mount /dev/dbname/orasoft /dbname/prod/orasoft
/dev/mapper/dbname-dbname--flashback
24770940 176200 23336452 1% /dbname/dbnameproddb/flashback
/dev/mapper/dbname-dbname--oraredo2
2064208 68680 1890672 4% /dbname/dbnameproddb/oraredo2
/dev/mapper/dbname-dbname--oradata1
400463896 158907264 221214260 42% /dbname/dbnameproddb/oradata1
/dev/mapper/dbname-orasoft
149657900 20823352 121232372 15% /dbname/prod/orasoft
No comments:
Post a Comment