实验需求:
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