快速搭建KVM及安装Linux系统

快速搭建KVM及安装Linux系统

1.安装KVM内核及libvirtd相关组件
yum -y install kvm Python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer

2.加载KVM运行模块
[root@localhost ~]# modprobe kvm
[root@localhost ~]# modprobe -ls |grep kvm
kernel/arch/x86/kvm/kvm.ko
kernel/arch/x86/kvm/kvm-intel.ko
kernel/arch/x86/kvm/kvm-amd.ko

3.创建物理桥
virsh iface-bridge eth0 br0
查看网络
[root@localhost ~]# ifconfig
br0      Link encap:Ethernet  HWaddr 00:0C:29:C1:62:56 
          inet addr:192.168.150.136  Bcast:192.168.150.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec1:6256/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4925 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3937 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:532933 (520.4 KiB)  TX bytes:13484199 (12.8 MiB)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C1:62:56 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:377686 errors:0 dropped:0 overruns:0 frame:0
          TX packets:110643 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:507725096 (484.2 MiB)  TX bytes:66233641 (63.1 MiB)

4.创建一块虚拟磁盘:
qemu-img create -f qcow2 /kvm/test003.img 5G

5.创建一个虚拟机:
qcow2格式
[root@localhost ~]# virt-install --name test003 --ram 512 \
--vcpus=1 --disk path=/kvm/test003.img,size=5,format=qcow2,bus=virtio \
--accelerate --cdrom /tmp/CentOS-6.6-x86_64-minimal.iso\
 --vnc --vncport=5910 --vnclisten=0.0.0.0\
 --network bridge=br0,model=virtio --noautoconsole
 raw格式:
 [root@localhost ~]# virt-install --name test003 --ram 512 \
--vcpus=1 --disk path=/kvm/test003.img,size=5,bus=virtio \
--accelerate --cdrom /tmp/CentOS-6.6-x86_64-minimal.iso\
 --vnc --vncport=5910 --vnclisten=0.0.0.0\
 --network bridge=br0,model=virtio --noautoconsole

6.VNC连接

快速搭建KVM及安装Linux系统快速搭建KVM及安装Linux系统

--------------------------------------分割线 --------------------------------------

--------------------------------------分割线 --------------------------------------

相关推荐