Linux课程第七周作业


一、自建yum仓库,分别为网络源和本地源

#实现本地光盘挂载
yum -y install autofs
systemctl enable --now autofs
#进入yum仓库配置文件存放目录
cd /etc/yum.repos.d
#创建网络源以及本地源yum仓库配置文件
vim base.repo
#编写网络源以及本地源yum仓库配置文件
[BaseOS]
name=BaseOS
baseurl=file:///misc/cd/BaseOS/
        https://mirros.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=0
enabled=1

[AppStream]
name=Appstream
baseurl=file:///misc/cd/AppStream/
gpgcheck=0
enabled=1

[extras]
name=extras
baseurl=https://mirros.aliyun.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/os/
gpgcheck=0
enabled=1

[epel]
name=epel
baseurl=https://mirros.aliyun.com/epel/$releasever/Everything/$basearch/
        http://mirrors.huaweicloud.com/epel/$releasever/Everything/$basearch/
enabled=1
gpgcheck=0

二、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交

#安装前准备:关闭防火墙和SELinux
#关闭SElinux
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
#SELINUXTYPE=targeted
#检查SELinux是否关闭
sestatus | grep status

#关闭防火墙
#关闭防火墙
systemctl stop firewalld.service
#设定下刺激开机不会启动防护墙O
systemctl disable firewalld.service
#查看防护墙状态
systemctl status firewalld.service

#把需要的包安装了
dnf install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
#创建一个用来存放下载的安装包的文件夹
mkdir /data/sources
#下载httpd压缩包
wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
#解压包
tar xvf httpd-2.4.46.tar.bz2 -C //usr/local/src
#配置
cd /usr/local/src/httpd-2.4.46/
./configure --prefix=/apps/httpd24 -sysconfdir=/etc/httpd24 --enable-ssl
#编译并安装
make -j 4 && make install
#配置环境
echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
. /etc/profile.d/httpd24.sh
#运行
apachectl
#指定apache用户运行
useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
vim /etc/httpd24/httpd.conf
User apache
Group apache
#生效和验证
apachectl restart
#查看
ps aux

在这里插入图片描述

三、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项

1、查看块设备信息

