Linux Challenge 1 solution - Add an LVM volume for the Database Server

Ticker

6/recent/ticker-posts

Linux Challenge 1 solution - Add an LVM volume for the Database Server

 

Question :  The database server called centos-host is running short on space! You have been asked to add an LVM volume for the Database team using some of the existing disks on this server.

Inspect the requirements in detail by clicking on the icons of the interactive architecture diagram on the right and complete the tasks. Once done click on the Check button to validate your work.


Install the correct packages that will allow the use of "lvm" on the centos machine.

Create a Physical Volume for "/dev/vdb" & "/dev/vdc"

Create a volume group called "dba_storage" using the physical volumes "/dev/vdb" and "/dev/vdc"

Create an "lvm" called "volume_1" from the volume group called "dba_storage". Make use of the entire space available in the volume group.

Format the lvm volume "volume_1" as an "XFS" filesystem

Mount the filesystem at the path "/mnt/dba_storage".

Make sure that this mount point is persistent across reboots with the correct default options.

Create a group called "dba_users" and add the user called 'bob' to this group

Ensure that the mountpoint "/mnt/dba_storage" has the group ownership set to the "dba_users" group

Ensure that the mount point "/mnt/dba_storage" has "read/write" and execute permissions for the owner and group and no permissions for anyone else

Solution:  

1. At first  switch to root user and check any existing physical / logical volumes 

  [bob@centos-host ~]$ sudo su -

  [root@centos-host ~]#

[root@centos-host ~]# pvs

-bash: pvs: command not found

[root@centos-host ~]# lvs

-bash: lvs: command not found

[root@centos-host ~]# rpm -qa |grep lvm

[root@centos-host ~]# 

2.  Install the correct packages that will allow the use of "lvm" on the centos machine.

[root@centos-host ~]# yum install -y lvm2

Dependencies resolved.

=====================================================================================================================================================

 Package                                           Architecture               Version                               Repository                  Size

=====================================================================================================================================================

Installing:

 lvm2                                              x86_64                     8:2.03.12-10.el8                      baseos                     1.6 M

Upgrading:

 device-mapper                                     x86_64                     8:1.02.177-10.el8                     baseos                     377 k

 device-mapper-libs                                x86_64                     8:1.02.177-10.el8                     baseos                     409 k

Installing dependencies:

 device-mapper-event                               x86_64                     8:1.02.177-10.el8                     baseos                     271 k

 device-mapper-event-libs                          x86_64                     8:1.02.177-10.el8                     baseos                     270 k

 device-mapper-persistent-data                     x86_64                     0.9.0-4.el8                           baseos                     925 k

 libaio                                            x86_64                     0.3.112-1.el8                         baseos                      33 k

 lvm2-libs                                         x86_64                     8:2.03.12-10.el8                      baseos                     1.2 M

 

Transaction Summary

=====================================================================================================================================================

Install  6 Packages

                                      

Upgraded:

  device-mapper-8:1.02.177-10.el8.x86_64                                 device-mapper-libs-8:1.02.177-10.el8.x86_64                                

 

Installed:

  device-mapper-event-8:1.02.177-10.el8.x86_64  device-mapper-event-libs-8:1.02.177-10.el8.x86_64  device-mapper-persistent-data-0.9.0-4.el8.x86_64

  libaio-0.3.112-1.el8.x86_64                   lvm2-8:2.03.12-10.el8.x86_64                       lvm2-libs-8:2.03.12-10.el8.x86_64               

 

Complete!

[root@centos-host ~]# rpm -qa |grep lvm

lvm2-libs-2.03.12-10.el8.x86_64

lvm2-2.03.12-10.el8.x86_64

[root@centos-host ~]#  

3. Create a Physical Volume for "/dev/vdb" & "/dev/vdc"

Create a volume group called "dba_storage" using the physical volumes  "/dev/vdb" and "/dev/vdc"

Create an "lvm" called "volume_1" from the volume group called "dba_storage". Make use of the  entire space available in the volume group.

[root@centos-host ~]# pvcreate /dev/vdb

  Physical volume "/dev/vdb" successfully created.

[root@centos-host ~]# pvcreate /dev/vdc

  Physical volume "/dev/vdc" successfully created.

