1、自建yum倉(cāng)庫(kù),分別為網(wǎng)絡(luò)源和本地源
①光盤(pán)搭建本地yum倉(cāng)庫(kù)
掛載光盤(pán)(前提示虛擬機(jī)上已加載光盤(pán)鏡像)
[root@centos7 ~]#mount /dev/sr0 /mnt
[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 4G 0 part [SWAP]
sr0 11:0 1 10G 0 rom /mnt
在此目錄下建立yum源文件
[root@centos7 ~]#cd /etc/yum.repos.d/
[root@centos7 yum.repos.d]#vim base.repo
[base]
name=cdrom base
baseurl=file:///mnt
gpgcheck=0
gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-7
enabled=1
②利用阿里云搭建網(wǎng)絡(luò)源
在上述文件中追加配置,如下
[epel]
name=aliyun epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
gpgcheck=0
enabled=1
更新yum源配置
[root@centos7 yum.repos.d]#yum clean all
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Cleaning repos: base epel extras updates
Cleaning up list of fastest mirrors
至此yum源就可以被正常使用
2、編譯安裝http2.4,實(shí)現(xiàn)可以正常訪問(wèn),并將編譯步驟和結(jié)果提交
①將下載好的文件復(fù)制到系統(tǒng)中
②解壓包并查看
[root@centos7 data]#tar xvf httpd-2.4.25.tar.bz2
[root@centos7 data]#ls
httpd-2.4.25 httpd-2.4.25.tar.bz2
[root@centos7 data]#cd httpd-2.4.25/
[root@centos7 httpd-2.4.25]#ls
ABOUT_APACHE ap.d CHANGES docs httpd.spec libhttpd.dep Makefile.win
acinclude.m4 build CMakeLists.txt emacs-style include libhttpd.dsp modules
Apache-apr2.dsw BuildAll.dsp config.layout httpd.dep INSTALL libhttpd.mak
Apache.dsw BuildBin.dsp configure httpd.dsp InstallBin.dsp LICENSE
apache_probes.d buildconf configure.in httpd.mak LAYOUT Makefile.in
③安裝
[root@centos7 httpd-2.4.25]#./configure --prefix=/apps/httpd66 --sysconfdir=/etc/httpd --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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
但有錯(cuò)誤,APR未被找到,yum補(bǔ)安裝
[root@centos7 httpd-2.4.25]#yum install apr-devel
[root@centos7 httpd-2.4.25]#yum install apr-util-devel
繼續(xù)運(yùn)行,提示錯(cuò)誤
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
再繼續(xù)安裝pcre
[root@centos7 httpd-2.4.25]#yum install pcre-devel
再運(yùn)行,提示錯(cuò)誤
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
再繼續(xù)安裝mod_ssl
[root@centos7 httpd-2.4.25]#yum install mod_ssl
提示
configure: WARNING: OpenSSL version is too old
再將新的openssl安裝
[root@centos7 httpd-2.4.25]#yum install openssl-devel
再次運(yùn)行,安裝成功
configure: summary of build options:
Server Version: 2.4.25
Install prefix: /apps/httpd66
C compiler: gcc -std=gnu99
CFLAGS: -pthread
LDFLAGS:
LIBS:
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
C preprocessor: gcc -E
④make
[root@centos7 httpd-2.4.25]#make
⑤make install
[root@centos7 httpd-2.4.25]#make install
⑥添加路徑至配置文件
[root@centos7 httpd-2.4.25]#cd /apps/httpd66/
[root@centos7 httpd66]#ls
bin build cgi-bin error htdocs icons include logs man manual modules
[root@centos7 httpd66]#vim /etc/profile.d/env.sh
PATH="/apps/httpd66/bin:$PATH" #添加此行
⑦生效此配置文件并查看變量
[root@centos7 httpd66]#. /etc/profile.d/env.sh
[root@centos7 httpd66]#echo $PATH
/apps/httpd66/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
⑧執(zhí)行程序
[root@centos7 ~]#apachectl start
⑨查看執(zhí)行效果

3、創(chuàng)建一個(gè)2G的文件系統(tǒng),塊大小為2048byte,預(yù)留1%可用空間,文件系統(tǒng) ext4,卷標(biāo)為T(mén)EST,要求此分區(qū)開(kāi)機(jī)后自動(dòng)掛載至/test目錄,且默認(rèn)有acl掛載選項(xiàng)
以我的sdb硬盤(pán)為例說(shuō)明
①創(chuàng)建2G大小的磁盤(pán)分區(qū)
[root@centos7 ~]#fdisk /dev/sdb
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
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
②創(chuàng)建好后查看
[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 4G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
sr0 11:0 1 10G 0 rom
③創(chuàng)建文件系統(tǒng)
[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
④創(chuàng)建掛載目錄并掛載
[root@centos7 ~]#mkdir /test
[root@centos7 ~]#vim /etc/fstab
.....
UUID=d96e21bf-6785-463c-9a96-1ccb84593004 /test ext4 acl 0 0 #UUID通過(guò)blkid命令查看得知
⑤重啟動(dòng)驗(yàn)證
[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 /
.......
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part /test
顯示掛載已成功
4、創(chuàng)建一個(gè)至少有兩個(gè)PV組成的大小為20G的名為testvg的VG;要求PE大小 為16MB, 而后在卷組中創(chuàng)建大小為5G的邏輯卷testlv;掛載至/users目錄
①創(chuàng)建pv并顯示信息
[root@centos7 ~]#pvcreate /dev/sdb1 /dev/sdb2
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdb2" successfully created.
[root@centos7 ~]#pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 --- 2.00g 2.00g
/dev/sdb2 lvm2 --- <18.00g <18.00g
②創(chuàng)建vg卷組并顯示信息
[root@centos7 ~]#vgcreate -s 16M testvg /dev/sdb1 /dev/sdb2
Volume group "testvg" successfully created
[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大小為16M
Total PE 1278
Alloc PE / Size 0 / 0
Free PE / Size 1278 / <19.97 GiB
VG UUID mckvB6-pIEX-8uZS-HZWR-knkF-2ira-yrV4ac
③創(chuàng)建邏輯卷并顯示信息
[root@centos7 ~]#lvcreate -n testlv -L 5G testvg
Logical volume "testlv" created.
[root@centos7 ~]#lvdisplay
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID 9chqy8-Ysvg-zJoH-l43G-2ZcH-nq4Z-AA0VoL
LV Write Access read/write
LV Creation host, time centos7.localdomain, 2020-03-05 21:40:04 +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@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
.......
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 2G 0 part
└─sdb2 8:18 0 18G 0 part
└─testvg-testlv 253:0 0 5G 0 lvm
sr0 11:0 1 10G 0 rom
④創(chuàng)建文件系統(tǒng)并掛載
[root@centos7 ~]#mkdir users
[root@centos7 ~]#mkfs.ext4 /dev/testvg/testlv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@centos7 ~]#mount /dev/testvg/testlv users/
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
.......
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 2G 0 part
└─sdb2 8:18 0 18G 0 part
└─testvg-testlv 253:0 0 5G 0 lvm /root/users #掛載成功
sr0 11:0 1 10G 0 rom