马哥教育N48-第六周作业

1、自建yum仓库,分别为网络源和本地源
1)、备份原先默认的yum源,其在文件夹/etc/yum.repos.d/中
[root@centos7 yum.repos.d]#cd /etc/yum.repos.d
[root@centos7 yum.repos.d]#mkdir backup
[root@centos7 yum.repos.d]#mv ./*.repo backup/
2)、挂载光盘
在这里插入图片描述
3)、配置光盘作为本地yum源
在/etc/yum.repos.d/路径下建立文件base.repo写入以下内容:
[base]
name=cdrom base
baseurl=file:///misc/cd/
gpgcheck=0
gpgkey=file:///misc/cd/RPM-GPG-KEY-CentOS-7

4.配置阿里云epel作为网络源,在上述文件中再添加以下内容:
[epel]
name=aliyun epel
baseurl=https://mirrors.aliyun.com/epel/releasever/basearch/
gpgcheck=0
enabled=1
在这里插入图片描述
*2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
1) 解压

[root@centos7 bin]# rpm -qi httpd

package httpd is not installed

[root@centos7 src]# tar -xf httpd-2.4.41.tar.gz

2) Configure

[root@centos7 src]# cd httpd-2.4.41/

[root@centos7 httpd-2.4.41]# ./configure

checking for chosen layout… Apache

checking for working mkdir -p… yes

checking for grep that handles long lines and -e… /usr/bin/grep

checking for egrep… /usr/bin/grep -E

checking build system type… x86_64-pc-linux-gnu

checking host system type… x86_64-pc-linux-gnu

checking target system type… x86_64-pc-linux-gnu

configure:

configure: Configuring Apache Portable Runtime library…

configure:

checking for APR… no

configure: error: APR not found. Please read the documentation.

安装缺少的依赖包:

[root@centos7 httpd-2.4.41]# yum install apr* pcre* -y

[root@centos7 src]# cd httpd-2.4.41/

3) 编译

[root@centos7 httpd-2.4.41]# make

4)安装

[root@centos7 httpd-2.4.41]# make install

5) 启动并验证

[root@centos7 bin]# pwd

/usr/local/apache2/bin

[root@centos7 bin]# ./apachectl -k start

[root@centos7 bin]# ps aux |grep apache

root 14751 0.0 0.1 103732 2728 ? Ss 18:34 0:00 /usr/local/apache2/bin/httpd -k start

daemon 14754 0.0 0.1 392644 2416 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd -k start

daemon 14755 0.0 0.1 392644 2424 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd -k start

daemon 14756 0.0 0.1 458180 2424 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd -k start

[root@centos7 bin]# curl localhost

It works!

[root@centos7 bin]#*

3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
1)为虚拟机添加一块硬盘并让系统马上识别硬盘
[root@centos7 ~]# echo “- - -” > /sys/class/scsi_host/host0/scan

[root@centos7 ~]#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 8G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 10.3G 0 rom
sdb为新添加的硬盘

[root@centos7 ~]#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 0xc57d7a43.

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc57d7a43

Device Boot Start End Blocks Id System

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G
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.
[root@centos7 ~]#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 8G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
sr0 11:0 1 10.3G 0 rom

将2G空间的分区格式化为块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST
mkfs.ext4 -t ext4 -b 2048 -m 1 -L TEST /dev/sdb1

[root@centos7 ~]# blkid /dev/sdb1
/dev/sdb1: LABEL=“TEST” UUID=“a5d163b7-5a9a-419d-9032-535b45695ac5” TYPE=“ext4”

将配置写入/etc/fstab

[root@centos7 ~]#cat /etc/fstab

/etc/fstab

Created by anaconda on Tue Sep 1 04:27:22 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

UUID=8dc6f93a-f3dd-4ccc-ba36-ec85b95fb63e / xfs defaults 0 0
UUID=19a9983b-fb6b-42d8-a8d7-cfb955adbb85 /boot xfs defaults 0 0
UUID=640c518e-76df-4468-ba12-2ec5c548d328 /data xfs defaults 0 0
UUID=b7038e3a-ec1a-4a20-978d-6fc49339effd swap swap defaults 0 0
UUID=a5d163b7-5a9a-419d-9032-535b45695ac5 /test ext4 acl 0 0

