1、自建yum仓库,分别为网络源和本地源

(1)启动服务

查看是否安装了autofs包

[22:09:27 root@CentOS7 /run/media/centos7.6/CentOS 7 x86_64]#rpm -q autofs
autofs-5.0.7-99.el7.x86_64

包中有一个autofs.servic服务

[21:56:41 root@CentOS7 ~]#rpm -ql autofs  |grep .*service
/usr/lib/systemd/system/autofs.servic

启动autofs.servic服务,会多一个/misc文件夹

[21:56:55 root@CentOS7 ~]#systemctl start autofs     (该方法启动,重新启动后/misc无法查看到,所以需使用下面该命令

[21:59:42 root@CentOS7 /misc]#systemctl enable autofs

Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.

[22:14:47 root@CentOS7 /]#ls
bin   data  etc   lib    media  mnt  opt   root  sbin  sys  usr
boot  dev   home  lib64  misc   net  proc  run   srv   tmp  var

(2)查看misc目录
[22:25:32 root@CentOS7 /]#cd /misc
[22:25:36 root@CentOS7 /misc]#ls

上面直接查看/misc目录中没有任何内容,先进入/misc/cd中再次查看会多一个cd目录
[22:25:37 root@CentOS7 /misc]#cd /misc/cd
[22:26:37 root@CentOS7 /misc/cd]#cd /misc
[22:26:56 root@CentOS7 /misc]#ls
cd

此时cd目录中的内容
[22:28:18 root@CentOS7 /misc]#
ls cd/

CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL

此时光盘是挂接在:/misc/cd

[22:28:25 root@CentOS7 /misc]#df /dev/sr0
F
ilesystem     1K-blocks    Used Available Use% Mounted on
/dev/sr0         4480476 4480476         0 100% /misc/cd

(3)以 /misc/cd 作为yum的路径

查看yum的配置文件

[22:41:39 root@CentOS7 /etc/yum.repos.d]#cat /etc/yum.conf 

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
[22:42:24 root@CentOS7 /etc/yum.repos.d]#ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo

原有的repo做一个备份

[22:50:08 root@CentOS7 /etc/yum.repos.d]#mkdir bak;mv *.repo bak/

自己建一个repo文件
[22:50:59 root@CentOS7 /etc/yum.repos.d]#vim base.repo

[base]
name = tao base
baseurl = file:///misc/cd  #(本地源,以光盘作为yum源)
gpgcheck=0      

配置一个epel源

[epel]
name= aliyun epel
baseurl=
https://mirrors.aliyun.com/epel/$releasever/$basearch/ #(网络源)
gpgcheck=0
enabled=1

[23:02:49 root@CentOS7 /etc/yum.repos.d]#cat base.repo 

[base]
name = tao base
baseurl = file:///misc/cd
gpgcheck=0
[epel]
name= aliyun epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
gpgcheck=0
enabled=1

(4)查看

[23:04:16 root@CentOS7 /etc/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.8 MB  00:00:02     
repo id                                 repo name              status
base                                   tao base               10,070
epel/7/x86_64                               aliyun epel             13,382
repolist: 23,452



2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

下载及解压:

[22:24:36 root@CentOS7 /data]#wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz

[23:28:15 root@CentOS7 /data]#tar xvf httpd-2.4.25.tar.gz
查看解压文件:

[23:33:06 root@CentOS7 /data/httpd-2.4.25]#ls

ABOUT_APACHE    ap.d      CHANGES      docs     httpd.spec    libhttpd.dep   Makefile.win       README                    srclib
acinclude.m4     build     CMakeLists.txt   emacs-style  include      libhttpd.dsp   modules               README.cmake         support
Apache-apr2.dsw   BuildAll.dsp  config.layout    httpd.dep   INSTALL      libhttpd.mak   NOTICE                 README.platforms   test
Apache.dsw      BuildBin.dsp  configure     httpd.dsp   InstallBin.dsp  LICENSE      NWGNUmakefile  ROADMAP                 VERSIONING
apache_probes.d   buildconf   configure.in    httpd.mak   LAYOUT      Makefile.in    os                          server

       可以通过README ;INSTALL查看安装方法

       configure的安装;参考Makefile.in 用脚本configure 生成Makefile文件

       configure 安装注意 :
           1.安装路径要指定

           2.哪些特性需要启用,哪些特性不需要启用

 安装步骤:

1./configure --prefix=PREFIX
2.make
3.make install
4.PREFIX/bin/apachectl start

执行安装操作

1.[23:59:19 root@CentOS7 /data/httpd-2.4.25]#./configure \
--prefix=/apps/httpd24 \
--sysconfdir=/etc/httpdt \
--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.

执行上面命令,出现报错,解决该错误方法:一般安装:名字+”-devel”的包即可,对于上面的报错,即安装:APR-devel包

会涉及安装的包如下所示:

yum install gcc

yum install apr-devel -y

yum install apr-util-devel  -y

yum install pcre-devel -y

yum install openssl-devel -y

安装完所有的包后,执行第一步的命令

2.make -j 4

3.make install

4.测试是否安装成功

1)可在安装目录中直接运行aparchctl start

