KVM安装部署虚拟机

作为虚拟化来用时,与KVM结合,称之为QEMU-KVM。QEMU-KVM是基于硬件虚拟化技术(例如Intel VT ,AMD SVM),并结合了QEMU提供设备虚拟化功能,来实现整个系统虚拟化。

从QEMU-KVM定义来看好像物理计算机系统只能是x86体系结构硬件平台,运行Linux操作系统计算机。

但是任何事物都发展的,将来当QEMU-KVM采用IPS , PPC等硬件虚拟化技术,并且KVM移植到其他操作系统上(FreeBSD等),也是有可能。

1.BIOS开启虚拟化
2.启用kvm模块
#modprobe kvm

关闭防火墙
# systemctl stop firewalld.service

3.功能区分intel/amd的启用
#modprobe kvm-intel
# lsmod | grep kvm
kvm_intel            170181  3
kvm                  554609  1 kvm_intel
irqbypass              13503  1 kvm

4.安装kvm
#yum install -y qemu-kvm libvirt virt-manager qemu-kvm-tools

5.安装网桥管理工具tunctl
下载:?query=tunctl
# yum install tunctl-1.5-3.el6.x86_64.rpm

6.挂载U盘,拷贝镜像文件
首先要进入官网下载NTFS-3G工具

6.1.下载之后进行解压
wget
tar -xvf ntfs-3g_ntfsprogs-2014.2.15.tgz

6.2.编译并进行安装
cd ntfs-3g_ntfsprogs-2014.2.15
./configure
make
make install

6.3.挂载NTFS
mount -t ntfs-3g /dev/sda2  /mnt/ckl

6.5.拷贝
cp /mnt/ckl/CentOS-7-x86_64-DVD-1611.iso /root/CentOS-7-x86_64-DVD-1611.iso

7.配置网卡
7.1.会自动启动一个桥设备,这相当于VMware Workstation中的host-only仅主机的网络设备;
# ifconfig 
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::ec4:17fa:8756:5a8f  prefixlen 64  scopeid 0x20<link>
        ether 00:1d:72:58:6f:93  txqueuelen 1000  (Ethernet)
        RX packets 2606  bytes 162013 (158.2 KiB)
        RX errors 0  dropped 2269  overruns 0  frame 0
        TX packets 177  bytes 16706 (16.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17 
 
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 96  bytes 8308 (8.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 96  bytes 8308 (8.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:7e:e7:ca  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

7.2.使用网桥管理命令查看
# brctl show
bridge name    bridge id              STP enabled    interfaces
virbr0          8000.5254007ee7ca      yes            virbr0-nic

7.4.需要将NetworkManager服务关闭,开机启动也关闭
# chkconfig NetworkManager off
# service NetworkManager stop

7.5.创建桥接设备及关联网卡到桥接设备上
# virsh iface-bridge ens3 br0
Created bridge br0 with attached device ens3
Bridge interface br0 started

7.6.查看网卡情况
# ifconfig 
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::21d:72ff:fe58:6f93  prefixlen 64  scopeid 0x20<link>
        ether 00:1d:72:58:6f:93  txqueuelen 1000  (Ethernet)
        RX packets 22  bytes 1636 (1.5 KiB)
        RX errors 0  dropped 15  overruns 0  frame 0
        TX packets 22  bytes 4045 (3.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:1d:72:58:6f:93  txqueuelen 1000  (Ethernet)
        RX packets 522  bytes 34644 (33.8 KiB)
        RX errors 0  dropped 341  overruns 0  frame 0
        TX packets 148  bytes 16251 (15.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17 
 
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 14  bytes 770 (770.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 770 (770.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:7e:e7:ca  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/13969.html