[root@centos-host ~]# vgcreate dba_storage /dev/vdb /dev/vdc

  Volume group "dba_storage" successfully created

[root@centos-host ~]# lvcreate -n volume_1 -l 100%FREE dba_storage

  Logical volume "volume_1" created.

[root@centos-host ~]# pvs

  PV         VG          Fmt  Attr PSize    PFree

  /dev/vdb   dba_storage lvm2 a--  1020.00m    0

  /dev/vdc   dba_storage lvm2 a--  1020.00m    0

[root@centos-host ~]# lvs

  LV       VG          Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  volume_1 dba_storage -wi-a----- 1.99g                                                   

[root@centos-host ~]#

4. Format the lvm volume "volume_1" as an "XFS" filesystem

    Mount the filesystem at the path "/mnt/dba_storage".

[root@centos-host ~]# mkfs.xfs /dev/dba_storage/volume_1

meta-data=/dev/dba_storage/volume_1 isize=512    agcount=4, agsize=130560 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=1, sparse=1, rmapbt=0

         =                       reflink=1

data     =                       bsize=4096   blocks=522240, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0, ftype=1

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@centos-host ~]#

[root@centos-host ~]# mkdir -p /mnt/dba_storage

[root@centos-host ~]# mount -t xfs /dev/dba_storage/volume_1 /mnt/dba_storage

[root@centos-host ~]# df -h /mnt/dba_storage/

Filesystem                        Size  Used Avail Use% Mounted on

/dev/mapper/dba_storage-volume_1  2.0G   47M  2.0G   3% /mnt/dba_storage

[root@centos-host ~]#

5. Make sure that this mount point is persistent across reboots with the correct default options.

[root@centos-host ~]# vi /etc/fstab

[root@centos-host ~]# cat /etc/fstab

# /etc/fstab

# Created by anaconda on Fri Dec  4 17:37:32 2020

#

# Accessible filesystems, by reference, are maintained under '/dev/disk/'.

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.

#

# After editing this file, run 'systemctl daemon-reload' to update systemd

# units generated from this file.

#

UUID=a62c5b49-755e-41b0-9d36-de3d95e17232 /                       xfs     defaults        0 0

/swapfile none swap defaults 0 0

/dev/mapper/dba_storage-volume_1 /mnt/dba_storage xfs defaults 0 0

#VAGRANT-BEGIN

# The contents below are automatically generated by Vagrant. Do not modify.

#VAGRANT-END

[root@centos-host ~]#

6. Create a group called "dba_users" and add the user called 'bob' to this group

[root@centos-host ~]# groupadd dba_users

[root@centos-host ~]# usermod -G dba_users bob

[root@centos-host ~]# id bob

uid=1002(bob) gid=1002(bob) groups=1002(bob),1003(dba_users)

[root@centos-host ~]#


7. Ensure that the mountpoint "/mnt/dba_storage" has the group ownership set to the "dba_users" group

Ensure that the mount point "/mnt/dba_storage" has "read/write" and execute permissions for the owner and group and no permissions for anyone else.

[root@centos-host ~]# ll -lsd /mnt/dba_storage/

0 drwxr-xr-x. 2 root root 6 Nov 10 14:29 /mnt/dba_storage/

[root@centos-host ~]#

[root@centos-host ~]# chown :dba_users /mnt/dba_storage

[root@centos-host ~]#

[root@centos-host ~]# ll -lsd /mnt/dba_storage/

0 drwxr-xr-x. 2 root dba_users 6 Nov 10 14:29 /mnt/dba_storage/

[root@centos-host ~]#

[root@centos-host ~]# chmod 770 /mnt/dba_storage

[root@centos-host ~]# ll -lsd /mnt/dba_storage/

0 drwxrwx---. 2 root dba_users 6 Nov 10 14:29 /mnt/dba_storage/

[root@centos-host ~]#


8. Click on Finish & Confirm to complete the task successfully

Script that automate the entire lab task 

you can copy form gitlab  https://gitlab.com/nb-tech-support/devops.git

Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this , please go through and share your comments. Like and share the knowledge




Post a Comment

0 Comments

Latest Posts

Kodekloud Kubernetes Challenge 4 solution | Build a highly available Redis Cluster | redis-cluster-config | PersistentVolume