企业实战之创建及配置KVM虚拟机

安装虚拟机

1.安装base

安装base(base为自定义,可自己命名)
【1】在物理机中使用超级用户身份。`开虚拟控制台
在这里插入图片描述

【2】创建KVM虚拟机
在这里插入图片描述

【3】选择ISO镜像,点击Browes,进入镜像选择页面。
在这里插入图片描述
在这里插入图片描述

【4】设置虚拟机内存和CPU数目。设置磁盘大小及位置。
在这里插入图片描述

在这里插入图片描述

【5】确认配置参数以及设置网络。

【6】开始安装系统
在这里插入图片描述

2.封装

【1】徐修改主机名称:

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostnamectl set-hostname base
[root@localhost ~]# hostname
base

在这里插入图片描述
【2】编辑ip配置文件:

[root@base ~]# cd /etc/sysconfig/network-scripts/
[root@base network-scripts]# vi ifcfg-eth0

BOOTPROTO=none
NAME=eth0
IPADDR=172.25.18.2
DEVICE=eth0
PREFIX=24
GATEWAY=172.25.18.250
DNS1=114.114.114.114
ONBOOT=yes

在这里插入图片描述
在这里插入图片描述

【2】关闭防火墙等

[root@base ~]# systemctl disable --now NetworkManager
[root@base ~]# systemctl disable --now firewalld

在这里插入图片描述
【3】关闭selinux

[root@base ~]# vi /etc/sysconfig/selinux


# 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=disabled                                       #将enforcing修改为disabled
# 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

在这里插入图片描述

【3】配置解析文件host

位置:/etc/hosts
[root@base ~]# cd /etc
[root@base etc]# vi hosts


27.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.18.250     base
172.25.18.1        server1
172.25.18.2        server2
172.25.18.3        server3
172.25.18.4        server4
172.25.18.5        server5
172.25.18.6        server6
172.25.18.7        server7
172.25.18.8        server8

在这里插入图片描述

在这里插入图片描述
【4】挂载真机镜像

[root@foundation18 ~]# mount /home/kiosk/Desktop/rhel-8.0-x86_64-dvd.iso /westos
mount: /westos: WARNING: device write-protected, mounted read-only.
[root@foundation18 ~]# yum install -y httpd
[root@foundation18 html]# mount /home/kiosk/Desktop/rhel-server-7.6-x86_64-dvd.iso /var/www/html/rhel7.6

在这里插入图片描述

在base母机中:

[root@base ~]# cd /etc/yum.repos.d
[root@base yum.repos.d]# vi dvd.repo

[DVD]
name=rehl7.6
baseurl=http://172.25.18.250/rehl7.6
gpgcheck=0

在这里插入图片描述

在这里插入图片描述

【5】关闭base
poweroff

3.安装

【1】在真机中克隆虚拟机vm1 vm2 vm3 vm4

[root@foundation18 ~]# cd /var/lib/libvirt/images
virt-sysprep -d rhel7.6-lue                          # 清理虚拟机
[root@foundation18 images]# qemu-img create -f qcow2 -b rhel7.6-base.qcow2 vm1
Formatting 'vm1', fmt=qcow2 size=21474836480 backing_file=rhel7.6-base.qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
[root@foundation18 images]# qemu-img create -f qcow2 -b rhel7.6-base.qcow2 vm2
Formatting 'vm2', fmt=qcow2 size=21474836480 backing_file=rhel7.6-base.qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
[root@foundation18 images]# qemu-img create -f qcow2 -b rhel7.6-base.qcow2 vm3
Formatting 'vm3', fmt=qcow2 size=21474836480 backing_file=rhel7.6-base.qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
[root@foundation18 images]# qemu-img create -f qcow2 -b rhel7.6-base.qcow2 vm4
Formatting 'vm4', fmt=qcow2 size=21474836480 backing_file=rhel7.6-base.qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

4.修改子机

注意:不可以打开母机
【1】设置为桥接模式
在这里插入图片描述

【2】 更改名称

在这里插入图片描述
【3】修改ip

在这里插入图片描述
在这里插入图片描述

4.删除base图标

为了防止误打开base,删除base图标
在这里插入图片描述
此处取消所有对号:
在这里插入图片描述
删除即可:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值