部署kvm

本文介绍了如何在CentOS7系统上部署KVM虚拟化环境,包括设置虚拟机内存、硬盘,安装KVM,配置网络为桥接模式,以及安装和配置WebVirtMgr进行KVM的Web界面管理。在部署过程中,还解决了服务器出现的accept错误问题,并指导创建虚拟机的步骤。
摘要由CSDN通过智能技术生成

实验需求:

1、部署kvm
2、使用WebVirtMgr的WEB界面管理
3、在该WEB界面中安装一台Linux操作系统

环境说明:

系统:CentOS7
IP:192.168.253.145

1. CPU虚拟化功能

部署前请确保你的CPU虚拟化功能已开启,分为两种情况:
(1)虚拟机要关机设置CPU虚拟化
(2)物理机要在BIOS里开启CPU虚拟化
在这里插入图片描述

2、虚拟机设置(内存:8G 磁盘:200G 虚拟化功能:开启)

设置虚拟机内存,添加一块200G的硬盘

在这里插入图片描述

新建分区,将硬盘所有大小都给这个分区

[root@localhost ~]#  parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? msdos                                                
(parted) unit                                                             
Unit?  [compact]? MIB                                                     
(parted) p                                                                
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 204800MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

(parted) mkpart                                                           
Partition type?  primary/extended? primary                                
File system type?  [ext2]? xfs                                            
Start? 10MiB
End? 204790MiB                                                            
(parted) p                                                                
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 204800MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start    End        Size       Type     File system  Flags
 1      10.0MiB  204790MiB  204780MiB  primary  xfs          lba

(parted) q                                                                
Information: You may need to update /etc/fstab.
[root@localhost ~]# udevadm settle

格式化挂载

[root@localhost ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=13105920 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=52423680, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=25597, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]#  blkid /dev/sdb1
/dev/sdb1: UUID="72ab5f05-368b-450d-bc4f-65ead8a953f3" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="c06f042f-01"
[root@localhost ~]#  mkdir /kvmdata
[root@localhost ~]#  vim /etc/fstab
UUID="72ab5f05-368b-450d-bc4f-65ead8a953f3" /kvmdata  xfs    defaults 0 0
[root@localhost ~]# mount -a
[root@localhost ~]# df -Th
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  865M     0  865M   0% /dev
tmpfs               tmpfs     895M     0  895M   0% /dev/shm
tmpfs               tmpfs     895M  9.7M  886M   2% /run
tmpfs               tmpfs     895M     0  895M   0% /sys/fs/cgroup
/dev/mapper/cs-root xfs        66G  4.7G   61G   8% /
/dev/mapper/cs-home xfs        32G  275M   32G   1% /home
/dev/sda1           xfs      1014M  242M  773M  24% /boot
tmpfs               tmpfs     179M  1.2M  178M   1% /run/user/42
tmpfs               tmpfs     179M  4.6M  175M   3% /run/user/0
/dev/sr0            iso9660   9.0G  9.0G     0 100% /run/media/root/CentOS-Stream-8-x86_64-dvd
/dev/sdb1           xfs       200G  1.5G  199G   1% /kvmdata

KVM安装

关闭防火墙和selinux

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]#  systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]#  vim /etc/sysconfig/selinux 
SELINUX=disabled
//重启reboot

部署yum源,安装所需软件包

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
CentOS-Stream-AppStream.repo  CentOS-Stream-HighAvailability.repo
CentOS-Stream-BaseOS.repo     CentOS-Stream-Media.repo
CentOS-Stream-Debuginfo.repo  CentOS-Stream-PowerTools.repo
CentOS-Stream-Extras.repo     CentOS-Stream-RealTime.repo
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# ls
[root@localhost yum.repos.d]#  curl -o /etc/yum.repos
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值