1. 自建yum仓库,分别为网络源和本地源
1.1 自建网络源yum仓库
1.1.1 仓库端配置
- 关闭防火墙和selinux
[root@localhost /]# getenforce
Disabled
[root@localhost /]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost /]#
- 安装httpd并将镜像挂载到相关目录,实际建议cp到相关目录
[root@localhost yum.repos.d]# yum -y install httpd
[root@localhost cd]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost cd]#
[root@localhost /]# mount /dev/sr2 /var/www/html/centos/8/os/x86_64/
mount: /var/www/html/centos/8/os/x86_64: WARNING: device write-protected, mounted read-only.
[root@localhost /]#
1.1.2 客户端配置
- 备份旧yum源
[root@centos8 yum.repos.d]# mv CentOS-Base.repo backup/CentOS-Base.repo.alibaba
- 创建新的yum源指向自建网络源yum仓库
[root@centos8 yum.repos.d]# vim Base.repo
[root@centos8 yum.repos.d]# cat Base.repo
[base]
name=base
baseurl=http://10.0.0.8/centos/$releasever/os/$basearch/BaseOS/
gpgcheck=0
[appstream]
name=appstream
baseurl=http://10.0.0.8/centos/$releasever/os/$basearch/AppStream/
gpgcheck=0
[root@centos8 yum.repos.d]#
- 列出仓库,验证是否成功
[root@centos8 yum.repos.d]# yum repolist
base 105 MB/s | 2.2 MB 00:00
Cannot find a valid baseurl for repo: appstream
Error: Cannot find a valid baseurl for repo: appstream
[root@centos8 yum.repos.d]#
[root@centos8 yum.repos.d]#
[root@centos8 yum.repos.d]# vim Base.repo
[root@centos8 yum.repos.d]#
[root@centos8 yum.repos.d]# yum repolist
base 3.6 MB/s | 3.9 kB 00:00
appstream 134 MB/s | 5.4 MB 00:00
repo id repo name status
appstream appstream 4,755
base base 1,659
[root@centos8 yum.repos.d]#
1.2自建本地yum仓库
1.2.1 挂载相关镜像
[root@localhost /]# mount /dev/sr2 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost /]#
[root@localhost /]# ll /mnt
total 12
dr-xr-xr-x 4 root root 2048 Jan 4 2020 AppStream
dr-xr-xr-x 4 root root 2048 Jan 4 2020 BaseOS
dr-xr-xr-x 3 root root 2048 Jan 4 2020 EFI
dr-xr-xr-x 3 root root 2048 Jan 4 2020 images
dr-xr-xr-x 2 root root 2048 Jan 4 2020 isolinux
-r--r--r-- 1 root root 87 Jan 4 2020 media.repo
-r--r--r-- 1 root root 664 Jan 4 2020 TRANS.TBL
[root@localhost /]#
1.2.2 修改yum配置文件指向本地光盘源
[root@localhost yum.repos.d]# vim base.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# cat base.repo
[base]
name=base
baseurl=file:///mnt/BaseOS/
gpgcheck=0
[appstream]
name=appstream
baseurl=file:///mnt/AppStream
gpgcheck=0
[root@localhost yum.repos.d]#
1.2.3 验证仓库
[root@localhost yum.repos.d]# yum repolist
repo id repo name
appstream appstream
base base
[root@localhost yum.repos.d]#
2. 编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
2.1安装编译httpd依赖软件并下载httpd源码包
[root@centos8 ~]#yum -y install wget bzip2 gcc apr-devel apr-util-devel pcre-devel make redhat-rpm-config
[root@centos8 ~]#wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
2.2解压源码包并编译安装
[root@centos8 ~]#tar xvf httpd-2.4.46.tar.bz2 -C /usr/local/src/
[root@centos8 ~]#cd /usr/local/src/httpd-2.4.46/
[root@centos8 httpd-2.4.46]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd
[root@centos8 httpd-2.4.46]# make && make install
2.3 启动httpd
[root@centos8 httpd-2.4.46]# nohup /usr/local/httpd/bin/apachectl -k start &
2.4在另一台服务器上访问httpd
[root@localhost ~]# curl 10.0.0.18
<html><body><h1>It works!</h1></body></html>
3. 创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
3.1用fdisk
命令创建新的分区
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): +2G
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
3.2 为新分区创建文件系统
[root@localhost ~]# mkfs.ext4 -b 2048 -L TEST -m 1 /dev/sdb1
3.3 将挂载写入配置文件并加载
[root@localhost ~]# cat /etc/fstab
UUID=ed42664a-0d82-4e5a-8660-25a28b7ddac3 /test ext4 acl 0 0
[root@localhost ~]#
[root@localhost ~]# mkdir /test
[root@localhost ~]# mount -a
4. 创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
4.1创建两个新PV
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@localhost ~]#
[root@localhost ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created.
[root@localhost ~]#
4.2 创建testvg卷组,并指定PE大小为16M
[root@localhost ~]# vgcreate -s 16M testvg /dev/sdb1 /dev/sdb2
Volume group "testvg" successfully created
[root@localhost ~]#
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
testvg 2 0 0 wz--n- <19.97g <19.97g
[root@localhost ~]#
4.3 创建逻辑卷
[root@localhost ~]# lvcreate -L 5G -n testlv testvg
Logical volume "testlv" created.
4.4 为逻辑卷创建文件系统并挂载
[root@localhost ~]# mkfs.ext4 /dev/testvg/testlv
[root@localhost ~]# mkdir /users
[root@localhost ~]# mount /dev/testvg/testlv /users
[root@localhost ~]#
架构作业:
1、实现openstack控制端的高可用
2、结合lvs实现openstack的负载均衡