目录
简介
KVM(Kernel-Based Virtual Machines)是一个基于Linux内核的虚拟化技术, 可以直接将Linux内核转换为Hypervisor(系统管理程序)从而使得Linux内核能够直接管理虚拟机, 直接调用Linux内核中的内存管理、进程管理子系统来管理虚拟机。
KVM部署
环境
系统:CentOS8
IP:192.168.91.134
CPU虚拟化功能
部署前请确保你的CPU虚拟化功能已开启,分为两种情况:
(1)虚拟机要关机设置CPU虚拟化
(2)物理机要在BIOS里开启CPU虚拟化
虚拟机设置
(内存:8G 磁盘:200G 虚拟化功能:开启)
//设置虚拟机内存,添加一块200G的硬盘
//开启虚拟化
//关闭防火墙、selinux
[root@kvm ~]# systemctl stop firewalld.service
[root@kvm ~]# systemctl disable firewalld.service
[root@kvm ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
[root@kvm ~]# reboot
//新建分区,将硬盘所有大小都给这个分区
[root@kvm ~]# parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 322GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1075MB 1074MB primary xfs boot
2 1075MB 322GB 321GB primary lvm
Error: /dev/sdb: unrecognised disk label //这里的错误是因为你还没有进行那种分区
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
[root@kvm ~]# 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? //使用那种类型进行分区,按两次TAB键就出现下面这几种类型
aix amiga atari bsd dvh gpt loop mac msdos pc98 sun
New disk label type? msdos
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
(parted) unit //设置单元单位
Unit? [compact]?
% B chs compact cyl GB GiB kB kiB MB MiB s TB TiB
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 //默认的话就是ext2类型
Start? 10MiB //起始点(我们留个几兆)单位是上面设置 End? 204790MiB //结束点&