虚拟机创建及部署
Posted ZhengLiming
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了虚拟机创建及部署相关的知识,希望对你有一定的参考价值。
本次试验涉及:虚拟机创建、iso上传、模版创建、批量部署、用户授权、用户登录
在H配置完后,接下来要对M上做虚拟机以实现批量部署客户端。
首先在前面创建了一个example.com域并将rhevadmin这个用户加入了其中并赋予了管路权限。接下来在M上创建虚拟机。

1.png
1、在/etc/expotrs下将所有人都赋予权限(在访问磁盘时iscsi需要能访问)
2、安装spice-xpi是为了一会能够图形化显示安装的系统

2.png
1-2、登陆rhevadmin这个域的用户

3.png
1、当H配置好后就会在主机栏显示servera这个主机

4.png
1、在数据中心栏中添加
2、创建一个数据中心名为date-1
####数据中心是所有的配置信息都存于M中,以后所有的配置后围着数据中心配置

5.png
1、在集群栏中添加,数据中心为date-1,创建集群名为cluster-1
2、cpu类型应该选择对应的H端的cpu架构,可以用lscpu查看cpu信息(不能跨数据中心、不能跨cpu型号(同种牌子也需要同种架构))
3、根据对应的版本选择

6.png
1、在优化下选择自己对应的优化方式

7.png
1-2、在主机栏中批准刚刚配置的H端servera主机,对应的数据中心和集群
3、主机名为servera.pod0.example.com
4、IP地址为172.25.0.10
5、端口默认为22

7a.png
1、主机servera被批准后,前面的图标变成一个向上的绿色箭头,说明主机创建成功

8.png
1、在存储栏中,新建域,名称为iscsi-1
2、对应的数据中心为date-1
3、选择data/iscsi存储类型
4、使用主机为servera.pod0.example.com
5、发现目标地址为172.25.0.15就是M端的IP地址
6、点击发现就会在下面显示iscsi共享的所有磁盘
7、勾选对应的磁盘

9.png
1-3、在存储栏中,将本地的域名iso0下的数据中心附加在date-1这数据中心上

9a.png
1、当域iso0附加成功后前面的图标变成一个向上的绿色箭头
2、在iso0下的映像中就会显示本地有那些镜像文件
####可以在/exports/rhevisos/1ba296ca-bc37-4b1a-b873-8cf03badfb3d/images/11111111-1111-1111-1111-111111111111路径下看见这些镜像

10.png
1、用wget在真机上将rhel-server-7.1-x86_64-boot.iso复制到本地
####方法一:
2、当没有root用户的权限下,可以借助engine-iso-uploader list 工具
3、用engine-iso-uploader -i(进入) iso0(本地域) upload(更新) rhel-server-7.1-x86_64-boot.iso 上传到本地的/exports/rhevisos/1ba296ca-bc37-4b1a-b873-8cf03badfb3d/images/11111111-1111-1111-1111-111111111111路径下。
4、当用ll查看是上传的文件时,文件的所属者和所属组都被改成vdsm和kvm
####方法二:

11.png
1、当有root权限时,可以直接在/exports/rhevisos/1ba296ca-bc37-4b1a-b873-8cf03badfb3d/images/11111111-1111-1111-1111-111111111111路径下用wget复制在当前路径
2、当复制完后,复制的文件的权限不是vdsm和kvm
3、需要用chown修改成vdsm和kvm
4、修改后的结果

12.png
1-2、当复制完、权限也修改后在存储栏中的iso0下的映像就会显示这2个镜像文件

13.png
1、在虚拟机栏中新建虚拟机,选择对应的集群和操作系统
2、类型选择small为基本
3、虚拟机名称为RHEL-7
4、选择对应的网络rhevm/rhevm
##Stateless:还原卡
##以暂停模式开启:开机为暂停再能开机
##删除保护:彻底删除不会留在回收站

14.png
1、在系统中根据自己的需求给虚拟机多大的内存个cpu的核数
2、选择中国的时间

15.png
1、配置一个虚拟磁盘用来安装系统

16.png
1、添加一个15G磁盘
2、preallocated 一次给
Thin Prowision 用多少给多少

17.png
1、当磁盘配置完后,在磁盘栏中就会显示一个创建好的磁盘

18.png
1、当虚拟机创建完后,点击只运行一次

19.png
1、勾选附加CD 选择对应的镜像文件
2、选择CD-ROM优先启动

20.png
1、点击只运行一次的右边有个像显示屏的图标
2、默认选择Open with就OK

21.png
1、选择第一行 安装

22.png
1、地方:上海
2、语言:简体中文
3、键盘:美式键盘
4、源码包
5、安装的模式:图形化
6、磁盘分配:swap 为2048M、/为10240M
7、
8、ip地址及主机名

23.png
1、root密码设置:redhat
2、用户:帐号zlm、密码redhat

24.png
reboot重启

26.png

25.png
1、关掉RHEL-7后做一个快照
##redhat下的虚拟机做快照与vm大致一样,只不过在做多个快照时在删除最近做的快照前的快照时会连着将后面的快照都删除
2、快照名为rhel1

27.png
1-6、再重启虚拟机RHEL-7时将删除系统内的文件,是系统下次分配时是一个新的系统
hostnamectl set-hostname localhost.local.domain 修改主机名
rm -rf /etc/ssh/ssh-host_*
rm -rf /etc/pki/tls/certs/*
rm -rf /etc/pki/tls/private/*
vim /etc/sysconfig/network-scripts/ifcfg-eth0 下的UUID删掉
rm -rf /var/log/*
rm -rf /root/.bash_history
init 0 关机

28.png
1、在虚拟机栏中,创建模版
2、模版名为:rhel7_bl
集群为:cluster-1/date-1
3、去掉勾,只允许管理员管理该模版
####该模版是基于在刚搭建的虚拟机RHEL7上

29.png
1、模版创建成功就会显示OK(在创建过程需要等一会)
####新建的模版成功后不会受RHEL7的影响

30.png
1、在虚拟机栏中,以模版rhel7_bl创建一个虚拟机
2、类型选择Small标准
3、优化为桌面
4、新的虚拟机名为rhel7-ds,网络地址为rhevm/rhevm
####新建的rhel7-ds虚拟机域RHEL7间不会各自影响

31.png
1、创建后的rhel7-ds左边的图标成显示屏说明虚拟机是以模版创建的

32.png
1、在池栏中,新建一个池基于rhel7_bl的模版上
2、类型选择Small标准
3、优化为桌面
4、池名为rhel7-pl
5、虚拟机数为3

33.png
1-3、结果为三台虚拟机
####在池内以模版为基础创建虚拟机只要机器性能高可以批量创建,当模版删除那池内的虚拟机也会受影响

34.png
1、分离:不受模板影响

35.png
1-3、在池栏中,rhel7-pl下的权限栏中添加一个用户User1赋予UserRole的权限,用于在用户门户中登陆
####该用户的登陆名为名+姓:rheluser1

36.png
1、选择用户门户

37.png
1、用户名:rheluser1
密码:redhat

38.png
1、登陆后的效果

39.png
1-2、点击向下的绿色箭头卡机,将鼠标移图片上会提示双击图形页面,打开图形页面时会提示报错点击确定后就可以打开图形页面

40.png
图形页面打开后就会跟平常时开机一样
以上是关于虚拟机创建及部署的主要内容,如果未能解决你的问题,请参考以下文章