一、自建yum仓库,分别为网络源和本地源
[root@centos7 ~]# cd /etc/yum.repos.d/ [root@centos7 yum.repos.d]# mkdir bak #建立备份文件夹 [root@centos7 yum.repos.d]# mv *.repo bak/ #将系统自带yum仓库备份 [root@centos7 yum.repos.d]# vim base.repo #新建仓库文件 [root@centos7 yum.repos.d]# cat base.repo [development] #本地光盘yum源 name=dvdbase repo baseurl=file:///mnt/cdrom/ enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7 [aliyun] #阿里云yum源 name=aliyun repo baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/ enabled=1 gpgchedk=1 gpgkey=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever [root@centos7 yum.repos.d]# mkdir /mnt/cdrom/ #创建光盘挂载点 [root@centos7 yum.repos.d]# mount /dev/sr0 /mnt/cdrom/ #挂载光盘 [root@centos7 yum.repos.d]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: aliyun development Cleaning up list of fastest mirrors Other repos take up 86 M of disk space (use --verbose for details) [root@centos7 yum.repos.d]# yum repolist #查看生效的yum源 Loaded plugins: fastestmirror, langpacks Determining fastest mirrors aliyun | 3.6 kB 00:00:00 development | 3.6 kB 00:00:00 (1/4): development/group_gz | 166 kB 00:00:00 (2/4): development/primary_db | 6.0 MB 00:00:00 (3/4): aliyun/7/x86_64/group_gz | 165 kB 00:00:00 (4/4): aliyun/7/x86_64/primary_db | 6.0 MB 00:00:03 repo id repo name status aliyun/7/x86_64 aliyun repo 10,097 development dvdbase repo 10,019 repolist: 20,116
二、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交
[root@centos7 ~]# ll httpd-2.4.39.tar #准备包
-rw-r--r-- 1 root root 41472000 Dec 3 17:57 httpd-2.4.39.tar
[root@centos7 ~]# tar -xvf httpd-2.4.39.tar #解包
[root@centos7 ~]# cd httpd-2.4.39/
[root@centos7 httpd-2.4.39]# ./configure --prefix=/usr/local/httpd #编译安装
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.39]# yum install -y apr-devel apr-util-devel gcc pcre-devel
[root@centos7 httpd-2.4.39]# ./configure --prefix=/usr/local/httpd
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: summary of build options:
Server Version: 2.4.39
Install prefix: /usr/local/httpd
C compiler: gcc -std=gnu99
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@centos7 httpd-2.4.39]# make
[root@centos7 httpd-2.4.39]# make install
[root@centos7 httpd-2.4.39]# /usr/local/httpd/bin/apachectl start #安装完成后启动服务
[root@centos7 httpd-2.4.39]# curl http://192.168.214.17 #测试访问是可以的
<html><body><h1>It works!</h1></body></html>
三、创建一个2G的文件系统,块大小为2068byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求些分区开机后自动挂载至/test目录,且默认有acl挂载选项
[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 0x001b493c.
Command (m for help): p
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x001b493c
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): 1
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): p
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x001b493c
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@centos7 ~]# lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 2G 0 part
#开始创建文件系统
[root@centos7 ~]# mke2fs -t ext4 -b 2048 -L TEST -m 1 /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, 1048576 blocks
10485 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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@centos7 ~]# blkid /dev/sdb1
/dev/sdb1: LABEL="TEST" UUID="c3f133c8-6e14-425d-8b24-f90ab30bb8d1" TYPE="ext4"
[root@centos7 ~]# mkdir /test #创建挂载目录
[root@centos7 ~]# mount -o acl /dev/sdb1 /test #临时挂载
[root@centos7 ~]# vim /etc/fstab #在fstab中添加以下内容,实现开机自动挂载
UUID=c3f133c8-6e14-425d-8b24-f90ab30bb8d1 /test ext4 defaults,acl 0 0
四、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小为16MB,而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
1、新增两块硬盘,大小分别为5G和15G,设备名分别为 /dev/sdb 和 /dev/sdc
[root@centos7 ~]# lsblk /dev/sdb /dev/sdc NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 5G 0 disk sdc 8:32 0 15G 0 disk
2、创建PV
[root@centos7 ~]# pvcreate /dev/sd{b,c}
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
[root@centos7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 --- 5.00g 5.00g
/dev/sdc lvm2 --- 15.00g 15.00g
3、创建VG,并设置PE大小为16MB
[root@centos7 ~]# vgcreate testvg /dev/sd{b,c} -s 16m
Volume group "testvg" successfully created
[root@centos7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
testvg 2 0 0 wz--n- <19.97g <19.97g
[root@centos7 ~]# vgdisplay
--- 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 #PE大小
Total PE 1278
Alloc PE / Size 0 / 0
Free PE / Size 1278 / <19.97 GiB
VG UUID fLJ0GI-hg5u-1QJ0-7ihI-ezKF-RyIP-TQUOgh
4、创建LV
[root@centos7 ~]# lvcreate -n testlv -L 5G testvg Logical volume "testlv" created. [root@centos7 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert testlv testvg -wi-a----- 5.00g [root@centos7 ~]# lvdisplay --- Logical volume --- LV Path /dev/testvg/testlv LV Name testlv VG Name testvg LV UUID DUZV6O-Guj4-C3IR-NEwI-Bj4d-F9Xj-W2jqal LV Write Access read/write LV Creation host, time centos7.localdomain, 2019-12-03 20:13:45 +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 8192 Block device 253:0
5、创建文件系统,并挂载
[root@centos7 ~]# mkfs.xfs /dev/testvg/testlv
meta-data=/dev/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 ~]# blkid
/dev/sda1: UUID="06fb735b-a954-479b-a7e2-5615d5ac1429" TYPE="xfs"
/dev/sda2: UUID="39a8e496-0019-4c2e-9cfe-2bb657078465" TYPE="xfs"
/dev/sda3: UUID="bf1909f2-e77e-4fe2-b8a8-c48bfb2dfeac" TYPE="xfs"
/dev/sda5: UUID="18046ac9-2bc9-4b83-b179-1453c4c40c51" TYPE="swap"
/dev/sdb: UUID="iJM4vP-g6pN-W0N5-J7k8-5u9w-Ywz2-Fdp1AR" TYPE="LVM2_member"
/dev/sdc: UUID="ZRpN8E-SD9n-p1sN-i623-vsAO-iqSL-6WYo7D" TYPE="LVM2_member"
/dev/mapper/testvg-testlv: UUID="7a0d0bc4-938c-4bbd-843c-0b248aec174b" TYPE="xfs"
[root@centos7 ~]# mkdir /users #创建挂载点
[root@centos7 ~]# mount /dev/mapper/testvg-testlv /users #临时挂载
[root@centos7 ~]# cd /users/
#如要实现自动化永久挂载,可以/etc/fstab 文件后添加以下内容
[root@centos7 users]# vim /etc/fstab
UUID=iJM4vP-g6pN-W0N5-J7k8-5u9w-Ywz2-Fdp1AR /users xfs defaults 0 0