CentOS7部署KVM

2018-11-08  本文已影响0人  david9

kvm管理工具Webvirtmgr安装教程,见 kvm管理工具Webvirtmgr安装

新建桥接网络

备份现有配置(名称为ifcfg-xxx):

cp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-enp0s3_bak

新建桥接配置ifcfg-br0:

vim /etc/sysconfig/network-scripts/ifcfg-br0

内容为:

DEVICE=br0
TYPE=Bridge
BOOTRPOTO=static
IPADDR=10.88.36.103 #根据实际网络填写
NETMASK=255.255.255.0 #根据实际网络填写
GATEWAY=10.88.36.1 #根据实际网络填写
ONBOOT=yes
DNS1=8.8.8.8
DNS2=223.5.5.5

修改原有配置ifcfg-enp0s3:

...
BRIDGE=br0
BOOTPROTO=none
ONBOOT=yes
...

重启网络(请确保配置正确,否则可能无法连接网络):

systemctl restart network
关闭防火墙及selinux

关闭防火墙:

systemctl stop firewalld && systemctl disable firewalld 

关闭selinux:

sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
安装KVM

验证CPU是否支持虚拟化(输出有vmx或svm即表示支持):

cat /proc/cpuinfo | egrep 'vmx|svm'

查看是否加载KVM:

[root@localhost ~]# lsmod | grep kvm
kvm_intel             188688  0 
kvm                   636965  1 kvm_intel
irqbypass              13503  1 kvm

这表明已经加载,如果没有加载则执行以下命令加载KVM:

modprobe kvm

安装kvm:

yum install qemu-kvm qemu-img \
virt-manager libvirt libvirt-python virt-manager \
libvirt-client virt-install virt-viewer libguestfs libguestfs-tools -y

说明:

启动libvirt并设置开机自启动:

systemctl start libvirtd && systemctl enable libvirtd
安装虚拟机
virt-install --virt-type=kvm --name=centos-test \
--vcpus=2 --memory=2048 \
--location=/data/iso/CentOS-7-x86_64-DVD-1810.iso \
--disk=/data/vm/centos-test.qcow2,size=8,format=qcow2 \
--network bridge=br0 \
--graphics none \
--extra-args='console=ttyS0'

说明:

安装界面如下所示:

Installation

1) [x] Language settings                 2) [!] Timezone settings
    (English (United States))                (Timezone is not set.)
3) [!] Installation source               4) [!] Software selection
    (Processing...)                          (Processing...)
5) [!] Installation Destination          6) [x] Kdump
    (No disks selected)                      (Kdump is enabled)
7) [ ] Network configuration             8) [!] Root password
    (Not connected)                          (Password is not set.)
9) [!] User creation
    (No user will be created)
 Please make your choice from above ['q' to quit | 'b' to begin installation |
 'r' to refresh]:

带 [!] 基本都是要配置的,按照顺序往下配置,按对用的数字进行设置
配置好各项后,按b开始安装

如果想退出,键入q,然后crtl + 5即可返回主机

上一篇 下一篇

猜你喜欢

热点阅读