第六周作业
1、自建yum仓库,分别为网络源和本地源
本地源
安装并启动autofs软件
[root@test ~]# yum -y install autofs
[root@test ~]# systemctl start autofs
[root@test ~]# systemctl enable autofs
查看光盘目录
[root@test ~]# cd /misc/cd
[root@test cd]# ll
总用量 1672
-rw-rw-r-- 5 root root 14 9月 10 03:06 CentOS_BuildTag
drwxr-xr-x 3 root root 2048 9月 6 19:48 EFI
-rw-rw-r-- 3 root root 227 8月 30 2017 EULA
-rw-rw-r-- 3 root root 18009 12月 10 2015 GPL
drwxr-xr-x 3 root root 2048 9月 10 02:07 images
drwxr-xr-x 2 root root 2048 9月 10 02:07 isolinux
drwxr-xr-x 2 root root 2048 9月 6 19:48 LiveOS
drwxrwxr-x 2 root root 1673216 9月 10 02:45 Packages
drwxrwxr-x 2 root root 4096 9月 10 02:59 repodata
-rw-rw-r-- 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 2 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root 2883 9月 10 03:08 TRANS.TBL
配置本地yum源文件
先移走原有的yum源文件
[root@test yum.repos.d]# cd /etc/yum.repos.d/
[root@test yum.repos.d]# mkdir -p /data/yum
[root@test yum.repos.d]# mv * /data/yum/
编辑本地yum源文件
[root@test yum.repos.d]# vim CentOS-Base.repo
file=/misc/cd
[base]
name=CentOS-Base
baseurl=file:///misc/cd
gpgcheck=0
清空原有缓存
[root@test yum.repos.d]# yum clean all
生成新yum源缓存
[root@test yum.repos.d]# yum makecache
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
(1/2): base/other_db | 2.6 MB 00:00:00
(2/2): base/filelists_db | 7.3 MB 00:00:00
元数据缓存已建立
网络源
安装httpd服务
[root@test ~]# yum -y install httpd
[root@test html]# service httpd start

复制rmp包和元数据库到html目录
[root@test html]# cp -rp /misc/cd/{Packages,repodata} /var/www/html/
编辑yum源文件
[root@test html]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-Base
#baseurl=file:///misc/cd
baseurl=http://172.16.1.21/
gpgcheck=0
清空已有缓存,生成新缓存
[root@test html]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base
Cleaning up list of fastest mirrors
Other repos take up 55 M of disk space (use --verbose for details)
[root@test html]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
(1/4): base/group_gz | 165 kB 00:00:00
(2/4): base/primary_db | 6.0 MB 00:00:00
(3/4): base/filelists_db | 7.3 MB 00:00:00
(4/4): base/other_db | 2.6 MB 00:00:00
元数据缓存已建立
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
下载httpd源码包
[root@test tools]# ll
总用量 6868
-rw-r--r-- 1 root root 7030539 9月 30 12:05 httpd-2.4.39.tar.bz2
解压软件包
解压时报错
[root@test tools]# tar xvf httpd-2.4.39.tar.bz2
tar (child): cannot run bzip2: 没有那个文件或目录
tar (child): trying lbzip2
tar (child): lbzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
解决方法
这是因为系统中缺少bzip2软件导致的。
[root@test tools]# yum -y install bzip2
[root@test tools]# tar xvf httpd-2.4.39.tar.bz2
[root@test tools]# ll
总用量 6872
drwxr-sr-x 11 root 40 4096 3月 27 2019 httpd-2.4.39
-rw-r--r-- 1 root root 7030539 9月 30 12:05 httpd-2.4.39.tar.bz2
编译安装httpd服务
目录中主要文件
[root@test httpd-2.4.39]# ll
总用量 2156
-rwxr-xr-x 1 root 40 1199771 3月 27 2019 configure #编译工具
-rw-r--r-- 1 root 40 3782 5月 18 2016 INSTALL #说明文件
安装开发包组
[root@test ~]# yum groupinstall "Development Tools" -y
创建运行httpd服务的用户
[root@test ~]# groupadd www
[root@test ~]# useradd -g www www -s /sbin/nologin
编译httpd服务
[root@test httpd-2.4.39]# ./configure --prefix=/app/
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@test httpd-2.4.39]# yum -y install apr-util-devel apr-devel pcre-devel
[root@test httpd-2.4.39]# ./configure --prefix=/app/
[root@test httpd-2.4.39]# echo $?
0
[root@test httpd-2.4.39]# make && make install
编辑httpd配置文件
[root@test app]# vim conf/httpd.conf
51 Listen 172.16.1.21:80
165 User www
166 Group www
196 ServerName 172.16.1.21:80
启动httpd服务
[root@test ~]# /app/bin/httpd

3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
[root@test ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0x22e0d6aa
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
[root@test ~]# mke2fs -t ext4 -b 2048 -L 'TEST' -m 1 -O acl /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Invalid filesystem option set: acl
[root@test ~]# 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@test ~]# blkid
ev/sda1: UUID="3f858921-b3e6-40e7-9467-fb39bcabd2bf" TYPE="xfs"
/dev/sda2: UUID="Mz29xU-kKCo-Q28O-UjF7-o9aj-6CRP-4wYeck" TYPE="LVM2_member"
/dev/sdb1: LABEL="TEST" UUID="ea304265-aa8a-462b-8a58-cb9aa2f0fc34" TYPE="ext4"
/dev/sr0: UUID="2019-09-09-19-08-41-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/mapper/centos-root: UUID="e0b45a81-0c9f-405e-af87-e616639882b2" TYPE="xfs"
/dev/mapper/centos-swap: UUID="63c9d504-084f-4879-83a8-d229d2d502b3" TYPE="swap"
[root@test ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Oct 13 19:35:28 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
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=3f858921-b3e6-40e7-9467-fb39bcabd2bf /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
UUID=ea304265-aa8a-462b-8a58-cb9aa2f0fc34 /test ext4 defaults,acl 0 0
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
[root@test ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0x22e0d6aa
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 25167871 10485760 83 Linux
/dev/sdb3 25167872 46139391 10485760 83 Linux
[root@test ~]# pvcreate /dev/sdb2 /dev/sdb3
Physical volume "/dev/sdb2" successfully created.
Physical volume "/dev/sdb3" successfully created.
[root@test ~]# vgcreate testvg /dev/sdb2 /dev/sdb3 -s 16
Volume group "testvg" successfully created
[root@test ~]# lvcreate -n testlv -L 5G /dev/testvg
Logical volume "testlv" created.
[root@test ~]# 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@test ~]# mkdir -p /users
[root@test ~]# mount /dev/testvg/testlv /users/
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 194G 12G 183G 7% /
/dev/sda1 2.0G 189M 1.9G 10% /boot
tmpfs 378M 0 378M 0% /run/user/0
/dev/mapper/testvg-testlv 4.8G 20M 4.6G 1% /users

浙公网安备 33010602011771号