What is LVM?
In Linux, LVM is a device mapper framework that provides logical volume management for the Linux kernel. It is a tool implemented in the Linux Kernel that let’s you work with Logical Volumes (LV), volumes that lay between the physical hard drives and the filesystems that will bring these LV to life.
Logical volumes are groups of information located on physical volumes. A hierarchy of structures is used to manage disk storage.
Ways of Managing LVM:
There are 3 concepts that LVM manages:
1️. Physical Volume: A physical volume is a collection of disk partitions used to store all server data.
2️. Volume Groups: is a collection of physical volumes of varying sizes and types.
3️. Logical Volumes: are groups of information located on physical volumes.
Why use LVM?
· LVM can be used to create, delete and resize logical volumes ,online i.e dynamically.
· LVM allows the creation of instant logical volume snapshots while the operating system is running and supports advanced encryption features.
Task Objective:
PART — 1: Integrating LVM with Hadoop and providing Elasticity to DataNode Storage.
PART — 2: Increase or decrease the sixe of static partition in Linux
PART — 3: Automating LVM Partition using Python-Script
Procedure:
PART — 1:
i). Firstly, we need to have JDK and Hadoop installed on at least two different systems on same network in order to configure a Hadoop Cluster.
ii).On one of the system “system1” configure two files in the folder “/etc/hadoop”
- hdfs-site.xml
- core-site.xml
iii).Next we have to configure Name-node by running two commands:
- Hadoop namenode -format- Hadoop-daemon.sh start namenode
iv). Now on “system2” we have to make changes to the same files
v). After this we have to configure the datanode by using the command
“hadoop-daemon.sh start datanode”
vi). Now check the status of the cluster by using the command
“hadoop dfsadmin -report”
PART — 2:
I. First we have to check the status of the disks in the cluster and it’s size by using the command
“fdisk -l”
II. For LVM, we have to first create a Physical Volume of the new device.
To create physical volume we can use the command
“pvcreate /dev/<name of the volume>”
III. Next we have to make a VG and add the PV to it by using command
“vgcreate <name of the VG> /dev/<name of the volume>”
IV. Now creating a LV from our VG, using the command
“lvcreate — size <size> — name <name for the lv> <name of the VG>”
V. Now the newly created LV have to be formatted and mounted manually using the command
“mkfs.ext4 <path_of_lv>” and “mount <path_of_lv> <mount_point_folder”.
VI. For increasing the size of the lvm by size of our choice, we can use command
“lvextend — size +(size in GiB)G /dev/<name of the VG>/<name of the LV>”
VII. Now, we have to Format the extended part using command
"resize2fs /dev/new_vol_group/new_logical_volume”
Finally you will be able to see the size would have been increased while keeping the volume alive(still mounted).
PART -3:
Automating LVM Partition using Python-Script
Step-1: first we will check the disk information using our python script.For that, we are opting “1” from the menu.
Step -2: We have to create a physical volume, for which we will be opting “2” from the menu
Step — 3: After PV, we need to create a Volume Group, so we have to opt “4” from the menu.
Step -4: Now we have to create a LVM, and then format it and mount it over a directory, for that we will opt “4” from the python menu.
Step-5: Now we have to increase the size of the LVM, we will be opting “5” from the menu.
Thanks For Reading!!!