美文网首页
第六周技术作业

第六周技术作业

作者: 神牧 | 来源:发表于2020-07-17 18:34 被阅读0次

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

    [root@localhost yum.repos.d]# mv *.repo /data/repobak  //原yum源备份
    [root@localhost yum.repos.d]# vim aliyun.repo   //配置网络源
    [alinyun]
    baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
    name=aliyun repo
    gpgcheck=0
    enabled=1
    [root@localhost ~]# systemctl start autofs  //挂载本地源文件
    [root@localhost ~]# ll /misc/cd/
    total 1656
    -rw-rw-r-- 1 mzy mzy      14 Nov 26  2018 CentOS_BuildTag
    drwxr-xr-x 3 mzy mzy    2048 Nov 26  2018 EFI
    -rw-rw-r-- 1 mzy mzy     227 Aug 30  2017 EULA
    -rw-rw-r-- 1 mzy mzy   18009 Dec 10  2015 GPL
    drwxr-xr-x 3 mzy mzy    2048 Nov 26  2018 images
    drwxr-xr-x 2 mzy mzy    2048 Nov 26  2018 isolinux
    drwxr-xr-x 2 mzy mzy    2048 Nov 26  2018 LiveOS
    drwxrwxr-x 2 mzy mzy 1656832 Nov 25  2018 Packages
    drwxrwxr-x 2 mzy mzy    4096 Nov 26  2018 repodata
    -rw-rw-r-- 1 mzy mzy    1690 Dec 10  2015 RPM-GPG-KEY-CentOS-7
    -rw-rw-r-- 1 mzy mzy    1690 Dec 10  2015 RPM-GPG-KEY-CentOS-Testing-7
    -r--r--r-- 1 mzy mzy    2883 Nov 26  2018 TRANS.TBL
    [root@localhost yum.repos.d]# vim base.repo    //配置本地源
    [base]
    name=base everything
    baseurl=file:///misc/cd
    gpgcheck=0
    enabled=1
    [root@localhost ~]# yum clean all   //清除yum缓存
    [root@localhost yum.repos.d]# yum repolist   //显示yum源列表
    Loaded plugins: fastestmirror, langpacks
    Determining fastest mirrors
    alinyun                                                                                                 | 3.6 kB  00:00:00     
    base                                                                                                    | 3.6 kB  00:00:00     
    epel                                                                                                    | 4.7 kB  00:00:00     
    (1/7): base/group_gz                                                                                    | 166 kB  00:00:00     
    (2/7): base/primary_db                                                                                  | 6.0 MB  00:00:00     
    (3/7): epel/group_gz                                                                                    |  95 kB  00:00:00     
    (4/7): alinyun/group_gz                                                                                 | 153 kB  00:00:00     
    (5/7): epel/updateinfo                                                                                  | 1.0 MB  00:00:01     
    (6/7): alinyun/primary_db                                                                               | 6.1 MB  00:00:02     
    (7/7): epel/primary_db                                                                                  | 6.8 MB  00:00:02     
    repo id                                                 repo name                                                        status
    alinyun                                                 aliyun repo                                                      10,070
    base                                                    base everything                                                  10,019
    epel                                                    aliyun epel                                                      13,383
    repolist: 33,472
    

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

    [root@localhost data]# tar xvf httpd-2.4.25.tar.bz2 //将httpd源码包解压缩
    [root@localhost httpd-2.4.25]# yum install gcc openssl-devel pcre-devel apr-devel apr-util-devel -y   //安装编译软件及依赖包
    [root@localhost httpd-2.4.25]#./configure --enable-ssl --enable-so //配置安装需要的组件
    [root@localhost httpd-2.4.25]# ll Makefile   //生成make文件
    -rw-r--r-- 1 root root 10622 Jul 17 16:07 Makefile
    [root@localhost httpd-2.4.25]# make -j 4    //make多核编译
    [root@localhost httpd-2.4.25]# make install //安装
    [root@localhost bin]# ./apachectl //到程序安装目录执行启动程序
    [root@localhost bin]# curl http://192.168.58.129   //可以正常访问
    <html><body><h1>It works!</h1></body></html>
    

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

    [root@localhost bin]# echo '- - -' > /sys/class/scsi_host/host0/scan   //检索出硬盘
    [root@localhost bin]# lsblk
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda               8:0    0  100G  0 disk 
    ├─sda1            8:1    0  500M  0 part /boot
    └─sda2            8:2    0 99.5G  0 part 
      ├─centos-root 253:0    0 83.5G  0 lvm  /
      ├─centos-swap 253:1    0    6G  0 lvm  [SWAP]
      └─centos-data 253:2    0   10G  0 lvm  /data
    sdb               8:16   0   20G  0 disk 
    sr0              11:0    1   10G  0 rom  /run/media/mzy/CentOS 7 x86_64
    [root@localhost bin]# 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 0x6e0f56f6.
    
    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   //2G分区大小
    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.
    [root@localhost bin]# partprobe /dev/sdb1  //同步分区表
    [root@localhost bin]# 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, 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@localhost bin]# blkid   
    /dev/sr0: UUID="2018-11-26-14-22-58-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
    /dev/sda1: UUID="6914bbcd-f83d-4431-b62e-114f256b509d" TYPE="xfs" 
    /dev/sda2: UUID="Yl552A-MsYb-Arsi-ufI7-BjUo-u2AK-wiRvMZ" TYPE="LVM2_member" 
    /dev/mapper/centos-root: UUID="9e6e3325-b084-432c-afe3-a9c2b9f1b948" TYPE="xfs" 
    /dev/mapper/centos-swap: UUID="f5cd8e63-77ac-442f-adcd-e2ce1d8b091d" TYPE="swap" 
    /dev/mapper/centos-data: UUID="4f33bfdd-cc5b-4ae9-b251-72cab96f5df4" TYPE="xfs" 
    /dev/sdb1: LABEL="TEST" UUID="5ebe8ec6-1709-4ba7-b4b2-21f2d97d68a9" TYPE="ext4"   //文件系统创建成功
    [root@localhost bin]# vim /etc/fstab  //将/dev/sdb1挂载信息写入fstab文件
    
    #
    # /etc/fstab
    # Created by anaconda on Fri Jul 17 11:33:22 2020
    #
    # 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
    #
    /dev/mapper/centos-root /                       xfs     defaults        0 0
    UUID=6914bbcd-f83d-4431-b62e-114f256b509d /boot                   xfs     defaults        0 0
    /dev/mapper/centos-data /data                   xfs     defaults        0 0
    /dev/mapper/centos-swap swap                    swap    defaults        0 0
    UUID=5ebe8ec6-1709-4ba7-b4b2-21f2d97d68a9 /test ext4    acl   0 0
    [root@localhost bin]# mkdir /test  //创建挂载目录
    [root@localhost bin]# mount -a     //挂载
    [root@localhost bin]# lsblk   
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda               8:0    0  100G  0 disk 
    ├─sda1            8:1    0  500M  0 part /boot
    └─sda2            8:2    0 99.5G  0 part 
      ├─centos-root 253:0    0 83.5G  0 lvm  /
      ├─centos-swap 253:1    0    6G  0 lvm  [SWAP]
      └─centos-data 253:2    0   10G  0 lvm  /data
    sdb               8:16   0   20G  0 disk 
    └─sdb1            8:17   0    2G  0 part /test    //挂载成功
    sr0              11:0    1   10G  0 rom  /run/media/mzy/CentOS 7 x86_64
    

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

    [root@localhost bin]# lsblk   //提前创建好两个分区类型为lvm的分区 sdb1、sdb2
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda               8:0    0  100G  0 disk 
    ├─sda1            8:1    0  500M  0 part /boot
    └─sda2            8:2    0 99.5G  0 part 
      ├─centos-root 253:0    0 63.5G  0 lvm  /
      ├─centos-swap 253:1    0    6G  0 lvm  [SWAP]
      └─centos-data 253:2    0   10G  0 lvm  /data
    sdb               8:16   0   20G  0 disk 
    ├─sdb1            8:17   0   10G  0 part 
    └─sdb2            8:18   0    9G  0 part 
    sr0              11:0    1   10G  0 rom  /run/media/mzy/CentOS 7 x86_64
    [root@localhost bin]# pvcreate /dev/sdb1    //创建pv
      Physical volume "/dev/sdb1" successfully created.
    [root@localhost bin]# pvcreate /dev/sdb2    //创建pv
      Physical volume "/dev/sdb2" successfully created.
    [root@localhost bin]# pvs
      PV         VG     Fmt  Attr PSize   PFree 
      /dev/sda2  centos lvm2 a--  <99.51g 20.00g
      /dev/sdb1         lvm2 ---   10.00g 10.00g
      /dev/sdb2         lvm2 ---    9.00g  9.00g
    [root@localhost bin]# vgcreate -s 16M testvg /dev/sdb1 /dev/sdb2   //创建vg卷组,指定PE大小16M
      Volume group "testvg" successfully created
    [root@localhost bin]# lvcreate -n testlv -L 5G testvg     //创建逻辑卷,大小5G
      Logical volume "testlv" created.
    [root@localhost bin]# 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@localhost bin]# mkdir /users    //创建挂载目录
    [root@localhost bin]# mount /dev/testvg/testlv /users/     //挂载
    [root@localhost bin]# lsblk
    NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda                 8:0    0  100G  0 disk 
    ├─sda1              8:1    0  500M  0 part /boot
    └─sda2              8:2    0 99.5G  0 part 
      ├─centos-root   253:0    0 63.5G  0 lvm  /
      ├─centos-swap   253:1    0    6G  0 lvm  [SWAP]
      └─centos-data   253:2    0   10G  0 lvm  /data
    sdb                 8:16   0   20G  0 disk 
    ├─sdb1              8:17   0   10G  0 part 
    │ └─testvg-testlv 253:3    0    5G  0 lvm  /users    //挂载成功
    └─sdb2              8:18   0    9G  0 part 
    sr0                11:0    1   10G  0 rom  /run/media/mzy/CentOS 7 x86_64
    
    

    相关文章

      网友评论

          本文标题:第六周技术作业

          本文链接:https://www.haomeiwen.com/subject/gcrnhktx.html