linux foundation week 6

Keywords: Operation & Maintenance CentOS yum network Linux

1. Self built yum warehouse, network source and local source respectively

Steps to create yum warehouse: 1) mount Centos system CD to a directory or copy network resources to a directory

2) find the repodata directory, which is located in the upper directory of yum warehouse address (network sharing is required if creating a network warehouse)

3) create and edit the file ending with.Repo in the directory /etc/yum.repo.d

repo file content:

[basenew]                     Warehouse unique identifier               
name=basenew                  Warehouse name 
baseurl=file:///MNT Yum warehouse address local warehouse file: / / / network warehouse ftp: / / or http: / / or https://
gpgcheck=1                    Verify file 0 is not verified and 1 is verified
gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-7 verify file path

2. Compile and install http2.4, the implementation can be accessed normally, and submit the compilation steps and results

tar xvf httpd-2.4.25.tar.bz2
cd httpd-2.4.25/
yum install -y apr-devel apr-util-devel gcc pcre-devel
./configure --prefix=/apps/httpd
make
make install
cd /apps/httpd/bin
./apachectl start

The results of connecting through another machine are as follows

[root@localhost ~]# curl 192.168.3.8
<html><body><h1>It works!</h1></body></html>

3. Create a 2G file system with block size of 2048byte, 1% free space reserved, ext4 as the file system, and test as the volume label. This partition is required to be automatically mounted to the / test directory after power on, and acl mounting option is available by default

1) add a 2G hard disk to the virtual machine

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  200G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0  199G  0 part
  ├─centos-root 253:0    0  197G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    2G  0 disk
sr0              11:0    1  4.4G  0 rom

2) create partition

[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x71352416.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-4194303, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303):
Using default value 4194303
Partition 1 of type Linux and of size 2 GiB is set

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

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

3) create a file system

[root@localhost ~]# mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048064 blocks
10480 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

4) check the UUID of the device

[root@localhost ~]# blkid
/dev/sda1: UUID="9a5ee9ca-f800-412c-96fb-54d44d4531f6" TYPE="xfs"
/dev/sda2: UUID="jQNwBL-y1wI-r42P-tuca-1yOX-nf0p-lzafsp" TYPE="LVM2_member"
/dev/sdb1: LABEL="TEST" UUID="15f66239-77ae-4fc5-98e5-a3cc49d27660" TYPE="ext4"
/dev/sr0: UUID="2019-09-11-18-50-31-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/mapper/centos-root: UUID="3fd73f39-4952-40f5-ad9b-db02254d6d6a" TYPE="xfs"
/dev/mapper/centos-swap: UUID="f488cb76-3982-4234-ac25-b6920f4d1e26" TYPE="swap"

5) write / etc/fstab file and create mount point

[root@localhost ~]# mkdir /test
#
#/etc/fstab
#Created by anaconda on Mon Feb 17 19:45:02 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=9a5ee9ca-f800-412c-96fb-54d44d4531f6 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0

UUID=15f66239-77ae-4fc5-98e5-a3cc49d27660 /test ext4 defaults 0 0

4. Create a vg named testvg with a size of 20G, consisting of at least two PV S. The PE size is required to be 16MB. Then create a 5G logical volume testlv in the volume group and mount it in the / users directory

1) create pv, vg and lv successively

[root@localhost ~]# pvcreate /dev/sdb /dev/sdc
  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.
[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize    PFree
  /dev/sda2  centos lvm2 a--  <199.00g     0
  /dev/sdb          lvm2 ---    20.00g 20.00g
  /dev/sdc          lvm2 ---    20.00g 20.00g
[root@localhost ~]# vgcreate -s 16m test  /dev/sdb /dev/sdc
  Volume group "test" successfully created
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               test
  System ID
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               <39.97 GiB
  PE Size               16.00 MiB
  Total PE              2558
  Alloc PE / Size       0 / 0
  Free  PE / Size       2558 / <39.97 GiB
  VG UUID               1hhdVA-IREt-yUkh-AgbX-PiA0-FZdL-Veg0hZ
[root@localhost ~]# lvcreate -n testlv -L 5G test
  Logical volume "testlv" created.
[root@localhost ~]# lvs
  LV     VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   centos -wi-ao---- <197.00g                                                   
  swap   centos -wi-ao----    2.00g                                                   
  testlv test   -wi-a-----    5.00g              

2) create a file system for the logical volume lv and mount it

[root@localhost ~]# mkfs.ext4 /dev/test/testlv                                     
[root@localhost ~]# mkdir /users
[root@localhost ~]# mount /dev/test/testlv /users
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  200G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0  199G  0 part
  ├─centos-root 253:0    0  197G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   20G  0 disk
└─test-testlv   253:2    0    5G  0 lvm  /users
sdc               8:32   0   20G  0 disk
sr0              11:0    1  4.4G  0 rom

Posted by Nay on Wed, 19 Feb 2020 07:36:39 -0800