KVM详细安装

KVM详细安装

安装KVM

yum-yinstallqemu-kvmlibvirtpython-virtinstbridge-utils

yuminstallbridge-utils.x86_64

查看模块是否启用

[root@test~]#lsmod|grepkvm

kvm_intel534840

kvm3165061kvm_intel

查看路由

[root@test~]#iproutelist

192.168.2.0/24deveth0protokernelscopelinksrc192.168.2.243

192.168.122.0/24devvirbr0protokernelscopelinksrc192.168.122.1

169.254.0.0/16deveth0scopelinkmetric1002

defaultvia192.168.2.1deveth0

查看虚拟网卡

[root@test~]#brctlshow

bridgenamebridgeidSTPenabledinterfaces

virbr08000.52540050ca18yesvirbr0-nic

###################################正确#########################

[root@localhost~]#more/etc/sysconfig/network-scripts/ifcfg-em1

DEVICE=em1

NM_CONTROLLED="yes"

ONBOOT=yes

BRIDGE="br0"

[root@localhost~]#more/etc/sysconfig/network-scripts/ifcfg-br0

DEVICE="br0"

NM_CONTROLLED="yes"

TYPE=Bridge

BOOTPROTO=none

name="br0"

ONBOOT=yes

IPADDR=10.10.16.39

NETMASK=255.255.0.0

GATEWAY=10.10.16.1

DNS1=8.8.8.8

###################################正确#########################

######################################################

配置桥接网卡

vi/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"

BOOTPROTO="static"

BROADCAST="192.168.2.255"

DNS1="192.168.0.51"

GATEWAY="192.168.2.1"

WADDR="D4:3D:7E:18:4B:FA"

IPADDR="192.168.2.10"

IPV6INIT="yes"

IPV6_AUTOCONF="yes"

NETMASK="255.255.255.0"

NM_CONTROLLED="yes"

ONBOOT="yes"

TYPE="Ethernet"

UUid="9a8ca6d1-5d07-4894-b0ca-c7a33d8d92d5"

BRIDGE="br0"

name="Systemeth0"

cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-br0

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

DEVICE="br0"

BOOTPROTO="static"

DNS1="192.168.0.51"

GATEWAY="192.168.2.1"

IPADDR="192.168.2.10"

ONBOOT="yes"

TYPE="Bridge"

PREFIX=24

###########################################################

安装wget下载ISO镜像

yuminstallwget*-y

yuminstalllrzsz*-y

[root@localhostvar]#mkdirvm

###################################

[root@localhostvm]#qemu-imgcreate-fqcow2/var/vm/centos.qcow240G

Formatting'/var/vm/centos.qcow2',fmt=qcow2size=42949672960encryption=offcluster_size=65536

[root@localhostvm]#pwd

/var/vm

####################

[root@localhostvm]#qemu-imginfo-fqcow2/var/vm/centos.qcow2

image:/var/vm/centos.qcow2

fileformat:qcow2

virtualsize:40G(42949672960bytes)

disksize:136K

cluster_size:65536

[root@localhostvm]#

安装操作系统,命令执行完成后,虚拟机自动开始安装进程,使用vnc连接进行安装

virt-install--name=centos17--ram=1024--vcpus=1--diskpath=/var/vm/linux.qcow2,device=disk,format=qcow2,bus=virtio,cache=none,size=80--os-type=linux--os-variant=rhel6--hvm--cdrom=/var/iso/CentOS-6.4-x86_64-bin-DVD1.iso--bootcdrom,hd,menu=on--networkbridge=br0--vnc--vncport=5991--vnclisten=0.0.0.0

安装系统有两种:img(用qcow则需要按上面的步骤去做)

virt-install--name=centos1--ram512--vcpus=1--diskpath=/var/vm/test02.img,size=30,bus=virtio--accelerate--cdrom/var/iso/CentOS-6.4-x86_64-bin-DVD1.iso--vnc--vncport=5910--vnclisten=0.0.0.0--networkbridge=br0,model=virtio--noautoconsole

CENTOS7

virt-install--namevm1--ram=1024--vcpus=1--networkbridge:br0--diskpath=/var/kvm/images/centos7.img,size=10--graphicsnone--location=http://ftp.iij.ad.jp/pub/linux/centos/7/os/x86_64/--extra-args="console=tty0console=ttyS0,115200"

virt-install--name=Optimadbr1--ram=4048--vcpus=1--diskpath=/services/vms/Optimadbr1.img,size=40,bus=virtio--accelerate--cdrom=/iso/--vnc--vncport=5920--vnclisten=0.0.0.0--networkbridge=br0,model=virtio--noautoconsole

kvm

相关推荐