All about LVM’s – Small Demo


All about LVM’s 

Because of the wide technolgy today, i feel DBA should have some knowledge on hardware and OS knowledge.

I am a big fan of LVM’s.I have been working on LVM’s (including Veritas LVM/Volume manager and Solstice DiskSuite in Solaris ) for the past 10 years.Veritas used to be little complex those days,but any more today.

I had an opportunity to work on Veritas Volume Manager and LVM’s (approx 8 years ago , for a client called Auripay at Cambridge).I used to hot swap the SCSI drives and test the VM’s groups.It was so intresting to see the VM groups swaping to different nodes.Prasad putta (MD of Auripay , now he is VP at Oatsystems) used to encourage me and given me full freedom on this implementation/testing.Got a very good exposure on veritas there.

I have done all my home testing with LVM’s only – not just with regular ext2 FS. Because it gives me the flexibility to add more space to the existing volumes as i needed and additionally i do see much better system performance.

Just i want to share my small Linux LVM experience (quite simple) with Other DBA’s 

Demo

I created a small device of 8GB size 

After login just find out the device name , here it is sdd.

you can use the dmesg command to find this.

SCSI device sdd: 16777216 512-byte hdwr sectors (8590 MB)
sdd: cache data unavailable
sdd: assuming drive cache: write through
SCSI device sdd: 16777216 512-byte hdwr sectors (8590 MB)
sdd: cache data unavailable
sdd: assuming drive cache: write through
sdd: unknown partition table
Attached scsi disk sdd at scsi0, channel 0, id 3, lun 0
Fusion MPT SAS Host driver 3.02.62.01rh
EXT3-fs: INFO: recovery required on readonly filesystem.
EXT3-fs: write access will be enabled during recovery.
kjournald starting. Commit interval 5 seconds
EXT3-fs: sda3: orphan cleanup on readonly fs
ext3_orphan_cleanup: deleting unreferenced inode 115623
EXT3-fs: sda3: 1 orphan inode deleted
EXT3-fs: recovery complete.
EXT3-fs: mounted filesystem with ordered data mode.
SELinux: Disabled at runtime.
SELinux: Unregistering netfilter hooks
inserting floppy driver for 2.6.9-34.EL
Floppy drive(s): fd0 is 1.44M
FDC 0 is a post-1991 82077
vmxnet: module license ‘unspecified’ taints kernel.
VMware vmxnet virtual NIC driver release 1.0.1 build-29996
ACPI: PCI interrupt 0000:00:11.0[A] -> GSI 10 (level, low) -> IRQ 10
Found vmxnet/PCI at 0x1424, irq 10.
vmxnet: numRxBuffers=(100*24) numTxBuffers=(100*64) driverDataSize=9000
divert: allocating divert_blk for eth0
eth0: vmxnet ether at 0x1424 assigned IRQ 10.
ACPI: PCI interrupt 0000:00:12.0[A] -> GSI 9 (level, low) -> IRQ 9
Found vmxnet/PCI at 0x14a4, irq 9.
vmxnet: numRxBuffers=(100*24) numTxBuffers=(100*64) driverDataSize=9000
divert: allocating divert_blk for eth1
eth1: vmxnet ether at 0x14a4 assigned IRQ 9.
ACPI: PCI interrupt 0000:00:13.0[A] -> GSI 5 (level, low) -> IRQ 5
Found vmxnet/PCI at 0x1824, irq 5.
vmxnet: numRxBuffers=(100*24) numTxBuffers=(100*64) driverDataSize=9000
divert: allocating divert_blk for eth2
eth2: vmxnet ether at 0x1824 assigned IRQ 5.
pcnet32.c:v1.31 29.04.2005 tsbogend@alpha.franken.de
ACPI: PCI interrupt 0000:00:14.0[A] -> GSI 11 (level, low) -> IRQ 11
shpchp: shpc_init : shpc_cap_offset == 0
shpchp: Standard Hot Plug PCI Controller Driver version: 0.4
USB Universal Host Controller Interface driver v2.2
ACPI: PCI interrupt 0000:00:07.2[D] -> GSI 9 (level, low) -> IRQ 9
uhci_hcd 0000:00:07.2: UHCI Host Controller
uhci_hcd 0000:00:07.2: irq 9, io base 00001060
uhci_hcd 0000:00:07.2: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
md: Autodetecting RAID arrays.
md: autorun …
md: … autorun DONE.
NET: Registered protocol family 10
Disabled Privacy Extensions on device c0378f60(lo)
IPv6 over IPv4 tunneling driver
divert: not allocating divert_blk for non-ethernet device sit0
ip_tables: (C) 2000-2002 Netfilter core team
vmxnet_init_ring: offset=9000 length=9000
vmxnet_init_ring: offset=9000 length=9000
ip_tables: (C) 2000-2002 Netfilter core team
vmxnet_init_ring: offset=9000 length=9000
ACPI: AC Adapter [ACAD] (on-line)
ACPI: Power Button (FF) [PWRF]
eth0: no IPv6 routers present
eth1: no IPv6 routers present
eth2: no IPv6 routers present
EXT3 FS on sda3, internal journal
device-mapper: 4.5.0-ioctl (2005-10-04) initialised: dm-devel@redhat.com
cdrom: open failed.
kjournald starting. Commit interval 5 seconds
EXT3 FS on sda1, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
Adding 1534196k swap on /dev/sda2. Priority:-1 extents:1
IA-32 Microcode Update Driver: v1.14 <tigran@veritas.com>
microcode: No new microdata for cpu 0
IA-32 Microcode Update Driver v1.14 unregistered
parport0: PC-style at 0x378 [PCSPP,TRISTATE]
ip_tables: (C) 2000-2002 Netfilter core team
ip_tables: (C) 2000-2002 Netfilter core team
ip_tables: (C) 2000-2002 Netfilter core team
ip_tables: (C) 2000-2002 Netfilter core team
iscsi-sfnet: Loading iscsi_sfnet version 4:0.1.11-2
iscsi-sfnet: Control device major number 254
OCFS2 Node Manager 1.2.3 Wed Jul 26 12:04:10 PDT 2006 (build 56074a7e99f767e0530 6907521c8ea25)
OCFS2 DLM 1.2.3 Wed Jul 26 12:04:10 PDT 2006 (build 05157a797e82010a31dfd4c78548 4fe9)
OCFS2 DLMFS 1.2.3 Wed Jul 26 12:04:11 PDT 2006 (build 05157a797e82010a31dfd4c785 484fe9)
OCFS2 User DLM kernel interface loaded
i2c /dev entries driver
ASM: oracleasmfs mounted with options: 
ASM: maxinstances=0
SCSI device sdb: 167772160 512-byte hdwr sectors (85899 MB)
sdb: cache data unavailable
sdb: assuming drive cache: write through
sdb: unknown partition table
SCSI device sdc: 96468992 512-byte hdwr sectors (49392 MB)
sdc: cache data unavailable
sdc: assuming drive cache: write through
sdc: unknown partition table
SCSI device sdd: 16777216 512-byte hdwr sectors (8590 MB)
sdd: cache data unavailable
sdd: assuming drive cache: write through
sdd: unknown partition table
parport0: PC-style at 0x378 [PCSPP,TRISTATE]
lp0: using parport0 (polling).
lp0: console ready
ip_tables: (C) 2000-2002 Netfilter core team
vmxnet_init_ring: offset=9000 length=9000
eth0: no IPv6 routers present
[root@Apps3 ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

Now create 2 partitions using fdisk utility 

The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdd: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): +4000M

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (488-1044, default 488):
Using default value 488
Last cylinder or +size or +sizeM or +sizeK (488-1044, default 1044):
Using default value 1044

