安装虚拟机
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图标
此处取消所有对号:
删除即可: