1、自建yum仓库,分别为网络源和本地源
yum仓库配置文件保存路径:
/etc/yum.conf #为所有仓库提供公共配置
/etc/yum.repos.d/*.repo: #为每个仓库的提供配置文件
自建yum仓库文件内容
[base] yum仓库名称,唯一性
name=CentOS-$releasever - Base 仓库描述
baseurl=仓库指向路径
https://
file://
ftp://
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-对应版本 gpg校验码
gpgcheck=1 使能gpg校验
enabled=1 使能仓库
相关变量
yum的repo配置文件中可用的变量:
$releasever: 当前OS的发行版的主版本号,如:8,7,6
$arch: CPU架构,如:aarch64, i586, i686,x86_64等
$basearch:系统基础平台;i386, x86_64
$contentdir:表示目录,比如:centos-8,centos-7
$YUM0-$YUM9:自定义变量
[root@centos8 scripts ]#cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
file:///misc/cd/BaseOS/
##基于已安装autofs包,如未安装该文件包,可手动挂载光盘,并写入/etc/fstab
##镜像地址止于repodata所在目录
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
enabled=1
[AppStream]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
file:///misc/cd/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
enabled=1
[extra]
name=CentOS-$releasever - extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
enabled=1
[epel]
name=CentOS-$releasever - epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
enabled=1
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
1、环境准备
[root@Centos8 src]# dnf install gcc make apr-devel apr-util-devel pcre-devel -y
2、下载并解压压缩包
[root@Centos8 src]# wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2 -O /usr/local/src/httpd-2.4.46.tar.bz2
[root@Centos8 src]# file httpd-2.4.46.tar.bz2
[root@Centos8 src]# tar xvf httpd-2.4.46.tar.bz2
3、配置
[root@Centos8 src]# cd httpd-2.4.46
[root@Centos8 httpd-2.4.46]# more README
[root@Centos8 httpd-2.4.46]# more INSTALL
[root@Centos8 httpd-2.4.46]# ./configure --help
##可通过查看相关文件来帮助完成相关配置,根据时隙需求选择需要的参数进行配置
[root@Centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
在编译中提供OPENSSL版本太低,yum仓库查看版本与系统的一致,只能从官网下载最新的压缩包
[root@Centos8 src]# yum provides openssl
Last metadata expiration check: 0:44:37 ago on Mon 30 Nov 2020 07:48:32 PM CST.
openssl-1:1.1.1c-15.el8.x86_64 : Utilities from the general purpose cryptography library with TLS implementation
Repo : @System
Matched from:
Provide : openssl = 1:1.1.1c-15.el8
openssl-1:1.1.1c-15.el8.x86_64 : Utilities from the general purpose cryptography library with TLS implementation
Repo : base
Matched from:
Provide : openssl = 1:1.1.1c-15.el8
[root@Centos8 src]# wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz
[root@Centos8 src]# tar xvf openssl-1.1.1h.tar.gz
[root@Centos8 src]# cd openssl-1.1.1h
[root@Centos8 openssl-1.1.1h]# ./config
#提示需要perl 5
[root@Centos8 openssl-1.1.1h]# cd ..
[root@Centos8 src]# wget https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz
[root@Centos8 src]# cd perl-5.28.0
[root@Centos8 perl-5.28.0]# ./Configure -des -Dprefix=$HOME/localperl;make ; make install
[root@Centos8 perl-5.28.0]# cd ..
[root@Centos8 src]# cd openssl-1.1.1h
[root@Centos8 openssl-1.1.1h]# ./config ;make ;make install
#这回没报错
[root@Centos8 src]# cd httpd-2.4.46
[root@Centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
#配置总算完成了
4、编译
[root@Centos8 httpd-2.4.46]# make ;make install
#make 后面能 -j CPU核实增加编译速度
#编译报错,缺少/usr/lib/rpm/redhat/redhat-hardened-ld这玩意儿,查了一下,这个由dnf -y install redhat-rpm-config包提供,梭哈。再来一次,这回终于完成了
[root@Centos8 httpd-2.4.46]# make ;make install
5、配置环境
#这样启动不用打绝对路径了,环境生效一下
[root@Centos8 httpd-2.4.46]# echo "PATH=/apps/httpd24/bin:$PATH " > /etc/profile.d/httpd.sh
[root@Centos8 httpd-2.4.46]# . /etc/profile.d/httpd24.sh
6、指定apache用户运行
#系统用户,uid:48,/sbin/nologin
[root@Centos8 httpd-2.4.46]# useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
7、运行
[root@Centos8 httpd-2.4.46]# apachectl
[root@Centos8 httpd-2.4.46]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
使用磁盘空间一般分三步:
1、分区:(也可不分区,直接磁盘格式化)fdisk
[root@Centos8 ~]# fdisk /dev/sdb
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.
非交互式
[root@Centos8 ~]#echo -e "n\np\n\n+2G\nw\n" | fdisk /dev/sdb
[root@Centos8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
sdc 8:32 0 10G 0 disk
sr0 11:0 1 7.7G 0 rom
[root@Centos8 ~]# cat /proc/partitions
major minor #blocks name
8 0 20971520 sda
8 1 20970496 sda1
8 16 20971520 sdb
8 17 2097152 sdb1
8 32 10485760 sdc
11 0 8038400 sr0
[root@Centos8 ~]# ll /dev/sd*
brw-rw----. 1 root disk 8, 0 Dec 3 09:40 /dev/sda
brw-rw----. 1 root disk 8, 1 Dec 3 09:40 /dev/sda1
brw-rw----. 1 root disk 8, 16 Dec 3 09:54 /dev/sdb
brw-rw----. 1 root disk 8, 17 Dec 3 09:54 /dev/sdb1
brw-rw----. 1 root disk 8, 32 Dec 3 09:40 /dev/sdc
2、创建文件系统(格式化)mkfs
[root@Centos8 ~]# mkfs.ext4 -b 2048 -L TEST -m 1 /dev/sdb1
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 1048576 2k blocks and 131072 inodes
Filesystem UUID: 188d2c38-8e7b-451f-9bd0-c797e112a923
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
[root@Centos8 ~]# blkid
/dev/sda1: UUID="2eedb28f-4457-4ba2-9aaa-2c850f4092e8" TYPE="xfs" PARTUUID="b9ce049d-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/sdb1: LABEL="TEST" UUID="188d2c38-8e7b-451f-9bd0-c797e112a923" TYPE="ext4" PARTUUID="6181012d-01"
[root@Centos8 ~]# tune2fs /dev/sdb1
tune2fs 1.45.4 (23-Sep-2019)
Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-f] [-g group]
[-i interval[d|m|w]] [-j] [-J journal_options] [-l]
[-m reserved_blocks_percent] [-o [^]mount_options[,...]]
[-r reserved_blocks_count] [-u user] [-C mount_count]
[-L volume_label] [-M last_mounted_dir]
[-O [^]feature[,...]] [-Q quota_options]
[-E extended-option[,...]] [-T last_check_time] [-U UUID]
[-I new_inode_size] [-z undo_file] device
[root@Centos8 ~]# tune2fs -l /dev/sdb1
tune2fs 1.45.4 (23-Sep-2019)
Filesystem volume name: TEST ###卷名 可用tune2fs -L NAME DEVICE 修改
Last mounted on: <not available>
Filesystem UUID: 188d2c38-8e7b-451f-9bd0-c797e112a923
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl ###有ACL功能,可用tune2fs -o [^]acl调整
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131072
Block count: 1048576
Reserved block count: 10485 ###预留可用空间,可用tune2fs -m # DEVICE修改
Free blocks: 1011035
Free inodes: 131061
First block: 0
Block size: 2048 ###默认块大小
Fragment size: 2048
Group descriptor size: 64
Reserved GDT blocks: 512
Blocks per group: 16384
Fragments per group: 16384
Inodes per group: 2048
Inode blocks per group: 256
Flex block group size: 16
Filesystem created: Thu Dec 3 10:20:53 2020
Last mount time: n/a
Last write time: Thu Dec 3 10:20:53 2020
Mount count: 0
Maximum mount count: -1
Last checked: Thu Dec 3 10:20:53 2020
Check interval: 0 (<none>)
Lifetime writes: 1058 kB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 32
Desired extra isize: 32
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 5792ebaa-5646-4d2e-b966-ec3617ffe6df
Journal backup: inode blocks
Checksum type: crc32c
Checksum: 0xc9223a4b
[root@Centos8 ~]# mount
/dev/sdb1 on /test type ext4 (rw,relatime,seclabel)
3、挂载mount
[root@Centos8 ~]# mkdir /test
[root@Centos8 ~]# mount /dev/sdb1 /test/
[root@Centos8 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
devtmpfs devtmpfs 470956 0 470956 0% /dev
tmpfs tmpfs 487436 0 487436 0% /dev/shm
tmpfs tmpfs 487436 6768 480668 2% /run
tmpfs tmpfs 487436 0 487436 0% /sys/fs/cgroup
/dev/sda1 xfs 20960256 2438124 18522132 12% /
tmpfs tmpfs 97484 0 97484 0% /run/user/0
/dev/sdb1 ext4 2031306 9236 1992908 1% /test
[root@Centos8 ~]# vim /etc/fstab
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
创建逻辑卷分三步:
创建物理卷PV pvcreate pvdisplay pvremove /dev/DEVICE
创建卷组VG vgcreate vgdisplay vgremove
创建逻辑卷LV
步骤一:创建物理卷
[root@Centos8 ~]# pvdisplay
-bash: pvdisplay: command not found
[root@Centos8 ~]# dnf provides pvdisplay
Last metadata expiration check: 1:22:02 ago on Thu 03 Dec 2020 09:50:43 AM CST.
lvm2-8:2.03.08-3.el8.x86_64 : Userland logical volume management tools
Repo : base
Matched from:
Filename : /usr/sbin/pvdisplay
[root@Centos8 ~]# dnf -y install lvm2
[root@Centos8 ~]# pvcreate /dev/{sdc,sdd}
Physical volume "/dev/sdc" successfully created.
Physical volume "/dev/sdd" successfully created.
[root@Centos8 ~]# pvdisplay
"/dev/sdc" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zVuPoV-BPHr-dpcJ-hg4Z-glYI-0W1i-0CCa07
"/dev/sdd" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdd
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID a7b6bC-ksAa-RjKT-Ikng-uaLa-fGye-gDCIyw
[root@Centos8 ~]# blkid
/dev/sda1: UUID="2eedb28f-4457-4ba2-9aaa-2c850f4092e8" TYPE="xfs" PARTUUID="b9ce049d-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/sdb1: LABEL="4096" UUID="188d2c38-8e7b-451f-9bd0-c797e112a923" TYPE="ext4" PARTUUID="6181012d-01"
/dev/sdc: UUID="zVuPoV-BPHr-dpcJ-hg4Z-glYI-0W1i-0CCa07" TYPE="LVM2_member"
/dev/sdd: UUID="a7b6bC-ksAa-RjKT-Ikng-uaLa-fGye-gDCIyw" TYPE="LVM2_member"
[root@Centos8 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdc lvm2 --- 10.00g 10.00g
/dev/sdd lvm2 --- 20.00g 20.00g
[root@Centos8 ~]# pvscan
PV /dev/sdc lvm2 [10.00 GiB]
PV /dev/sdd lvm2 [20.00 GiB]
Total: 2 [30.00 GiB] / in use: 0 [0 ] / in no VG: 2 [30.00 GiB]
步骤二:
[root@Centos8 ~]# vgcreate -s 16M testvg /dev/sdc /dev/sdd
Volume group "testvg" successfully created
[root@Centos8 ~]# vgscan
Found volume group "testvg" using metadata type lvm2
[root@Centos8 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
testvg 2 0 0 wz--n- <29.97g <29.97g
[root@Centos8 ~]# 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 <29.97 GiB
PE Size 16.00 MiB
Total PE 1918
Alloc PE / Size 0 / 0
Free PE / Size 1918 / <29.97 GiB
VG UUID 5qfQ1W-HJ2v-MSlW-eKcd-SfI9-utfS-eqd2ER
步骤三:
[root@Centos8 ~]# lvcreate -L 5G -n testlv testvg
Logical volume "testlv" created.
[root@Centos8 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID cwLGhM-l4H1-VYgr-M2Kw-iBA1-uWiT-yMB70a
LV Write Access read/write
LV Creation host, time Centos8.SourceCode, 2020-12-03 11:31:35 +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
步骤四:
[root@Centos8 ~]# 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=1, sparse=1, rmapbt=0
= reflink=1
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@Centos8 ~]# mkdir /users
[root@Centos8 ~]# mount /dev/testvg/testlv /users/
[root@Centos8 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 460M 0 460M 0% /dev
tmpfs 477M 0 477M 0% /dev/shm
tmpfs 477M 6.7M 470M 2% /run
tmpfs 477M 0 477M 0% /sys/fs/cgroup
/dev/sda1 20G 2.4G 18G 12% /
tmpfs 96M 0 96M 0% /run/user/0
/dev/sdb1 2.0G 9.1M 1.9G 1% /test
/dev/mapper/testvg-testlv 5.0G 68M 5.0G 2% /users
[root@Centos8 ~]# blkid
/dev/sda1: UUID="2eedb28f-4457-4ba2-9aaa-2c850f4092e8" TYPE="xfs" PARTUUID="b9ce049d-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/sdb1: LABEL="4096" UUID="188d2c38-8e7b-451f-9bd0-c797e112a923" TYPE="ext4" PARTUUID="6181012d-01"
/dev/sdc: UUID="zVuPoV-BPHr-dpcJ-hg4Z-glYI-0W1i-0CCa07" TYPE="LVM2_member"
/dev/sdd: UUID="a7b6bC-ksAa-RjKT-Ikng-uaLa-fGye-gDCIyw" TYPE="LVM2_member"
/dev/mapper/testvg-testlv: UUID="0a7677c4-8d51-4204-ba3d-fb57743f9287" TYPE="xfs"