wiki:GTD_Cloud_xen_ubuntu

Version 7 (modified by rock, 16 years ago) (diff)

--

Install Xen-3.1.3 on ubuntu Server 8.04 (AMD64)

0.Software Information

1.Requirement packages

sudo aptitude install build-essential libncurses5-dev kernel-package iproute bridge-utils \
python-twisted gcc binutils make zlib1g-dev python-dev transfig bzip2 screen ssh debootstrap \ 
libcurl3-dev libncurses5-dev x-dev libsdl1.2-dev bin86 bcc python-pam patch latex-make \ 
qemu qemu-launcher qemuctl graphviz graphviz-dev lvm2 libvncserver-dev libjpeg62-dev libjpeg62 \
 gettext python-xml gawk tetex-extra tetex-base openssl libssl-dev mercurial quilt libc6-dev-i386


2. Install Xen-3.1.3

  • Xen-3.1.3
  • Xen-3.1.4
    $ cd /usr/src ; wget http://bits.xensource.com/oss-xen/release/3.1.3/xen-3.1.3.tar.gz
    $ tar zxvf xen-3.1.3.tar.gz
    $ cd xen-3.1.3
    $ make -j 4 world
    $ make install
    $ mkinitramfs -o /boot/initrd.img-2.6.18.8-xen 2.6.18.8-xen
    $ update-grub
    
    ###  If your loop is build-in kernel ###
    $ vim /boot/grub/menu.lst
    netloop.nloopbacks=200
    


3. Install xen-tools

  • xen-tools
    $ wget http://www.xen-tools.org/software/xen-tools/xen-tools-3.9.tar.gz
    $ tar xen-tools-3.9.tar.gz
    $ cd xen-tools-3.9 ; make install
    
    ###  Edit xen-tools config ###
    $ vim /etc/xen-tools/xen-tools.conf
    


4. Test Xen

###  Edit xen config for you demand  ###
$ vim /etc/xen/xend-config.sxp
(network-script 'network-bridge netdev=eth0')

###  Startup Xen  ###
$ xend start

###  Check Xen  ###
$ ifconfig
$ less /var/log/xen/xend.log
$ less /var/log/xen/xend-debug.log
//If xend and xen networking can normal startuped, you can go to next step. 
//If you meet problem, check your xen config, network, loop device and log message.

###  Create VM  ###
$ xen-create-image --hostname vm01 --ip 140.110.X.X

###  Booting VM01  ###
$ cd /etc/xen
$ xm create vm01.cfg -c
$ route add default gw 140.110.X.X
$ ping ptt.cc
//If vm01 can normal booting! God job!

5. Problem

1.Xen 3.1.4 的 網路問題

$ ifconfig
vif1.0    Link encap:Ethernet  HWaddr fe:ff:ff:ff:ff:ff  
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:37 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:1 overruns:0 carrier:0
          collisions:0 txqueuelen:32
          RX bytes:1252 (1.2 KB)  TX bytes:140 (140.0 B)

xenbr100  Link encap:Ethernet  HWaddr fe:ff:ff:ff:ff:ff  
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:37 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:1252 (1.2 KB)  TX bytes:0 (0.0 B)

$ brctl show
bridge name    bridge id        STP enabled    interfaces
xenbr100        8000.feffffffffff    no        vif1.0

解決方法:需設定netdev=eth0

$ vim /etc/xen/xend-config.sxp
(network-script 'network-bridge netdev=eth0')

$ ifconfig
vif0.100  Link encap:Ethernet  HWaddr fe:ff:ff:ff:ff:ff  
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:178 errors:0 dropped:0 overruns:0 frame:0
          TX packets:369 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:34300 (33.4 KB)  TX bytes:30167 (29.4 KB)

xenbr100  Link encap:Ethernet  HWaddr fe:ff:ff:ff:ff:ff  
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:146 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:9545 (9.3 KB)  TX bytes:0 (0.0 B)

$ brctl show
bridge name    bridge id            STP enabled    interfaces
xenbr100        8000.feffffffffff    no                vif0.100
                                                                peth0
                
$ xm create vm01.cfg -c
$ route add default gw 140.110.138.254

ctrl+]

$ brctl show
bridge name    bridge id            STP enabled    interfaces
xenbr100        8000.feffffffffff    no                vif0.100
                                                                peth0
                                                                vif1.0
  • VM的route問題,需自行新增route rule
    $ vim /etc/rc.local
    route add default gw 140.110.X.X