封装虚拟机

1、数据流走向:

client -> dns -> cdn(cache) -> LB+HA -> web server -> tomcat -> db -> storage

2、封装7.6版本虚拟机

[root@foundation50 images]# cd /isos/  镜像存放位置
[root@foundation50 isos]# ls
rhel-8.2-x86_64-dvd.iso  rhel-server-7.6-x86_64-dvd.iso

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

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

禁掉selinux
在这里插入图片描述
禁掉防火墙
在这里插入图片描述
将selinux改称disabled
在这里插入图片描述
配置网络
宿主机为双ip
[root@foundation50 isos]# ip addr show
在这里插入图片描述
虚拟机网关为宿主机上的ip
在这里插入图片描述
启动网络在这里插入图片描述

配置rhel7.6 yum源
在这里插入图片描述
安装基础软件
在这里插入图片描述
做解析
vim /etc/hosts
在这里插入图片描述
poweroff 关机

[root@foundation50 isos]# cd /var/lib/libvirt/images/
[root@foundation50 images]# ls
base.qcow2
[root@foundation50 images]# du -h base.qcow2 
21G	base.qcow2    base有21个G比较占空间
[root@foundation50 images]# yum install libguestfs-tools 安装清理命令的包
[root@foundation50 images]# virt-sysprep -d base   清理缓存临时等文件,-d 后面跟域名 base ,而不是镜像名
[   0.0] Examining the guest ...
[  20.2] Performing "abrt-data" ...
[  20.2] Performing "backup-files" ...
[  21.1] Performing "bash-history" ...
[  21.1] Performing "blkid-tab" ...
[  21.1] Performing "crash-data" ...
[  21.1] Performing "cron-spool" ...
[  21.1] Performing "dhcp-client-state" ...
[root@foundation50 images]# virt-sparsify --compress base.qcow2 rhel7.6-base.qcow2  压缩 ,压缩后的新名字为rhel7.6-base.qcow2 
[   0.0] Create overlay file in /tmp to protect source disk
[   0.1] Examine source disk
[   3.0] Fill free space in /dev/rhel/root with zero
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 193.2] Clearing Linux swap on /dev/rhel/swap
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 199.1] Fill free space in /dev/sda1 with zero
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 212.8] Copy to destination and make sparse
[ 517.8] Sparsify operation completed with no errors.
virt-sparsify: Before deleting the old disk, carefully check that the 
target disk boots and works correctly.
[root@foundation50 images]# rm -f base.qcow2  删除
[root@foundation50 images]# qemu-img creat -f qcow2 -b rhel7.6-base.qcow2 vm1
qemu-img: Command not found: creat
Try 'qemu-img --help' for more information
[root@foundation50 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@foundation50 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@foundation50 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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
依次类推可以创建多台虚拟机,创建虚拟机只需更改网络和主机名

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小莫细说linux

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值