1.rhel7.5虚拟机的封装(rhel7.5母盘)
1.基本步骤
a.打开虚拟机管理器,选择镜像安装
b.选择一系列基本属性,选择虚拟机大小,语言,时区等…
注意选择无图形化最小安装(母盘封装为后续服务实验而封装,不需要图形化界面,减少资源利用,封装好后可以直接在物理机使用ssh连接)
c.选择好后等待安装
2.母盘封装配置
a.配置ip网络
cd /etc/sysconfig/network-scripts/
mv ifcfg-ens3 ifcfg-eth0
> ifcfg-eth0
vim ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.10
PREFIX=24
systemctl restart network ##重启服务 发现报错
报错解决:
vim /boot/grub2/grub.cfg 在文件99行最后添加 net.ifnames=0 ##修改默认网卡设备名称为eth0
reboot ##重启修改生效
b.测试网络连通性
ping 172.25.254.1(物理机ip) ##ip addr show检查网卡及ip都没有错,但虚拟机还是ping不同物理机;再次检查物理机中的网卡,没有找到桥接虚拟机网卡
配置虚拟机网卡:
修改后可以ping通物理机
c.修改主机名、关闭防火墙、设置selinux为disabled模式…
systemctl stop firewalld
systemctl disable firewalld
systemctl stop NetworkManager
systemctl disable NetworkManager
vi /etc/sysconfig/selinux
d.搭建yum源
[root@server yum.repos.d]# vi lin.repo
[rhel7]
name=rhel7
baseurl=http://172.25.254.1/rhel7.0/
gpgcheck=0
[root@server yum.repos.d]# ls
lin.repo
[root@server yum.repos.d]# yum clean all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel7
Cleaning up everything
[root@server yum.repos.d]# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel7 | 4.1 kB 00:00:00
(1/2): rhel7/group_gz | 134 kB 00:00:00
(2/2): rhel7/primary_db | 3.4 MB 00:00:00
repo id repo name status
rhel7 rhel7 4,305
repolist: 4,305
e.下载基本使用软件
yum install -y vim lftp net-tools ## net-tools网络工作 不装没有ifconfig命令
f.配置完成关机
在物理机清理缓存 virt-sysprep -d rhel7.3 ##-d后面加的是母盘名称
## 如果在虚拟机管理器中删除了母盘就不能使用此命令
## 清理缓存的原因: 每次开机都会生成一些临时文件、缓存文件等,如果不清除,快照会变大,占用缓存。。