[13:05:28 root@CentOS7 ~]#. /apps/httpd24/bin/apachectl start

2)或者写入变量当中这种方法,当重新电脑启动后,服务是无法自动启动的

[09:58:12 root@CentOS7 /etc/profile.d]#vim env.sh
[09:59:05 root@CentOS7 /etc/profile.d]#. env.sh
[09:59:16 root@CentOS7 /etc/profile.d]#echo $PATH
/apps/httpd24/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[09:59:22 root@CentOS7 /etc/profile.d]#apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using CentOS7.6.localdomain. Set the 'ServerName' directive globally to suppress this message

让apachectl服务开机时自动启动

(1)[13:17:50 root@CentOS7 ~]#vim /etc/rc.d/rc.local

在rc.local中加入以下内容(如下图所示,前面的路径是在--prefix=/apps/httpd24中设置的路径
/apps/httpd24/bin/apachectl start

随笔6_tww_第1张图片
(2)还需加上执行权限
chmod +x /etc/rc.d/rc.local

 

在网页中输入ip地址,如能显示,则表示安装成功

 

随笔6_tww_第2张图片

可以在index.html中修改显示内容:

image

 


3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项

1).查看硬盘

[00:00:45 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    2G  0 part [SWAP]
sdb      8:16   0   20G  0 disk
sr0     11:0    1  4.3G  0

此处以sdb硬盘进行实验

2).对sdb分一个2G的分区

[00:01:51 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 0xc849f931.

Command (m for help): n     ( 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    ( w:保存退出)
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

 

[00:08:24 root@CentOS7 ~]#lsblk  /dev/sdb
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  20G  0 disk
└─sdb1   8:17   0   2G  0 part

 

3).创建文件系统

[10:24:22 root@CentOS7 ~]#mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1

[10:26:25 root@CentOS7 ~]#blkid /dev/sdb1
/dev/sdb1: LABEL="TEST" UUID="9ef4eb89-c0ae-443f-bb53-2bbaa169ab47" TYPE="ext4"

配置文件/etc/fstab中加入以下代码

UUID=9ef4eb89-c0ae-443f-bb53-2bbaa169ab47 /test                   ext4    acl             0 0

[10:48:07 root@CentOS7 /test]#mkdir /test

[10:48:07 root@CentOS7 /test]#mount –a

查看

[10:50:13 root@CentOS7 /test]#df /dev/sdb1
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sdb1        1998538  9236   1960140   1% /test

随笔6_tww_第3张图片

4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录

查看磁盘情况

[20:37:13 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    2G  0 part [SWAP]
sdb      8:16   0   20G  0 disk
├─sdb1   8:17   0    2G  0 part /test
└─
sdb2   8:18   0   18G  0 part
sdc      8:32   0  100G  0 disk
└─
sdc1   8:33   0    2G  0 part
sr0     11:0    1  4.3G  0 rom 

以sdb2和sdc1作为pv

 1).创建物理卷
创建

[20:44:10 root@CentOS7 ~]#pvcreate  /dev/sd{b2,c1}
  Physical volume "/dev/sdb2" successfully created.
  Physical volume "/dev/sdc1" successfully created.

查看

[20:44:49 root@CentOS7 ~]#pvs
  PV         VG Fmt  Attr PSize   PFree 
  /dev/sdb2     lvm2 ---  <18.00g <18.00g
  /dev/sdc1     lvm2 ---    2.00g   2.00g

2).创建卷组

 创建

[20:51:26 root@CentOS7 ~]#vgcreate  testvg /dev/sd{b2,c1}  -s 16M
  Volume group "testvg" successfully created
查看

随笔6_tww_第4张图片

3).创建逻辑卷

 创建

[20:54:11 root@CentOS7 ~]#lvcreate -n testlv -L 5G testvg
  Logical volume "testlv" created.

查看

随笔6_tww_第5张图片

4.创建文件系统

[21:18:51 root@CentOS7 ~]#mkfs.xfs /dev/testvg/testlv
5挂载

[21:23:02 root@CentOS7 ~]#mkdir /users ;mount /dev/testvg/testlv   /usrs/