KVM虚拟化
1、部署kvm
环境说明:
系统:CentOS7
IP:192.168.89.157
虚拟机设置(内存:8G 磁盘:200G 虚拟化功能:开启)
设置虚拟机内存,添加一块200G的硬盘
//新建分区,将硬盘所有大小都给这个分区
[root@157 ~]# 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@151 ~]# 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 bigtime=0 inobtcount=0
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@157 ~]# blkid /dev/sdb1
/dev/sdb1: UUID="61f2a261-3735-4a8c-a600-2c696ae3a3e0" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="89539e83-01"
[root@151 ~]# mkdir /kvmdata
[root@151 ~]# vim /etc/fstab
UUID=61f2a261-3735-4a8c-a600-2c696ae3a3e0 /kvmdata xfs defaults 0 0
[root@157 ~]# mount -a
[root@157 ~]# df -Th /dev/sdb1
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 xfs 200G 1.5G 199G 1% /kvmdata
[root@151 ~]#
//KVM安装
//关闭防火墙和selinux
[root@157 ~]# systemctl stop firewalld
[root@157 ~]# systemctl disable firewalld
[root@157 ~]# cat /etc/sysconfig/selinux
SELINUX=disabled
//部署yum源
[root@157 ~]# cd /etc/yum.repos.d
[root@157 yum.repos.d]# rm -rf*
[root@157 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
//安装所需软件包
[root@157 ~]# yum -y install epel-release vim wget net-t