Command (m for help): p

Disk /dev/sdd: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdd1 1 487 3911796 83 Linux
/dev/sdd2 488 1044 4474102+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

First Create a physical Volume on first partition

[root@Apps3 ~]# pvcreate /dev/sdd1 —> First Partition
Physical volume “/dev/sdd1” successfully created

Next create a Volume group on top of the physical volume just (/dev/sdd1) created

[root@Apps3 ~]# vgcreate volgrp_1 /dev/sdd1
Volume group “volgrp_1” successfully created

See the Phyical volume structure

[root@Apps3 ~]# pvdisplay /dev/sdd1
— Physical volume —
PV Name /dev/sdd1
VG Name volgrp_1
PV Size 3.73 GB / not usable 0
Allocatable yes
PE Size (KByte) 4096
Total PE 954
Free PE 954
Allocated PE 0
PV UUID v3tkkp-Wsa2-yk3s-lhwG-wlkn-F8g5-2GcfGS

View the Volume group structure just created

[root@Apps3 ~]# vgdisplay volgrp_1
— Volume group —
VG Name volgrp_1
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 3.73 GB
PE Size 4.00 MB
Total PE 954
Alloc PE / Size 0 / 0
Free PE / Size 954 / 3.73 GB
VG UUID zUAAMY-9Z7L-4CsQ-HUKK-p37P-TlvR-XzfUKW

