一.虚拟机封装

1.新建6.5版本的虚拟机

virt-manager打开虚拟机管理器安装名叫base虚拟机

  • mem = 512 MB(默认选择无图形化安装)
  • GiB=12G(虚拟硬盘disk,内存大一点)
  • lanuage = English 选择语言和美式键盘
  • Linux 运维:虚拟机封装
  • Linux 运维:虚拟机封装
  • Time Zone = Asia/Shanghai 时区
  • Linux 运维:虚拟机封装
  • TCP/IP中ipv4中选择dhcp,关闭ipv6
  • 设置超户密码
  • Linux 运维:虚拟机封装
  • 重新初始化所有磁盘设备

Linux 运维:虚拟机封装

将存储设置写入磁盘

Linux 运维:虚拟机封装

重启完成更新

Linux 运维:虚拟机封装

二、配置base虚拟机

1.关闭防火墙和iptables

iptables -L                            #查看火墙状态

/etc/init.d/iptables stop     #关闭火墙

chkconfig iptables off       #设置火墙开机不启动

Linux 运维:虚拟机封装

2.关闭selinux

vi /etc/sysconfig/selinux

SELINUX=disable

Linux 运维:虚拟机封装

3.配置ip

cd /etc/sysconfig/network-scripts/

vi ifcfg-eth0

/etc/init.d/network restart重启网络

Linux 运维:虚拟机封装

4.配置yum仓库

vi /etc/yum.repo.d/rhel-source.repo

Linux 运维:虚拟机封装

Linux 运维:虚拟机封装

yum install -y vim openssh-clients lftp #安装vim,scp,ftp

Linux 运维:虚拟机封装

5.更改主机名

vim /etc/sysconfig/network

HOSTNAME=server1    #永久更改主机名为server1

Linux 运维:虚拟机封装

6.配置本地解析

vim /etc/hosts

Linux 运维:虚拟机封装

7.关闭虚拟机

poweroff

8.清除base缓存

真机上安装virt-sysprep用来清除缓存

yum provides */virt-sysprep  #查看包含/virt-sysprep命令的安装包

yum  install  libguestfs-tools-c-1.28.1-1.55.el7.x86_64 -y

virt-sysprep -d base

Linux 运维:虚拟机封装

2.删除虚拟机管理器中的base(防止损坏母镜像)

不删除镜像文件

Linux 运维:虚拟机封装

在/var/lib/libvirt/images里还存在base.qcow2

Linux 运维:虚拟机封装

三、创建子虚拟机

qemu-img create -f qcow2 -b base.qcow2 vm1

qemu-img create -f qcow2 -b base.qcow2 vm2

qemu-img create -f qcow2 -b base.qcow2 vm3

Linux 运维:虚拟机封装

2、导入新建的子镜像到虚拟机管理器

导入子镜像,ostype:Linux,version选择redhat6.5

Linux 运维:虚拟机封装Linux 运维:虚拟机封装

内存设置1G,cpu1颗,名字与镜像名字最好保持一致

Linux 运维:虚拟机封装Linux 运维:虚拟机封装

配置子虚拟机的ip和hostname

Linux 运维:虚拟机封装

Linux 运维:虚拟机封装

Linux 运维:虚拟机封装

按照以上步骤配置完三台子虚拟机

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

相关文章:

  • 2021-04-29
  • 2021-09-03
  • 2021-08-08
  • 2021-06-09
  • 2021-11-13
  • 2021-11-11
  • 2021-10-14
猜你喜欢
  • 2021-09-28
  • 2021-12-09
  • 2021-04-25
  • 2021-10-24
  • 2021-05-10
  • 2021-07-05
相关资源
相似解决方案