##KVM Install
Install Tools:
yum -y install kvm python-virtinst libvirt bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v
安装
virt-install --name=win2003test --ram 1024 --vcpus=1 --disk path=/mnt/win2003test.img,size=20 --accelerate --cdrom /mnt/WindowsServer2003SP2.iso --graphics vnc,password=123456,listen=0.0.0.0,port=5920 --force --autostart
删除
[root@localhost ~]# virsh -c qemu:///system
virsh # list --all
virsh # destroy win2003Test
virsh # undefine win2003Test
安装过程中,在系统重启后,设置CD
修改 /etc/libvirt/qemu/win2003test.xml 或执行命令 virsh edit win2003test
<source dev='/mnt/WindowsServer2003SP2.iso'/>
加入到
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/mnt/WindowsServer2003SP2.iso'/>
...
</disk>
然后执行一下命令
[root@localhost ~]# virsh -c qemu:///system
virsh # shutdown win2003test
virsh # destroy win2003test
virsh # define /etc/libvirt/qemu/win2003test.xml
virsh # start win2003test
virsh # quit
[root@localhost ~]# virt-viewer win2003test
解决出现两个鼠标光标问题
修改 /etc/libvirt/qemu/win2003test.xml 或执行命令 virsh edit win2003test
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
安装网卡驱动
下载virtio-win-0.1-52.iso
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-52.iso
修改
<source dev='/mnt/WindowsServer2003SP2.iso'/>
为
<source dev='/mnt/virtio-win-0.1-52.iso'/>
重启系统
[root@localhost ~]# virsh shutdown win2003test
[root@localhost ~]# virsh define /etc/libvirt/qemu/win2003test.xml
[root@localhost ~]# virsh start win2003test
进入系统后就可以从光驱安装网卡驱动了.
[root@localhost ~]# /etc/init.d/network stop
Shutting down interface br0: [ OK ]
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down interface eth2: [ OK ]
Shutting down interface eth3: [ OK ]
Shutting down interface eth4: [ OK ]
Shutting down interface eth5: [ OK ]
Shutting down loopback interface: [ OK ]
参考文章:
- fedora 17上kvm的配置
- CentOS 6.3部署KVM虚拟机V1.0
- Creating an RHEL 6 KVM Networked Bridge Interface
- RHEL6 KVM安装备忘
- KVM Howto
##KVM Bridge
command list:
[root@localhost ~]#service network stop
[root@localhost ~]#cd /etc/sysconfig/network-scripts/
[root@localhost ~]#cat ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BRIDGE=br0
HWADDR=b3:1c:51:ca:a9:f0
[root@localhost ~]#cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.110.30
NETMASK=255.255.255.192
GATEWAY=192.168.110.1
[root@localhost ~]#service network start
[root@localhost ~]#route add default gw 192.168.110.1 dev br0
参考:
- linux kvm 网卡Bridge设置
- Redhat/CentOS6.2 x86系统KVM虚拟机网络配置(二)—Bridge方式
- CentOS 6.0 下 KVM 网卡桥接的配置
- 虚拟化方案之--kvm简单教程(网络桥接方案,全文更新中。。。)
- RHEL KVM虚拟机网桥设置
- Linux 原生橋接器(Bridge)
- Fedora KVM Networking
- Redhat/CentOS6.2 x86系统KVM虚拟机网络配置 Bridge方式
##KVM Bond
关掉NetworkManager服务
[root@localhost ~]# service NetworkManager stop
[root@localhost ~]# service NetworkManager status
NetworkManager is stopped
列出当前的网卡的个数
查询eth*,其中[[:digit:]]匹配数字,+匹配用来一个或多个数字
[root@localhost ~]# ip a | grep -E "eth[[:digit:]]+:"
2: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
4: eth5: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
5: eth3: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
6: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
7: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
[root@localhost ~]# ip a | grep -E "eth[[:digit:]]+:" | wc -l
6
[root@localhost ~]# grep -E "eth[[:digit:]]+" /proc/net/dev | awk -F' |:' '{print $3}' | sort
eth2
eth3
eth4
eth5
eth6
eth7
HowTo: Linux Show List Of Network Cards
http://www.cyberciti.biz/faq/linux-list-network-cards-command/
列出bond的个数和组成
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
BRIDGE=br1
查看绑定状态
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth5 # 当前使用eth5
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth3 # 绑定成员eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:24:ec:20:00:fe
Slave queue ID: 0
Slave Interface: eth5 # 绑定成员eth5
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:24:ec:20:00:fd
Slave queue ID: 0
列出网桥的个数及其组成,和vnet的情况
1).查询网桥个数
[root@localhost ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.0024ec2000fb no eth4
tap0
br1 8000.0024ec2000fe no bond0
tap1
vnet0
virbr0 8000.525400d2af63 yes virbr0-nic
[root@localhost ~]# ifconfig | grep -E "^br[[:digit:]]"
br0 Link encap:Ethernet HWaddr 00:24:EC:20:00:FB
br1 Link encap:Ethernet HWaddr 00:24:EC:20:00:FE
[root@localhost ~]# ifconfig | grep -E "^br[[:digit:]]" | wc -l
2
2).查询vnet情况,使用sed,查找vnet开始到空行结束的行
[root@localhost ~]# ifconfig | sed -n '/vnet[[:digit:]]/,/^$/p'
vnet0 Link encap:Ethernet HWaddr FE:24:EC:20:00:FF
inet6 addr: fe80::fc24:ecff:fe20:ff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2669288 errors:0 dropped:0 overruns:0 frame:0
TX packets:26731021 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:323410384 (308.4 MiB) TX bytes:2495782478 (2.3 GiB)
[root@localhost ~]#
两个网卡建立绑定
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
BRIDGE=br1
echo "MASTER=bond0
SLAVE=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "MASTER=bond0
SLAVE=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth1
一个绑定建立一个网桥
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
BOOTPROTO=static
NM_CONTROLLED="yes"
ONBOOT=yes
IPADDR=192.168.110.30
PREFIX=24
GATEWAY=192.168.110.1
DEFROUTE=yes
TYPE=Bridge
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE="br1"
BOOTPROTO=none
NM_CONTROLLED="yes"
ONBOOT=yes
IPADDR=192.168.110.32
NETMASK=255.255.255.0
GATEWAY=192.168.110.1
DEFROUTE=yes
TYPE=Bridge
删除网桥,删除绑定
[root@localhost ~]# brctl delif br1 eth3
[root@localhost ~]# brctl delif br1 eth5
[root@localhost ~]# brctl delbr br1
service network stop
rm -f ifcfg-br*
A bonded machine look as below:
[root@localhost ~]# ls /etc/sysconfig/network-scripts/
ifcfg-bond0 ifcfg-eth3 ifdown-bnep ifdown-post ifup ifup-ipv6 ifup-ppp init.ipv6-global
ifcfg-br0 ifcfg-eth4 ifdown-eth ifdown-ppp ifup-aliases ifup-isdn ifup-routes net.hotplug
ifcfg-br1 ifcfg-eth5 ifdown-ippp ifdown-routes ifup-bnep ifup-plip ifup-sit network-functions
ifcfg-eth0 ifcfg-lo ifdown-ipv6 ifdown-sit ifup-eth ifup-plusb ifup-tunnel network-functions-ipv6
ifcfg-eth1 ifdown ifdown-isdn ifdown-tunnel ifup-ippp ifup-post ifup-wireless
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
BRIDGE=br1
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE="br1"
BOOTPROTO=none
NM_CONTROLLED="yes"
ONBOOT=yes
IPADDR=192.168.110.32
NETMASK=255.255.255.0
GATEWAY=192.168.110.1
DEFROUTE=yes
TYPE=Bridge
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth3
DEVICE=eth3
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth5
DEVICE=eth5
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet
[root@localhost ~]# cat /etc/modprobe.d/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=6
[root@localhost ~]# grep -r "bond0" /etc
/etc/modprobe.d/modprobe.conf:alias bond0 bonding
/etc/modprobe.d/modprobe.conf:options bond0 miimon=100 mode=6
/etc/sysconfig/network-scripts/ifcfg-eth5:MASTER=bond0
/etc/sysconfig/network-scripts/ifcfg-bond0:DEVICE=bond0
/etc/sysconfig/network-scripts/ifcfg-eth3:MASTER=bond0
[root@localhost ~]#
参考:
- RHEL6双网卡绑定
- linux系统双网卡绑定详细配置
- CentOS5.5 双网卡绑定
- Linux双网卡绑定实现负载均衡(Bonding双网卡绑定)
- shell脚本自动配置双网卡绑定
- What is the correct way to setup a bonded bridge on Centos 6 for KVM guests?