企业实战--虚拟机的封装

虚拟机安装及设置

1.安装rhel7虚拟机
2.选择最小化安装,自动分区
3.修改ip

vim /etc/sysconfig/network-scripts/ifcfg-eth0
写入:
BOOTPROTO=static
DEVICE=eth0
ONBOOT=yes
IPADDR=172.25.63.3
PREFIX=24

若使用 ip addr show命令查看网卡名称不是eth0,则执行以下操作:

vim /boot/grub2/grub.cfg

将文件99行最后添加  net.ifnames=0

98         fi
99         linux16 /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/mapper/rhel-root ro     crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet LANG=en    _US.UTF-8 net.ifnames=0
100         initrd16 /initramfs-3.10.0-514.el7.x86_64.img

4.关闭禁用NetowrkManager :会影响网络配置、DNS等

systemctl stop NetworkManager
systemctl disable NetworkManager

5.配置yum源

vim /etc/yum.repos.d/rhel.repo
写入:
[rhel7.3]
name=rhel7.3
baseurl=http://172.25.63.250/iso
gpgcheck=0

6.安装基础软件

yum install -y vim lftp net-tools

7.关闭selinux
8.关闭并禁用防火墙

systemctl stop filewalld
systemctl disable filewalld

9.修改主机名

hostnamectl set-hostname server1

10.添加解析
物理机解析也加上

vim /etc/hosts
写入:
172.25.63.250   foundation63.ilt.example.com
172.25.63.1     server1
172.25.63.2     server2
172.25.63.3     server3
172.25.63.4     server4
172.25.63.5     server5
172.25.63.6     server6
172.25.63.7     server7

11.关闭虚拟机

poweroff
  1. 清理临时及缓存文件
    在真机中:
cd /var/lib/libvirt/images/
virt-sysprep -d rhel7.3-cl.qcow2

如果提示没有命令virt-sysprep,则需要安装:

yum whatprovides */virt-sysprep
yum install -y libguestfs-tools-c-1.32.7-3.el7.x86_64

13.快照虚拟机

cd /var/lib/libvirt/images/
qemu-img create -f qcow2 -b rhel7.3-cl.qcow2 pp1

14.使用虚拟机快照创建虚拟机
在虚拟机管理器中import pp1即可

发布了101 篇原创文章 · 获赞 65 · 访问量 3138

猜你喜欢

转载自blog.csdn.net/qq_35887546/article/details/104392439