[root@Apps3 ~]# fdisk /dev/sdd -l

Disk /dev/sdd: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdd1 1 487 3911796 83 Linux
/dev/sdd2 488 1044 4474102+ 83 Linux

To increase the VG size, just add the partition /dev/sdd2 to the existing volume group

[root@Apps3 ~]# pvcreate /dev/sdd2 –> create this before adding
Physical volume “/dev/sdd2” successfully created
[root@Apps3 ~]# vgextend volgrp_1 /dev/sdd2
Volume group “volgrp_1” successfully extended

Now you see the Volume group size increased from 4GB to 8GB

[root@Apps3 ~]# vgdisplay volgrp_1
— Volume group —
VG Name volgrp_1
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 7.99 GB
PE Size 4.00 MB
Total PE 2046
Alloc PE / Size 0 / 0
Free PE / Size 2046 / 7.99 GB
VG UUID zUAAMY-9Z7L-4CsQ-HUKK-p37P-TlvR-XzfUKW

Now remove the physical volume from the extended volume group

[root@Apps3 ~]# vgreduce volgrp_1 /dev/sdd2
Removed “/dev/sdd2” from volume group “volgrp_1”

See the size is reduced to 4GB now

[root@Apps3 ~]# vgdisplay volgrp_1
— Volume group —
VG Name volgrp_1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
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 3.73 GB
PE Size 4.00 MB
Total PE 954
Alloc PE / Size 0 / 0
Free PE / Size 954 / 3.73 GB
VG UUID zUAAMY-9Z7L-4CsQ-HUKK-p37P-TlvR-XzfUKW

Create a logical volume now on top of the volume group – volgrp_1 size 200MB

[root@Apps3 ~]# lvcreate -n logvol_1 –size 200M volgrp_1
Logical volume “logvol_1” created

See the structure of LVM just created

[root@Apps3 ~]# lvdisplay /dev/volgrp_1/logvol_1
— Logical volume —
LV Name /dev/volgrp_1/logvol_1
VG Name volgrp_1
LV UUID jwQVYp-0K5H-iJLW-JO3n-CPn4-nnyI-ibglYZ
LV Write Access read/write
LV Status available
# open 0
LV Size 200.00 MB
Current LE 50
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0

[root@Apps3 ~]# vgdisplay volgrp_1|grep “Total PE”
Total PE 954

Now you are ready to create any FS on to this LVM – here we are creating ext2 FS

[root@Apps3 ~]# mkfs /dev/volgrp_1/logvol_1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Mount the LVM – 

[root@Apps3 ~]# mount /dev/volgrp_1/logvol_1 /u01
[root@Apps3 ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 3241580 2404772 672144 79% /
/dev/sda1 396623 13530 362612 4% /boot
none 676380 0 676380 0% /dev/shm
/dev/mapper/volgrp_1-logvol_1
198337 1550 186547 1% /u01

All set to create any Oracle installations on top of this LVM now.

Hope this helps

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s