第六周-创建基于本地源和网络共享源的yum仓库、逻辑卷使用

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

  1. 虚拟机挂载光盘

在这里插入图片描述

 [root@centos7 ~]# mkdir /mnt/cdrom
 [root@centos7 ~]# mount /dev/cdrom /mnt/cdrom
  1. 备份原yum配置文件
 [root@centos7 ~]# mkdir /etc/yum.repos.d/bak
 [root@centos7 ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
  1. 新建自定义配置文件
 [root@centos7 ~]# vim /etc/yum.repos.d/base.repo
 [base]
name=base yum
baseurl=file:///mnt/cdrom
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[root@centos7 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                                    repo name                                                    status
base                                                       base yum                                                     4,067
repolist: 4,067

[root@centos7 ~]# ls /mnt/cdrom/Packages/*.rpm | wc -l
4067

网络源:
环境:

系统IP角色
centos7192.168.100.7yum源服务器
centos7192.168.100.17客户端
  1. yum源服务器上安装httpd服务
 [root@yum-server ~]# yum -y install httpd
  [root@yum-server ~]# systemctl enable --now httpd
  1. 创建对应目录
 [root@yum-server ~]# mkdir -p /var/www/html/centos/7/os/x86_64
  1. 拷贝或者挂载镜像内容到对应目录
 [root@yum-server ~]# mount /dev/sr0 /var/www/html/centos/7/os/x86_64
 [root@centos7 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        10G  1.9G  8.2G  19% /
/dev/sda3       7.5G   76M  7.5G   1% /data
/dev/sda1      1014M  131M  884M  13% /boot
tmpfs            98M     0   98M   0% /run/user/0
/dev/sr0        4.4G  4.4G     0 100% /var/www/html/centos/7/os/x86_64
  1. 客户端配置yum源
 [root@client ~]# mkdir /etc/yum.repos.d/bak
 [root@client ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
 [root@client ~]# vim /etc/yum.repos.d/base.repo
  [base]
name=base
baseurl=http://192.168.100.7/centos/$releaserver/os/$basearch/
gpgcheck=0
  1. 安装测试
[root@client ~]# yum install -y wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                              Arch                                   Version                                            Repository                            Size
===========================================================================================================================================================================
Installing:
 wget                                 x86_64                                 1.14-18.el7_6.1                                    test                                 547 k

Transaction Summary
===========================================================================================================================================================================
Install  1 Package

Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm                                                                                                                     | 547 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7_6.1.x86_64                                                                                                                             1/1 
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                                                                                                             1/1 

Installed:
  wget.x86_64 0:1.14-18.el7_6.1                                                                                                                                            

Complete!

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

系统IP
centos7192.168.100.7
  1. 安装基础环境
 [root@centos7 ~]# yum install gcc pcre-devel openssl-devel expat-devel bzip2 wget
  1. 下载httpd、apr、apr-util源包并解压
[root@centos7 ~]# cd /usr/local/src
[root@centos7 src]# wget http://us.mirrors.quenda.co/apache//httpd/httpd-2.4.41.tar.bz2
[root@centos7 src]# wget https://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.bz2
[root@centos7 src]# wget https://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
[root@centos7 src]# tar -xjvf httpd-2.4.41.tar.bz2
[root@centos7 src]# tar -xjvf apr-1.7.0.tar.bz2
[root@centos7 src]# tar -xjvf apr-util-1.6.1.tar.bz2
  1. 复制apr和apr-util到httpd-版本/srclib/
[root@centos7 src]# cp -r apr-1.7.0 httpd-2.4.41/srclib/arp
[root@centos7 src]# cp -r apr-util-1.6.1 httpd-2.4.41/srclib/arp-util
  1. 创建Makefile文件
[root@centos7 src]# cd httpd-2.4.41
[root@centos7 httpd-2.4.41]# ./configure \
> --prefix=/usr/local/httpd24 \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-included-apr \
> --enable-modules=most \
> --enalbe-mpms-shared=all \
> --with-mpm=prefork

  1. 编译
[root@centos7 httpd-2.4.41]# make
  1. 安装
[root@centos7 httpd-2.4.41]# make install
  1. 复制httpd服务控制脚本到/usr/local/bin下,并启动httpd服务
[root@centos7 httpd-2.4.41]# cp /usr/local/httpd24/bin/apachectl /usr/local/bin
[root@centos7 httpd-2.4.41]# apachectl -k start
  1. 访问测试
    在这里插入图片描述

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

系统IP
centos7192.168.100.7
  1. 虚拟机添加一块硬盘
[root@centos7 ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0   10G  0 part /
├─sda3   8:3    0  7.5G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0  1.5G  0 part [SWAP]
sdb      8:16   0    2G  0 disk 
sr0     11:0    1  4.4G  0 rom  
  1. 创建分区
[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 0x81000a64.

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x81000a64

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): q

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

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-4194303, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): 
Using default value 4194303
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): w
The partition table has been altered!

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

  1. 创建文件系统
[root@centos7 ~]# mkfs.ext4 -b 2048 -m 1 -L TEST /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, 1048064 blocks
10480 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 (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

查看创建后分区结果:

[root@centos7 ~]# blkid
/dev/sr0: UUID="2019-09-11-18-50-31-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/sda1: UUID="73f1fe9a-100f-476f-80b7-1f7f0c1aa3ac" TYPE="xfs" 
/dev/sda2: UUID="30f34c07-dcdc-4b4e-973f-0272d521986e" TYPE="xfs" 
/dev/sda3: UUID="d1a1cc90-012f-44bf-ac99-70c8e7a6c8a5" TYPE="xfs" 
/dev/sda5: UUID="f6083a27-afc0-428e-be04-68ac03fec069" TYPE="swap" 
/dev/sdb1: LABEL="TEST" UUID="e9bf1504-d7f5-4639-8f37-7f2f988acc39" TYPE="ext4" 

  1. 修改/etc/fstab,添加下列信息:
/dev/sdb1 				  /test			  ext4    acl		  0 0

  1. 创建挂载目录并挂载
[root@centos7 ~]# mkdir /test
[root@centos7 ~]# mount -a
[root@centos7 ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0   10G  0 part /
├─sda3   8:3    0  7.5G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0  1.5G  0 part [SWAP]
sdb      8:16   0    2G  0 disk 
└─sdb1   8:17   0    2G  0 part /test
[root@centos7 ~]# tune2fs -l /dev/sdb1
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:   TEST
Last mounted on:          <not available>
Filesystem UUID:          e9bf1504-d7f5-4639-8f37-7f2f988acc39
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl  ##acl
Filesystem state:         clean
Errors behavior:          Continue
...

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

系统IP
centos7192.168.100.7
  1. 添加一块硬盘
[root@centos7 ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0   10G  0 part /
├─sda3   8:3    0  7.5G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0  1.5G  0 part [SWAP]
sdb      8:16   0   21G  0 disk 
sr0     11:0    1  4.4G  0 rom  

  1. 创建两个分区,并更改系统ID为8e
[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 0xb084a4d9.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):  
Using default response p
Partition number (1-4, default 1): 
First sector (2048-44040191, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-44040191, default 44040191): +10G
Partition 1 of type Linux and of size 10 GiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (20973568-44040191, default 20973568): 
Using default value 20973568
Last sector, +sectors or +size{K,M,G} (20973568-44040191, default 44040191): +10G
Partition 2 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk /dev/sdb: 22.5 GB, 22548578304 bytes, 44040192 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb084a4d9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    20973567    10485760   83  Linux
/dev/sdb2        20973568    41945087    10485760   83  Linux

Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdb: 22.5 GB, 22548578304 bytes, 44040192 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb084a4d9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    20973567    10485760   8e  Linux LVM
/dev/sdb2        20973568    41945087    10485760   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

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

  1. 创建pv
[root@centos7 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
[root@centos7 ~]# pvcreate /dev/sdb2
  Physical volume "/dev/sdb2" successfully created.
[root@centos7 ~]# pvdisplay 
  "/dev/sdb2" is a new physical volume of "10.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb2
  VG Name               
  PV Size               10.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               nrevbz-wVb3-U1x7-csVk-C9sa-gH3Q-Ygca3Q
   
  "/dev/sdb1" is a new physical volume of "10.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               10.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               jHgcnM-Tm3E-kDBG-fZwO-iDZ1-uc4R-Q0NNT4

  1. 创建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
  Total PE              1278
  Alloc PE / Size       0 / 0   
  Free  PE / Size       1278 / <19.97 GiB
  VG UUID               30ihFZ-kWfF-ngq5-Q2rI-K74m-vbHZ-H6ZKV6

  1. 创建lv
[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                SWpk9j-i5Uw-wN9E-zdK1-OwIt-BHX4-gQ4KQ2
  LV Write Access        read/write
  LV Creation host, time centos7.localdomain, 2020-03-27 17:02:53 +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

  1. 创建文件系统
[root@centos7 ~]# 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=0, sparse=0
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@centos7 ~]# blkid
/dev/sr0: UUID="2019-09-11-18-50-31-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/sda1: UUID="73f1fe9a-100f-476f-80b7-1f7f0c1aa3ac" TYPE="xfs" 
/dev/sda2: UUID="30f34c07-dcdc-4b4e-973f-0272d521986e" TYPE="xfs" 
/dev/sda3: UUID="d1a1cc90-012f-44bf-ac99-70c8e7a6c8a5" TYPE="xfs" 
/dev/sda5: UUID="f6083a27-afc0-428e-be04-68ac03fec069" TYPE="swap" 
/dev/sdb1: UUID="jHgcnM-Tm3E-kDBG-fZwO-iDZ1-uc4R-Q0NNT4" TYPE="LVM2_member" 
/dev/sdb2: UUID="nrevbz-wVb3-U1x7-csVk-C9sa-gH3Q-Ygca3Q" TYPE="LVM2_member" 
/dev/mapper/testvg-testlv: UUID="acedf98a-e685-48f2-9c8b-80d2463c8b9f" TYPE="xfs" 

  1. 创建/users目录并挂载lv
[root@centos7 ~]# mkdir /users
[root@centos7 ~]# mount /dev/testvg/testlv /users/
[root@centos7 ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
devtmpfs                   476M     0  476M   0% /dev
tmpfs                      487M     0  487M   0% /dev/shm
tmpfs                      487M  7.7M  479M   2% /run
tmpfs                      487M     0  487M   0% /sys/fs/cgroup
/dev/sda2                   10G  1.9G  8.2G  19% /
/dev/sda3                  7.5G   76M  7.5G   1% /data
/dev/sda1                 1014M  131M  884M  13% /boot
tmpfs                       98M     0   98M   0% /run/user/0
/dev/mapper/testvg-testlv  5.0G   33M  5.0G   1% /users

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值