4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
[root@centos7 ~]# 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.

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0xfbaa7750

Device Boot Start End Blocks Id System

/dev/sdb1 2048 4196351 2097152 83 Linux

Command (m for help): n

Partition type:

p primary (1 primary, 0 extended, 3 free)

e extended

Select (default p): p

Partition number (2-4, default 2):

First sector (4196352-104857599, default 4196352):

Using default value 4196352

Last sector, +sectors or +size{K,M,G} (4196352-104857599, default 104857599): +10G

Partition 2 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0xfbaa7750

Device Boot Start End Blocks Id System

/dev/sdb1 2048 4196351 2097152 83 Linux

/dev/sdb2 4196352 25167871 10485760 83 Linux

Command (m for help): n

Partition type:

p primary (2 primary, 0 extended, 2 free)

e extended

Select (default p): p

Partition number (3,4, default 3):

First sector (25167872-104857599, default 25167872):

Using default value 25167872

Last sector, +sectors or +size{K,M,G} (25167872-104857599, default 104857599): +10G

Partition 3 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0xfbaa7750

Device Boot Start End Blocks Id System

/dev/sdb1 2048 4196351 2097152 83 Linux

/dev/sdb2 4196352 25167871 10485760 83 Linux

/dev/sdb3 25167872 46139391 10485760 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@centos7 ~]#

2)创建pv

[root@centos7 ~]# pvcreate /dev/sdb2 /dev/sdb3

Physical volume “/dev/sdb2” successfully created.

Physical volume “/dev/sdb3” successfully created.

[root@centos7 ~]#

3)创建逻辑卷组

[root@centos7 ~]# vgcreate -s 16MB testvg /dev/sdb2 /dev/sdb3

Volume group “testvg” successfully created

[root@centos7 ~]# vgdisplay testvg

— Volume group —

VG Name testvg

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 <19.97 GiB

PE Size 16.00 MiB

Total PE 1278

Alloc PE / Size 0 / 0

Free PE / Size 1278 / <19.97 GiB

VG UUID 0fGU0o-XJGc-TKQD-2G2G-bL3I-bO7I-3sV4Y0

[root@centos7 ~]#

4)创建大小为5G的逻辑卷testlv;挂载至/users目录

[root@centos7 ~]# lvcreate -L 5G -n testlv testvg

Logical volume “testlv” created.

[root@centos7 ~]# lvdisplay testvg

— Logical volume —

LV Path /dev/testvg/testlv

LV Name testlv

VG Name testvg

LV UUID Onl32p-WxHz-TcX3-EBzf-plNB-I01E-sPCuev

LV Write Access read/write

LV Creation host, time centos7.6, 2020-03-08 21:10:12 +0800

LV Status available

open 0

LV Size 5.00 GiB

Current LE 320

Segments 1

Allocation inherit

Read ahead sectors auto

  • currently set to 256

Block device 253:2

[root@centos7 ~]# mkdir /users

[root@centos7 ~]# mkfs.xfs /dev/mapper/testvg-testlv

meta-data=/dev/mapper/testvg-testlv isize=512 agcount=4, agsize=327680 blks

     =                       sectsz=512   attr=2, projid32bit=1

     =                       crc=1        finobt=0, sparse=0

data = bsize=4096 blocks=1310720, 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@centos7 ~]# mount /dev/mapper/testvg-testlv /users

[root@centos7 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 60G 5.4G 55G 9% /

devtmpfs 983M 0 983M 0% /dev

tmpfs 1000M 0 1000M 0% /dev/shm

tmpfs 1000M 74M 926M 8% /run

tmpfs 1000M 0 1000M 0% /sys/fs/cgroup

/dev/sda1 1014M 166M 849M 17% /boot

tmpfs 200M 0 200M 0% /run/user/0

/dev/sr0 11G 11G 0 100% /mnt

/dev/mapper/testvg-testlv 5.0G 33M 5.0G 1% /users

[root@centos7 ~]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值