最近忙于备考没关注,有次点进某小黄鱼发现首页出现了我的笔记还被人收费了
虽然我也卖了一些资源,但我以交流、交换 为主,笔记都是免费 给别人看的
由于当时刚刚接触写的并不成熟,为了避免更多人花没必要的钱,所以决定公开出来
欢迎各位大佬指正文章内容

一、利用虚拟机构建本地实验环境
[本篇所有内容都不属于比赛内容]
因为在利用虚拟机搭建OpenStack
平台之前,我们需要安装操作系统Centos7
1,网卡相关
也就是规划网段,首先说明VM提供的三种网卡模式的区别
桥接模式
直接寄生到宿主机现在的网络上,所以桥接模式会让我们选择桥接哪一个网络适配器

桥接的效果:
假如我们从上游(如:路由器)获取的ip为192.168.100.10,那么我们主机的网段是192.168.100.0/24
采用桥接模式创建出来的虚拟机,也将直接从我们的上游获取ip,如:192.168.100.11、192.168.100.22 ....
创建出来的虚拟机和我们的宿主机是同级关系
缺点:一个网段只有255个ip
,所以采用桥接模式,不可能创建超过254个虚拟机(我们本机占用一个)
图示:

NAT
由于上游分配的ip非常珍贵(我们平时家用的,手机、电脑、平板甚至智能家具各种要上网的设备都需要用)
因此,为了防止不够用的情况,NAT模式是创建虚拟机的绝佳选择
NAT直接开一个虚拟交换机来给虚拟机组网,所以在NAT模式下,我们可以在【**子网IP】**那里随意定义网段

可以在NAT设置中设置网关

可以在DHCP设置中设置IP池

NAT的效果:
假如我们从上游(如:路由器)获取的ip为192.168.100.10,那么我们主机的网段是192.168.100.0/24
如果采用桥接将直接占用此网段的IP数量
我们用NAT模式生成一个虚拟交换机(图中的NAT适配器VM8)
将其网段设置为192.168.101.0/24
将其ip池设置为192.168.101.1至192.168.101.254
采用NAT模式创建的虚拟机,将在101网段下,互相通信
由于主机也处于101网段下,所以可直接与主机进行通信
图示:

注意:在对外数据那里,会有一个NAT虚拟设备,将主机网卡和VM8进行链接,以此达到能上网的效果
仅主机
就是NAT去除了NAT虚拟设备(纯内网,不能上网),其它功能与NAT模式无异
图示:

网卡部分至此结束,再次说下:属于虚拟机知识,与比赛无关
二、构建可快速循环的练习环境
1,设立一个专门用于存放虚拟机的地方,并将其设置为默认

2,创建一个克隆机,通过克隆机的不同快照,实现全部环境的快速克隆







这几个直接默认





最终这样:

点击关闭,创建虚拟机结束
此时第一个快照点:****准备启动

3,开启虚拟机
放大看得清:

取消网卡重命名:

等待图形化界面出现...
出现后,只需要四步:
第一步:

第二步:
第三步:


第四步:

设置密码为 000000 ( 6个0** 为方便我们后面搭建OpenStack填写密码方便)**


等待完成...


关闭防火墙
shell
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
更改SELinux的模式
临时更改SELinux的模式为Permissive(宽容模式)
Enforcing(强制模式) :SELinux
会强制执行其安全策略,阻止不允许的行为,并记录相关的警告和违规行为。
Permissive(宽容模式) :SELinux
不会强制执行其安全策略,但会记录所有的违规行为,就好像它处于强制模式一样。这对于调试和确定哪些操作会被SELinux
阻止很有帮助。
Disabled(禁用模式) :SELinux
完全被禁用,不会加载任何安全策略,也不会记录任何信息。
shell
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 《《《查看
Permissive
永久设置宽容模式(也就是启动时直接以【宽容模式】运行,默认是【强制模式】
[root@localhost ~]# vi /etc/selinux/config
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=Permissive
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
清除系统自带的yum源

关机

此时第二个快照点【关机后创快照】:****4vCPU/4G/100G

添加硬盘

此时第三个快照点:****4vCPU/4G/100G_50G
三、克隆机使用方法
以私有云第一题为例,

我们可以直接克隆我们刚刚克隆机的快照


克隆后,一定在启动虚拟机之前,为其创建一个【准备启动】的快照,方便直接回退重新做题
在克隆后,配置网卡的时候可以把uuid
删除掉,这样就不用担心uuid
重复了,系统会自动重新生成一个