第六周

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

①光盘搭建本地yum仓库

挂载光盘(前提示虚拟机上已加载光盘镜像)

[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

②利用阿里云搭建网络源

在上述文件中追加配置,如下

[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,实现可以正常访问,并将编译步骤和结果提交

①将下载好的文件复制到系统中

②解压包并查看

[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.

但有错误,APR未被找到,yum补安装

[root@centos7 httpd-2.4.25]#yum install apr-devel
[root@centos7 httpd-2.4.25]#yum install apr-util-devel

继续运行,提示错误

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

再继续安装pcre

[root@centos7 httpd-2.4.25]#yum install pcre-devel

再运行,提示错误

checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

再继续安装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   

再次运行,安装成功
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

⑧执行程序

[root@centos7 ~]#apachectl start

⑨查看执行效果

图片.png

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

以我的sdb硬盘为例说明

①创建2G大小的磁盘分区

[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.

②创建好后查看

[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

③创建文件系统

[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 ~]#mkdir /test
[root@centos7 ~]#vim /etc/fstab
.....
UUID=d96e21bf-6785-463c-9a96-1ccb84593004 /test   ext4    acl     0 0   #UUID通过blkid命令查看得知

⑤重启动验证

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

①创建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

②创建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

③创建逻辑卷并显示信息

[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

④创建文件系统并挂载

[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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1、自建yum仓库,分别为网络源和本地源2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。3、...
    阿浩浩浩阅读 3,283评论 0 1
  • 1、自建yum仓库,分别为网络源和本地源 为保证本地光盘开机自动挂载,安装autofs软件: 挂载光盘:mount...
    小罗很忙阅读 1,463评论 0 0
  • 1、自建yum仓库,分别为网络源和本地源 网络源: 备份repo文件 mkdir /etc/yum.repos.d...
    24K_CHEN阅读 1,162评论 0 0
  • 自建yum仓库,分别为网络源和本地源 本地源 1、创建本地源目录 2、挂载光盘 3、编辑Centos-Media....
    原来是考拉呐阅读 1,666评论 0 0
  • 1、自建yum仓库,分别为网络源和本地源。 本地源: cp /etc/yum.repos.d/CentOS-Bas...
    alone_0cd6阅读 1,301评论 0 0

友情链接更多精彩内容