1、自建yum仓库,分别为网络源和本地源
本地源:
1——建立目录,挂载光盘
2——进入到/etc/yum.repos.d/目录下,只保留一个repo结尾的文件,配置最基本的name,baseurl等字段,
3——yum clean all;yum makecache 重新建立缓存
4——验证:yum repolist
[root@centos6 ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@centos6 network-scripts]# cdyum
[root@centos6 yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1991 Jun 26 2018 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 647 Jun 26 2018 CentOS-Debuginfo.repo.bak
-rw-r--r--. 1 root root 289 Jun 26 2018 CentOS-fasttrack.repo.bak
-rw-r--r--. 1 root root 630 Jun 26 2018 CentOS-Media.repo.bak
-rw-r--r--. 1 root root 8854 Jun 26 2018 CentOS-Vault.repo.bak
-rw-r--r--. 1 root root 71 Nov 2 21:15 local.repo
[root@centos6 yum.repos.d]# cat local.repo
[local]
name=local_yum
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
[root@centos6 yum.repos.d]#
[root@centos6 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
local local_yum 6,713
repolist: 6,713
网络源
实验环境:
ip1:192.168.80.10——做服务端
ip2:192.168.80.12——做客户端
ip1:
[root@localhost centos7]# yum install -y httpd #安装httpd软件
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package httpd-2.4.6-80.el7.centos.x86_64 already installed and latest version
Nothing to do
[root@localhost centos7]# cd /var/www/html/ #进入到httpd存放网页数据的目录中,新建若干文件夹,然后将对应版本的iso文件挂载到对应目录,
[root@localhost html]# ll
total 2
drwxr-xr-x. 2 root root 6 Jan 6 06:25 centos6.8
drwxr-xr-x. 8 root root 2048 May 4 2018 centos7
[root@localhost html]# mount /dev/cdrom centos7/
[root@localhost html]# systemctl start httpd
[root@localhost html]# systemctl stop firewalld
# 启动httpd,关闭防火墙
ip2:
打开浏览器输入ip1可以看到对应的文件夹,如下图所示:
# 编辑yum源的配置文件,输入以下内容
[root@centos6 yum.repos.d]# vim http_yum.repo
[root@centos6 yum.repos.d]# cat http_yum.repo
[http_yum]
name=this is a http yum
baseurl=http://192.168.80.10/centos7
gpgcheck=0
enabled=1
[root@centos6 yum.repos.d]#
# 刷新,重建缓存即可
[root@centos6 yum.repos.d]# yum clean all;yum makecache
捕获.PNG
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
# 下载源码包并解压
[root@localhost data]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz
--2020-01-06 06:46:07-- http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 219.143.204.117, 202.204.80.77, 2001:da8:204:1205::22
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|219.143.204.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9267917 (8.8M) [application/octet-stream]
Saving to: ‘httpd-2.4.41.tar.gz’
100%[=======================================================================================================>] 9,267,917 434KB/s in 15s
2020-01-06 06:46:21 (611 KB/s) - ‘httpd-2.4.41.tar.gz’ saved [9267917/9267917]
[root@localhost data]# ll
total 9052
-rw-r--r--. 1 root root 9267917 Aug 13 07:37 httpd-2.4.41.tar.gz
[root@localhost data]# tar -xzvf httpd-2.4.41.tar.gz
# 解压后进入到解压后的目录,三步走,./configur make make install 还要安装一些必要的编译工具
[root@localhost httpd-2.4.41]# mkdir /opt/apache-2.4.41
[root@localhost httpd-2.4.41]# ll /opt/
total 0
drwxr-xr-x. 2 root root 6 Jan 6 06:51 apache-2.4.41
drwxr-xr-x. 2 root root 6 Sep 7 2017 rh
[root@localhost httpd-2.4.41]# pwd
/data/httpd-2.4.41
[root@localhost httpd-2.4.41]# ./configure --prefix=/opt/apache-2.4.41
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@localhost httpd-2.4.41]# yum install -y gcc pcre-devel apr-devel apr-util-devel
[root@localhost httpd-2.4.41]# ./configure --prefix=/opt/apache-2.4.41
[root@localhost ~]# make
[root@localhost ~]# make install
[root@localhost ~]#
# 启动apache,在客户端测试
[root@localhost apache-2.4.41]# /opt/apache-2.4.41/bin/httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
httpd (pid 19260) already running
捕获2.PNG
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
# 新加一块虚拟硬盘
[root@localhost ~]# echo '- - -' > /sys/class/scsi_host/host0/scan
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 20G 0 part /
├─sda3 8:3 0 4G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 10G 0 part /data
sdb 8:16 0 20G 0 disk
sr0 11:0 1 4.2G 0 rom
# 给新硬盘分区
[root@localhost ~]# 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 0xdf75b598.
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-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# 格式化分区
[root@localhost ~]# mke2fs -t ext4 -b 2048 -L TEST -m 1 /dev/sdb1
# 挂载
[root@localhost ~]# mount -o acl /dev/sdb1 /test
mount: mount point /test does not exist
[root@localhost ~]# mkdir /test
[root@localhost ~]# mount -o acl /dev/sdb1 /test
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 3.7G 17G 19% /
devtmpfs 976M 0 976M 0% /dev
tmpfs 992M 0 992M 0% /dev/shm
tmpfs 992M 9.9M 982M 1% /run
tmpfs 992M 0 992M 0% /sys/fs/cgroup
/dev/sda5 10G 107M 9.9G 2% /data
/dev/sda1 497M 148M 350M 30% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/sdb1 20G 15M 20G 1% /test
[root@localhost ~]#
# 写入/etc/fstab文件
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Nov 3 04:34:27 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=a50190c0-c1d3-482c-83cd-ff1174763170 / xfs defaults 0 0
UUID=43a445fa-806e-4002-b185-56f936606dda /boot xfs defaults 0 0
UUID=3bb50e53-a23a-46ab-a65e-2279e3354d54 /data xfs defaults 0 0
UUID=fda48915-74c1-483c-adf3-4e1a8ba89d9d swap swap defaults 0 0
UUID=6bd40f51-c9ab-41a4-bbfa-d79b31a9723e /test ext4 defaults,acl 0 0
[root@localhost ~]# umount /test/
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 3.7G 17G 19% /
devtmpfs 976M 0 976M 0% /dev
tmpfs 992M 0 992M 0% /dev/shm
tmpfs 992M 9.9M 982M 1% /run
tmpfs 992M 0 992M 0% /sys/fs/cgroup
/dev/sda5 10G 107M 9.9G 2% /data
/dev/sda1 497M 148M 350M 30% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/sdb1 20G 15M 20G 1% /test
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
# 新加一块硬盘,20G,然后分两个10G的区
[root@localhost ~]# fdisk /dev/sdc
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 0x7de64e01.
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): +10G
Partition 1 of type Linux and of size 10 GiB is set
# 然后将两个分区变为物理卷
[root@localhost ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[root@localhost ~]# pvcreate /dev/sdc2
Physical volume "/dev/sdc2" successfully created.
[root@localhost ~]# pvdisplay
"/dev/sdc1" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
# 创建卷组
[root@localhost ~]# vgcreate -s 16m testvg /dev/sdc1 /dev/sdc2
Volume group "testvg" successfully created
[root@localhost ~]# vgdisplay
#创建逻辑卷
[root@localhost ~]# lvcreate -L 5G -n testlv testvg
Logical volume "testlv" created.
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID UJ8er6-vw5m-7xwe-hP5n-fgdJ-5rPz-fbcsva
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-01-06 07:53:29 +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@localhost ~]#
#挂载逻辑卷
[root@localhost ~]# mount /dev/testvg/testlv /users/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 3.7G 17G 19% /
devtmpfs 976M 0 976M 0% /dev
tmpfs 992M 0 992M 0% /dev/shm
tmpfs 992M 10M 982M 2% /run
tmpfs 992M 0 992M 0% /sys/fs/cgroup
/dev/sda5 10G 107M 9.9G 2% /data
/dev/sda1 497M 148M 350M 30% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/sdb1 20G 15M 20G 1% /test
/dev/mapper/testvg-testlv 4.8G 20M 4.6G 1% /users
网友评论