运维项目实战——虚拟机的封装

本文详细介绍如何在virt-manager中创建虚拟机,并进行主机名、网络、防火墙、SELinux等核心配置,同时讲解如何挂载镜像、配置repo及进行虚拟机克隆的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、安装
在virt-manager里新建一个虚拟机

2、更改主机名

 hostnamectl set-ostname westos.com

3、设定网络

cd /etc/sysconfig/network-scripts/

vim ifcfg-eth0
 
BOOTPROTO=none
NAME=westos
IPADDR=172.25.7.1
GATEWAY=172.25.7.250
DNS1=114.114.114.114
DEVICE=eth0
ONBOOT=yes

4、关闭防火墙

systemctl disable --now NetworkManager
systemctl stop firewalld

5、关闭selinux

vi /etc/sysconfig/selinux

enforcing------>disabled

# 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

6、配置解析文件host

cd /etc
vi hosts


27.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.7.250     westos
172.25.7.1        server1
172.25.7.2        server2
172.25.7.3        server3
172.25.7.4        server4
172.25.7.5        server5
172.25.7.6        server6
172.25.7.7        server7
172.25.7.8        server8

7、挂载镜像

mount /home/kiosk/Desktop/rhel-8.0-x86_64-dvd.iso /westos
   mount: /westos: WARNING: device write-protected, mounted read-only.

yum install -y httpd
mount /home/kiosk/Desktop/rhel-server-7.6-x86_64-dvd.iso /var/www/html/rhel7.6

8、 配置repo

vi /etc/yum.repos.d/dvd.repo
 
[DVD]
name=rehl7.6
baseurl=http://172.25.6.250/rehl7.6
gpgcheck=0

9、关闭电源后在真机中进行克隆:

cd /var/lib/libvirt/images/
virt-sysprep -d rhel7.6-lue  #清理虚拟机
qemu-img create -f qcow2 -b rhel7.6-lue.qcow2 vm1 #克隆虚拟机
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值