1. 编辑/etc/xen目录下的配置文件,如果使用2颗网卡,增加nic=2,如果使用3颗网卡,设置nic=3.
2. 修改vif=选项:
vif = [ "mac=00:16:36:04:7f:e1,bridge=xenbr0,script=vif-bridge" ]
如果添加一块网卡,则修改vif为:
vif=["mac=00:16:36:04:7f:e1,bridge=xenbr0,script=vif-bridge","mac=00:16:36:05:7f:e2,bridge=xenbr0,script=vif-bridge" ]
当然还可以继续增加:
vif=["mac=00:16:36:04:7f:e1,bridge=xenbr0,script=vif-bridge","mac=00:16:36:05:7f:e2,bridge=xenbr0,script=vif-bridge", "mac=00:16:37:05:8f:e3,bridge=xenbr0,script=vif-bridge" ]
如果是完全虚拟化客户机,配置应该是下面的样子:
vif = [ 'type=ioemu,mac=xx:xx:xx:xx:xx:xx, bridge=xenbr0', 'type=ioemu,mac=xx:xx:xx:xx:xx:xx:xx, bridge=xenbr0', 'type=ioemu,mac=xx:xx:xx:xx:xx:xx, bridge=xenbr0' ]
Xen当前限制一台客户机只能创建3颗虚拟网卡,因此在客户机上不可能创建大于3颗网卡。
3. 重启虚拟机
xm shutdown domainname
xm create domainname
============================================================================
Xen虚拟环境默认只会创建一个桥接网络,设备xenbr0桥接eth0,在此基础上创建两个新的桥接网络,设备xenbr1和xenbr2分别桥接到eth1和eth2网络设备,xenbr0用于虚拟机中的公共网络,xenbr1用于私有网络,xenbr2用于存储网络,下面是创建三个桥接网络设备的步骤。
步骤1 编辑/etc/xen/xend-config.sxp文件,在相应的地方加入以下内容:
#(network-script network-bridge)
(network-script network-multi-bridge)
步骤2 创建/etc/xen/scripts/network-multi-bridge文件,加入如下内容:
#!/bin/sh
dir=$(dirname "$0")
"$dir/network-bridge" "$@" vifnum=0 bridge=xenbr0 netdev=eth0
"$dir/network-bridge" "$@" vifnum=1 bridge=xenbr1 netdev=eth1
"$dir/network-bridge" "$@" vifnum=2 bridge=xenbr2 netdev=eth2
步骤3 修改network-multi-bridge文件权限:
chmod 755 /etc/xen/scripts/network-multi-bridge
步骤4 重启xend服务:
service xend restart
私有网络和存储网络也可以使用Xen虚拟机中的内部网络,使用桥接网络的最大优势在于可以将不同物理服务器的Xen虚拟机融合成一个RAC集群
cat network-custom
#!/bin/bash
# network-xen-custom
# Exit if anything goes wrong
set -e
# First arg is operation.
OP=$1
#shift
script=/etc/xen/scripts/network-bridge
case ${OP} in
start)
$script start vifnum=0 bridge=xenbr0 netdev=eth0
$script start vifnum=1 bridge=xenbr1 netdev=eth1
$script start vifnum=2 bridge=xenbr2 netdev=eth2
$script start vifnum=3 bridge=xenbr3 netdev=eth3
;;
stop)
$script stop vifnum=0 bridge=xenbr0 netdev=eth0
$script stop vifnum=1 bridge=xenbr1 netdev=eth1
$script stop vifnum=2 bridge=xenbr2 netdev=eth2
$script stop vifnum=3 bridge=xenbr3 netdev=eth3
br1 netdev=eth1
;;
status)
$script status vifnum=0 bridge=xenbr0 netdev=eth0
$script status vifnum=1 bridge=xenbr1 netdev=eth1
$script status vifnum=2 bridge=xenbr2 netdev=eth2
$script status vifnum=3 bridge=xenbr3 netdev=eth3
;;
*)
echo "Unknown command:${OP}"
echo 'Valid commands are: start, stop, status'
exit 1
;;
esac