ARTH_TASK_07

Automating LVM Partition using Python-Script

According to Google:

In Linux, Logical Volume Manager (LVM) is a device mapper framework that provides logical volume management for the Linux kernel. Most modern Linux distributions are LVM-aware to the point of being able to have their root file systems on a logical volume.

we have attached external hard disks to the OS.

STEP1:

>>CREATE A SCRIPT IN PYTHON TO AUTOMATE THE LVM PROCESS
HERE’S HOW TO WRITE THE CODE:-

STEP2:

RUNNING THE PYTHON SCRIPT AND FILLING THE REQUIRED DETAILS AS A USER.

STEP3:

CHECKING THE FULL STORAGE USING “df -h” COMMAND TO CONFIRM THR CREATED LVM
HERE’S I HAVE CREATED A LVM OF 4GB STORAGE.

Increase or Decrease the Size of Static Partition in Linux.

There are two Memory Management Techniques: Contiguous, and Non-Contiguous. In Contiguous Technique, the executing process must be loaded entirely in the main memory. Contiguous Technique can be divided into:

  1. Fixed (or static) partitioning
  2. Variable (or dynamic) partitioning

We are here going to look upon how we going to make static partition a dynamic one:

STEP1:

Add a physical storage to achieve the partition
We have created a 8gb sdb .

STEP2:

>>Creating a partition on sdb disk to use the storage.

>>Creating a 4-GB partition which we will later increase dynamically without deleting the data.

>>Checking the New Partition and storage.

>>Formatting the Partition to Use the sdb storage.

>>Mounting the sdb storage to the /static directory.

>>Creating a file to check later for security purpose.

STEP3:

>>Unmounting the sdb1 to resize the storage and without loosing the Data

STEP4:

>>Deleting the old partition and will be creating new partition of +7GB

STEP4:

>>Using e2fsck : The e2fsck command is used to check the ext2/ext3/ext4 family of file systems. For ext3 and ext4 filesystems that use a journal, if the system has been shut down uncleanly without any errors, normally, after replaying the committed transactions in the journal, the file system should be marked as clean.

>>Increasing the size of sdb1

STEP5:

>>Mounting again to se the storage:

>>As we can see here Size is increased but alos “t.txt” file is not formatted i.e. We have increased the storage without Formatting the Whole Static Storage.

Integrating LVM with Hadoop and providing Elasticity to Data-Node Storage

According to google:

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.

So what are we going to do?

We are going to use LVM with root storage and increase the size of slave node on the go i.e., without unmounting , removing or without creating using new hard-disk.

Step1:

we have attached an external hard disk sdb of 8GB.

>>Let me show you guys my initial space provided by Data Node.

STEP2:

Creating a physical volume from the sdb hard disk.
>> pvcreate /dev/sdb

STEP3:

We are adding this physical volume to the pre-existing RHEL volume group as we want to make an elastic storage in Root director

Now we have sdb attached to our sda which can be used to increase the size of the datanode as per the requirement.

STEP4:

Now we adding Volume group to the Root-LVM storage.

STEP5:

As we can see above #df -h command does not show the storage increased above as we need to format it but here the important thing is we are going to use the resize command which will only format the later extended part of storage (5G) rest data won’t be affected.

STEP6:

Checking the storage provided by Data Node.

As we can see 5GB is Dynamically Increased

7.2: Docker Task

🔅Configuring HTTPD Server on Docker Container

🔅Setting up Python Interpreter and running Python Code on Docker Container

Step1

RUN THE DOCKER USING RUN COMMAND:
docker run -it — name myos2 ubuntu:20.10

STEP1:(b)
YOU CAN ALSO USE PRE INSTALLED CONTAINER USING:
docker start myos2
docker attach myos2

STEP1:©
TO CHECK RUNNING DOCKER CONTAINER:
docker ps

TO CHECK ALL THE INSTALLED DOCKER CONTAINER:
docker ps -a

STEP 2:
PROGRAMS WE NEED TO INSTALL TO SETUP APACHE2 AND PYHTON:

apt-get update
apt-get install apache2
apt-get install systemctl
apt-get install net-tools
apt-get install python3
apt-get install vim

CONFIGURING HTTPD SERVER ON DOCKER CONTAINER:

INSTALLING APACHE2
apt-get install apache2

INSTALLING VIM
apt-get install vim

STARTING THE APACHE2 SERVICE:
systemctl start apache2
systemctl status apache2

CONFIGURING APACHE2
#cd /var/www/html
#vim rb.html

HERE’S THE OUTPUT OF MY WEBSERVER
Named :: rb.html

SETTING UP PYTHON INTERPRETER AND RUNNING PYTHON CODE ON DOCKER CONTAINER.

INSTALLING PYTHON3 ON DOCKER:

apt-get install python3

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store