第六周作业
1、自建yum仓库,分别为网络源和本地源
配置本地光盘作为yum源仓库:
#原仓库文件做备份
[root@centos7 17:40:00 ~]#cd /etc/yum.repos.d/
[root@centos7 17:40:08 yum.repos.d]#ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@centos7 17:40:10 yum.repos.d]#mkdir backup
[root@centos7 17:40:24 yum.repos.d]#mv *.repo backup/
[root@centos7 17:40:40 yum.repos.d]#ls
backup
#确认光盘已经挂载在/misc/cd目录下
[root@centos7 17:40:44 yum.repos.d]#df /dev/sr0
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sr0 4480476 4480476 0 100% /misc/cd
#新建本地磁盘yum源,编辑yum源文件
[root@centos7 17:43:36 yum.repos.d]#cat >> base.repo <<EOF
> [base]
> name=CentOS7
> baseurl=file:///misc/cd
> enabled=1
> gpgcheck=0 -------- 指定了不检查
> EOF
[root@centos7 17:46:43 yum.repos.d]#
#用yum repolist查看设置的仓库信息
[root@centos7 17:48:30 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
!base CentOS7 10,070
repolist: 10,070
#能看到仓库文件中多出base.repo
[root@centos7 17:48:34 yum.repos.d]#ls
backup base.repo
配置阿里云EPEL网络仓库作为yum源仓库:
#找到阿里云epel网络仓库链接
http://mirrors.aliyun.com/epel/7/x86_64/
[root@centos7 17:56:26 yum.repos.d]#vim epel.repo
[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/$basearch/ -------- 路径用变量替换
enabled=1
gpgcheck=0
[root@centos7 18:03:48 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
Not using downloaded base/repomd.xml because it is older than what we have:
Current : Wed Apr 22 07:37:50 2020
Downloaded: Mon Nov 26 07:53:36 2018
epel | 4.7 kB 00:00:00
(1/3): epel/7/x86_64/group_gz | 95 kB 00:00:00
(2/3): epel/7/x86_64/updateinfo | 1.0 MB 00:00:01
(3/3): epel/7/x86_64/primary_db | 6.9 MB 00:00:03
repo id repo name status
base CentOS7 10,070
epel/7/x86_64 EPEL 13,470
repolist: 23,540
#能看到仓库文件中多出epel.repo
[root@centos7 18:03:56 yum.repos.d]#ls
backup base.repo epel.repo
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交
#从阿里云下载包
[root@centos7 12:40:14 data]#wget http://mirrors.aliyun.com/apache/httpd/httpd-2.4.46.tar.bz2
#解包
[root@centos7 12:41:57 data]#tar xvf httpd-2.4.46.tar.bz2
#进入目录下
[root@centos7 12:42:23 data]#cd httpd-2.4.46/
#指定安装路径、特性等
[root@centos7 12:43:37 httpd-2.4.46]#./configure \
> --prefix=/apps/httpd24\
> sysconfdir=/etc/httpd24\
> --enable-ssl\
> --enable-so
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.
#根据error安装其他相关软件
[root@centos7 12:48:22 httpd-2.4.46]#yum install apr-devel -y
[root@centos7 12:48:51 httpd-2.4.46]#yum install apr-util-devel -y
[root@centos7 12:51:15 httpd-2.4.46]#yum install pcre-devel -y
[root@centos7 12:52:32 httpd-2.4.46]#yum install openssl-devel -y
[root@centos7 12:51:40 httpd-2.4.46]#./configure \--prefix=/apps/httpd24 \sysconfdir=/etc/httpd24 \--enable-ssl \--enable-so
#再次执行成功后开始make
[root@centos7 13:06:14 httpd-2.4.46]#make
[root@centos7 13:08:39 httpd-2.4.46]#make install
#可在安装路径下看到httpd24
[root@centos7 13:14:08 ~]#ls /apps/
httpd24
#为方便执行将httpd的bin路径加到$PATH中(也可不加,后用路径执行)
#打开apache服务
[root@centos7 13:14:02 ~]#apachectl start -------- 启动不会自动打开服务,需将/apps/httpd24/bin/apachectl start写入/etc/rc.d/rc.local中
#页面编辑在index.html中
[root@centos7 13:33:13 httpd24]#cd /apps/httpd24/htdocs/
[root@centos7 13:33:19 htdocs]#ls
index.html
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1
mkdir /test
mount -t ext4 -o acl /dev/sdb1 /test
#开机后自动挂载,将配置写入/etc/fstab中
[root@centos7 14:37:05 data]#vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Aug 10 23:28:58 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=4b2d084d-e6a8-4cf7-ade0-b16b093c40a0 / xfs defaults 0 0
UUID=c674a7cd-cc0a-4544-8e01-4ef554338170 /boot xfs defaults 0 0
UUID=9e31b14f-1bf2-4358-9545-da2ee08bc762 /data xfs defaults 0 0
UUID=b4f08dbe-dd1a-4365-be0a-3dc7fd8ce18b swap swap defaults 0 0
UUID=b479a7ea-98fd-42ce-a921-65c77ffb1f34 /test ext4 acl 0 0
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小为16MB,而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
- 用10G的/dev/sdb3和10G的/dev/sdc1组成物理卷组,先创建两个10G分区并将分区格式改为8e(LVM)
#/dev/sdc1的操作也参考如下
[root@centos7 14:44:46 data]#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): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (12584960-41943039, default 12584960):
Using default value 12584960
Last sector, +sectors or +size{
K,M,G} (12584960-41943039, default 41943039): +10G
Partition 3 of type Linux and of size 10 GiB is set
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
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!
- 创建物理卷
查看 pv
详细查看 pvdisplay
-
创建物理卷组,指定PE大小为16M,VG名为testvg
查看vgs
详细查看vgdisplay
-
创建逻辑卷,指定逻辑卷大小为5G,名为testlv
查看lvs
详细查看lvdisplay
-
创建一个文件系统
-
永久挂载到/users目录
#创建目录
mkdir /users
写入/etc/fstab