[root@repo-server ~]# 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  100G  0 part /
|-sda3   8:3    0   50G  0 part /data
|-sda4   8:4    0    1K  0 part
`-sda5   8:5    0    4G  0 part [SWAP]
sdb      8:16   0   20G  0 disk
sdc      8:32   0   20G  0 disk
sdd      8:48   0   20G  0 disk
sde      8:64   0   20G  0 disk
sr0     11:0    1  7.7G  0 rom

2、在sdb磁盘上创建大小为2G的分区

[root@repo-server ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0x1e01229e.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): +2G

Created a new partition 1 of type 'Linux' and of size 2 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

3、在sdb1分区上创建文件系统

[root@repo-server ~]# mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1048576 2k blocks and 131072 inodes
Filesystem UUID: ee016872-6d5e-4bbe-97c7-c0058461a209
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、查询新建文件系统的UUID并在在/etc/fstab文件中添加新添加的文件系统的信息

[root@repo-server ~]# blkid
/dev/sda1: UUID="837d2be8-b585-46c3-b675-0c34e0879ebc" TYPE="ext4" PARTUUID="4dffc6b3-01"
/dev/sda2: UUID="21076945-5a9b-4714-8507-4975b87d6425" TYPE="xfs" PARTUUID="4dffc6b3-02"
/dev/sda3: UUID="e9cc64e2-d9ea-48f6-becf-bc1a13a5460f" TYPE="xfs" PARTUUID="4dffc6b3-03"
/dev/sda5: UUID="fb5080de-432e-4d57-86c0-c668e1cd5d5c" TYPE="swap" PARTUUID="4dffc6b3-05"
/dev/sdb1: LABEL="TEST" UUID="ee016872-6d5e-4bbe-97c7-c0058461a209" TYPE="ext4" PARTUUID="1e01229e-01"
/dev/sr0: UUID="2020-06-08-22-08-25-00" LABEL="CentOS-8-2-2004-x86_64-dvd" TYPE="iso9660" PTUUID="545ce9a4" PTTYPE="dos"
vim /etc/fstab
UUID=ee016872-6d5e-4bbe-97c7-c0058461a209 /test                   ext4    acl             0 0

5、创建挂载文件夹并使配置文件生效

[root@repo-server ~]# mkdir /test
[root@repo-server test]# mount -a
[root@repo-server test]# 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  100G  0 part /
|-sda3   8:3    0   50G  0 part /data
|-sda4   8:4    0    1K  0 part
`-sda5   8:5    0    4G  0 part [SWAP]
sdb      8:16   0   20G  0 disk
`-sdb1   8:17   0    2G  0 part /test
sdc      8:32   0   20G  0 disk
sdd      8:48   0   20G  0 disk
sde      8:64   0   20G  0 disk
sr0     11:0    1  7.7G  0 rom

四、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小为16MB,而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录

1、查看磁盘信息

[root@repo-server ~]# 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  100G  0 part /
|-sda3   8:3    0   50G  0 part /data
|-sda4   8:4    0    1K  0 part
`-sda5   8:5    0    4G  0 part [SWAP]
sdb      8:16   0   20G  0 disk
`-sdb1   8:17   0    2G  0 part /test
sdc      8:32   0   20G  0 disk
sdd      8:48   0   20G  0 disk
sde      8:64   0   20G  0 disk
sdf      8:80   0    2G  0 disk
sr0     11:0    1  7.7G  0 rom

2、以下将使用sdb的剩余空间以及整块sdf共同创建物理卷(pv)

[root@repo-server ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (4196352-41943039, default 4196352):
Last sector, +sectors or +size{K,M,G,T,P} (4196352-41943039, default 41943039):

Created a new partition 2 of type 'Linux' and of size 18 GiB.

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e

Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Syncing disks.
[root@repo-server ~]# fdisk /dev/sdf

Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0xa702bbbb.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4194303, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303):

Created a new partition 1 of type 'Linux' and of size 2 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

3、在sdb2和sdf1上分别创建物理卷(pv)

[root@repo-server ~]# pvcreate /dev/sdb2
  Physical volume "/dev/sdb2" successfully created.
[root@repo-server ~]# pvcreate /dev/sdf1
  Physical volume "/dev/sdf1" successfully created.
[root@repo-server ~]# pvs
  PV         VG Fmt  Attr PSize   PFree
  /dev/sdb2     lvm2 ---  <18.00g <18.00g
  /dev/sdf1     lvm2 ---   <2.00g  <2.00g

4、创建vg并将以上pv加入其中

[root@repo-server ~]# vgcreate -s 16M testvg /dev/sdb2 /dev/sdf1
  Volume group "testvg" successfully created
[root@repo-server ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  testvg   2   0   0 wz--n- <19.97g <19.97g

5、在tetsvg中创建大小为5G的逻辑建(lv)

[root@repo-server ~]# lvcreate -n testlv -L 5G testvg
  Logical volume "testlv" created.

6、创建文件系统

[root@repo-server ~]# mkfs.ext4 /dev/testvg/testlv
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 8f511715-a1b5-4a82-b298-5d3c4337031b
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912, 819200, 884736

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

7、查看新建lv的UUID

[root@repo-server ~]# blkid
/dev/sda2: UUID="21076945-5a9b-4714-8507-4975b87d6425" TYPE="xfs" PARTUUID="4dffc6b3-02"
/dev/sda1: UUID="837d2be8-b585-46c3-b675-0c34e0879ebc" TYPE="ext4" PARTUUID="4dffc6b3-01"
/dev/sda3: UUID="e9cc64e2-d9ea-48f6-becf-bc1a13a5460f" TYPE="xfs" PARTUUID="4dffc6b3-03"
/dev/sda5: UUID="fb5080de-432e-4d57-86c0-c668e1cd5d5c" TYPE="swap" PARTUUID="4dffc6b3-05"
/dev/sdb1: LABEL="TEST" UUID="ee016872-6d5e-4bbe-97c7-c0058461a209" TYPE="ext4" PARTUUID="1e01229e-01"
/dev/sdb2: UUID="mO7OGJ-nnt0-Qhq1-QW9B-E2sf-aeNS-V4NVa4" TYPE="LVM2_member" PARTUUID="1e01229e-02"
/dev/sdf1: UUID="qEDC3p-Ywb6-fsxn-M8Vb-w8fD-GIpX-S7XqwR" TYPE="LVM2_member" PARTUUID="a702bbbb-01"
/dev/sr0: UUID="2020-06-08-22-08-25-00" LABEL="CentOS-8-2-2004-x86_64-dvd" TYPE="iso9660" PTUUID="545ce9a4" PTTYPE="dos"
/dev/mapper/testvg-testlv: UUID="8f511715-a1b5-4a82-b298-5d3c4337031b" TYPE="ext4"

8、在/etc/fstab配置文件中添加以下内容

UUID=8f511715-a1b5-4a82-b298-5d3c4337031b /users                  ext4    defaults        0 0

9、创建users文件夹并使配置文件生效

[root@repo-server ~]# mkdir /users
[root@repo-server ~]# mount -a

10、查看结果

[root@repo-server ~]# 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  100G  0 part /
|-sda3              8:3    0   50G  0 part /data
|-sda4              8:4    0    1K  0 part
`-sda5              8:5    0    4G  0 part [SWAP]
sdb                 8:16   0   20G  0 disk
|-sdb1              8:17   0    2G  0 part /test
`-sdb2              8:18   0   18G  0 part
  `-testvg-testlv 253:0    0    5G  0 lvm  /users
sdc                 8:32   0   20G  0 disk
sdd                 8:48   0   20G  0 disk
sde                 8:64   0   20G  0 disk
sdf                 8:80   0    2G  0 disk
`-sdf1              8:81   0    2G  0 part
sr0                11:0    1  7.7G  0 rom
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值