Centos安装KVM

纯净的Centos安装KVM主要有以下几部分

【前提条件】

查看系统是否支持CPU虚拟化,网卡虚拟化

  1. 通过以下命令查看设备是否支持虚拟CPU,包含该关键词即表示支持
    cat /proc/cpuinfo | grep vmx (基于Inter处理器)
    cat /proc/cpuinfo | grep svm (基于AMD处理器)
    lsmod | grep kvm

  2. BIOS里需要开启VT-x/VT-d选项和SR-IOV
    Processor Settings > Virtualization Technology,并将 Virtualization Technology 设置更改为 Enabled
    System Setting > Integrated devices 并将 “SR-IOV Global Enable” 设置更改为 “Enabled”
    BIOS还需要进入各个网卡下,开启SR-IOV模式
    (不同服务器开启方式不尽相同,可以百度确认)

一、网络配置部分
  1. 通过ip 相关命令配置管理接口地址
    ip addr add 10.182.145.225/24 dev ens192
  2. 添加默认路由
    ip route add 0.0.0.0/0 via 10.182.145.1

3.添加DNS server,可以通过配置网卡配置文件来永久保存,网卡配置文件路径
cd /etc/sysconfig/network-scripts

[root@localhost network-scripts]# cat ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
BRIDGE=br0
DEFROUTE=yes
#IPADDR=0.0.0.0
#GATEWAY=10.182.145.1
#DNS1=10.88.7.10
#IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=861ae1f6-2015-4435-bef7-ffec118cb2a7
DEVICE=ens192
ONBOOT=yes
NM_CONTROLLED=no

如果担心重启配置会丢失,可以将上述命令添加到 cd /etc/rc.local 末尾,作为开启启动命令
网络重启命令 service network restart/start/stop

二、远程管理部分
  1. 配置SSH远程,先安装SSH server
    yum install -y openssl openssh-server
    systemctl start sshd

  2. 安装gnome桌面
    yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts –y

    [root@localhost system]# cat /lib/systemd/system/graphical.target
    # This file is part of systemd.
    #
    # systemd is free software; you can redistribute it and/or modify it
    # under the terms of the GNU Lesser General Public License as published by
    # the Free Software Foundation; either version 2.1 of the License, or
    # (at your option) any later version.
    
    [Unit]
    Description=Graphical Interface
    Documentation=man:systemd.special(7)
    Requires=multi-user.target
    Wants=display-manager.service
    Conflicts=rescue.service rescue.target
    After=multi-user.target rescue.service rescue.target display-manager.service
    AllowIsolate=yes
    
    [root@localhost system]#cd /etc/systemd/system
    [root@localhost system]#ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
    
    [root@localhost system]#startx
    
  3. VNC远程,参考笔记《VNC远程配置》

三、安装KVM

yum -y install qemu-kvm bridge-utils uml-utilities libvirt-bin virtinst virt-manager virt-viewer virt-install libvirtd libvirt

四、SR-IOV网卡划分
  1. 查看万兆网卡 lspci | grep Ethernet
    [root@pxe44a84225805f VFW]# lspci | grep Ethernet
    01:00.0 Ethernet controller: Broadcom Limited NetXtreme BCM5720 Gigabit Ethernet PCIe
    01:00.1 Ethernet controller: Broadcom Limited NetXtreme BCM5720 Gigabit Ethernet PCIe
    02:00.0 Ethernet controller: Broadcom Limited NetXtreme BCM5720 Gigabit Ethernet PCIe
    02:00.1 Ethernet controller: Broadcom Limited NetXtreme BCM5720 Gigabit Ethernet PCIe
    05:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
    05:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
    06:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
    06:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)

  2. 用pci小工具划分SR-IOV网卡。将工具放到任意目录下,根据help说明进行 划分
    [root@pxe44a84225805f VFW]# ./pci -h
    Usage: pci [options]
    -b pci_addr: bind a pci device back to default driver
    -u interface: unbind a interface
    -q interface: get the pci address and driver of a interface
    -d driver -v vf_count: enable sriov for with <vf_count> of VFs

    [root@localhost VFW]# ./pci -q p2p1                         //获取driver
    Interface: p2p1
    PCI address: 0000:60:00.0
    Driver: ixgbe
    PF: 0000:60:00.0
    VFS:
    
    [root@localhost VFW]# ./pci -d ixgbe -v 8                         //将单个网卡拆分为8个虚拟vf
    Changing driver params...
    0000:5e:00.0
    0000:5e:00.1
    0000:60:00.0
    0000:60:00.1
    
  3. 也可以通过命令划分SR-IOV
    echo ‘6’ > /sys/class/net/p1p1/device/sriov_numvfs
    其中6是划分虚拟网卡数量,p1p1是对应万兆接口名字

五、网桥配置
  1. brctl help, 根据help 手册将物理网卡绑定到网桥上
  2. KVM-Edit-Connection Details-Virtual Networks/Network Interfaces 来控制虚拟网桥或者其它物理网口
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值