Xen虚拟机迁移和扩容

首先安装好系统CentOS系统,宿主机只安装base的基本包,然后用yum安装常见的xen,kernel-xen软件。

Xen虚拟机迁移和扩容

2.xen软件安装好之后检查一下/etc/grub.conf文件设置启动选项为后缀为xen 的内核,最后reboot重新启动。

3.系统启动好之后查看宿主机信息

[root@localhost ~]# xm li //xm  list显示domain 0的信息。
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0      282     1 r-----    804.7

4.ifconfig -a查看桥和虚拟网卡

xen的网络桥接模式的工作流程,现翻译在下面以备后面之需。

When xend is started, with the default configuration (in /etc/xen/xend-config.sxp), it'll execute /etc/xen/scripts/network-bridge to re-configure your networking.

当xend这个进程被开启之后,进程会根据默认的配置文件/etc/xen/xend-config.sxp里的内容,让/etc/xen/scripts/network-bridge这个脚本发挥工作,重新来配置你的网络。

It'll rename the physical eth0 interface to peth0, change it's MAC address to FE:FF:FF:FF:FF:FF, and then create a virtual ethernet interface called eth0, configure it with the real MAC address, and bridge both of those interfaces to xenbr0 bridge.

它会将你的eth0重命名为peth0,把eth0的MAC值改为FE:FF:FF:FF:FF:FF。然后再重新创建一个虚拟的网络接口,将它命名为eth0,配置它让它有物理上的MAC地址,然后把peth0跟eth0这两个接口跟xenbr0做一个桥接。

This way the virtual eth0 interface should have a real MAC, and it can be used for dom0 management, and at the same time allow other VMs/domUs to share the physical ethernet interface by using xenbr0 bridge.

所以说,按这种方式虚拟出来的eth0这个接口会有物理上的MAC值,在domain0中发挥上网的功用,同时它也允许domainU通过xenbr0这个桥接接口跟domain0合用物理网络接口。

[root@localhost ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.000000000000       yes
xenbr0          8000.feffffffffff       no              vif3.0
                                                        vif0.0
                                                        peth0

[root@localhost ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:15:56:F2 
          inet addr:192.168.40.232  Bcast:192.168.40.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:45498 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13674 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:19669317 (18.7 MiB)  TX bytes:1924647 (1.8 MiB)

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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:100 (100.0 b)  TX bytes:100 (100.0 b)

peth0     Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:324838 errors:2 dropped:2 overruns:0 frame:0
          TX packets:118994 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:402460402 (383.8 MiB)  TX bytes:9313197 (8.8 MiB)
          Interrupt:18 Base address:0x2000

veth1     Link encap:Ethernet  HWaddr 00:00:00:00:00:00 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 b)  TX bytes:0 (0.0 b)

veth2     Link encap:Ethernet  HWaddr 00:00:00:00:00:00 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 b)  TX bytes:0 (0.0 b)

veth3     Link encap:Ethernet  HWaddr 00:00:00:00:00:00 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 b)  TX bytes:0 (0.0 b)

vif0.0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:13719 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45546 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1931157 (1.8 MiB)  TX bytes:19672872 (18.7 MiB)

vif0.1    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 b)  TX bytes:0 (0.0 b)

vif0.2    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 b)  TX bytes:0 (0.0 b)

vif0.3    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 b)  TX bytes:0 (0.0 b)

vif3.0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:314 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1649 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:23922 (23.3 KiB)  TX bytes:434040 (423.8 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:3137 (3.0 KiB)

xenbr0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:26586 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:6736372 (6.4 MiB)  TX bytes:0 (0.0 b)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3264e30a3a20232f6155fce4ea9b7756.html