xen虚拟化实战系列文章列表
xen虚拟化实战系列(一)之xen虚拟化环境安装
xen虚拟化实战系列(二)之xen虚拟机安装
xen虚拟化实战系列(三)之xen虚拟机复制
xen虚拟化实战系列(四)之xen虚拟机扩展磁盘空间一法
xen虚拟化实战系列(五)之xen虚拟机扩展磁盘空间再一法
xen虚拟化实战系列(六)之xen虚拟机破解密码
xen虚拟化实战系列(七)之xen虚拟机VNC访问配置
xen虚拟化实战系列(八)之xen虚拟机开机自启动配置
xen虚拟化实战系列(九)之xen虚拟机时间配置
xen虚拟化实战系列(十)之xen虚拟机双网卡配置
xen虚拟化实战系列(十一)之xen虚拟机磁盘文件挂载
xen虚拟化实战系列(十二)之xen虚拟机高可用之在线迁移
xen虚拟化实战系列(十三)之xen虚拟机集中管理之convirt
现在通常服务器最基本也配置了双网卡,服务器在上应用的时候通常这么设计,一个网卡分配业务应用网段,接收用户访问,一个网卡连接内部网段,连接数据库或NFS共享等类似应用,这样一来可以充分利用网卡带宽,提高网络效率。本文出自:http://koumm.blog.51cto.com
本文只是做了一个示例:
配置思路:
(1) 物理机双网卡,xen虚拟化平台也配置成双网桥。
(2) xen虚拟机也添加双网卡,分别桥网两个网卡,配置不同网段IP,内部网段可以不用配置网关。
1. 配置eth1网卡的IP地址
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
并启动网卡:
# ifdown eth1 关闭网卡
# ifup eth1 启动网卡
# cp /etc/xen/scripts/network-bridge /etc/xen/scripts/network-bridge.xen
# vi /etc/xen/xend-config.sxp
#(network-script network-bridge) 注释掉这行,添加如下一行
(network-script network-xen-multi-bridge)
# 创建另一个xenbr1配置脚本文件
# cd /etc/xen
# vi network-xen-multi-bridge #!/bin/sh # network-xen-multi-bridge # Exit if anything goes wrong. set -e # First arg is the operation. OP=$1 shift script=/etc/xen/scripts/network-bridge.xen case ${OP} in start) $script start vifnum=1 bridge=xenbr1 netdev=eth1 $script start vifnum=0 bridge=xenbr0 netdev=eth0 ;; stop) $script stop vifnum=1 bridge=xenbr1 netdev=eth1 $script stop vifnum=0 bridge=xenbr0 netdev=eth0 ;; status) $script status vifnum=1 bridge=xenbr1 netdev=eth1 $script status vifnum=0 bridge=xenbr0 netdev=eth0 ;; *) echo 'Unknown command: ' ${OP} echo 'Valid commands are: start, stop, status' exit 1 esac
# chmod +x network-xen-multi-bridge
手动执行创建虚拟网桥脚本
# /etc/xen/scripts/network-bridge.xen start vifnum=1 bridge=xenbr1 netdev=eth1
# 重启服务器
[root@node1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:F0:01:51 inet addr:192.168.233.150 Bcast:192.168.233.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:35 errors:0 dropped:0 overruns:0 frame:0 TX packets:46 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5614 (5.4 KiB) TX bytes:7879 (7.6 KiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:F0:01:5B inet addr:10.10.10.10 Bcast:10.10.10.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:18 errors:0 dropped:0 overruns:0 frame:0 TX packets:14 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3671 (3.5 KiB) TX bytes:3325 (3.2 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1664 errors:0 dropped:0 overruns:0 frame:0 TX packets:1664 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4532496 (4.3 MiB) TX bytes:4532496 (4.3 MiB) peth0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:59 errors:0 dropped:0 overruns:0 frame:0 TX packets:70 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:9967 (9.7 KiB) TX bytes:11564 (11.2 KiB) peth1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:89 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14686 (14.3 KiB) TX bytes:6534 (6.3 KiB) vif0.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:47 errors:0 dropped:0 overruns:0 frame:0 TX packets:35 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:8033 (7.8 KiB) TX bytes:5614 (5.4 KiB) vif0.1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:14 errors:0 dropped:0 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3325 (3.2 KiB) TX bytes:3671 (3.5 KiB) virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:14 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:3053 (2.9 KiB) xenbr0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:25 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5401 (5.2 KiB) TX bytes:0 (0.0 b) xenbr1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 RX packets:30 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:6468 (6.3 KiB) TX bytes:0 (0.0 b)
(1) 关闭xen虚拟机
# xm shutdown test01
(2) 修改xen虚拟配置文件
xen虚拟机通常也只有一个网卡,再加一网卡需要修改配置文件。
# vif = [ "mac=00:16:3e:27:ec:b9,bridge=xenbr0", "mac=00:16:3e:1a:00:01,ip=10.10.10.11,bridge=xenbr1" ]
(3) 启动xen虚拟机自动适应硬件配置
# xm create test01
修改eth1网卡IP地址,没有配置文件的话,可以直接复制eth0,修改上面的MAC地址,修改IP地址。
# vi /etc/sysconfig/network-script/ifcfg-eth1
本文只配置了一台xen服务器的网卡改造,另一台也按相同的方式进行配置。
至此,xen服务器双网卡配置完毕,有相同需求的情况可以按以上方式配置改造。