Inserisci Infobox

Xen

Xen virtualization

/etc/xen/xend.config
Autore: lab42 - Ultimo Aggiornamento: 2008-08-21 02:36:03 - Data di creazione: 2008-08-21 02:27:55
Tipo Infobox: PATH - Skill: 5- SENIOR

A sample xend.config file with live relocation and bridging on multiple interfaces activated.

#(logfile /var/log/xen/xend.log)
#(loglevel DEBUG)
(xend-http-server yes)
(xend-unix-server yes)
#(xend-tcp-xmlrpc-server no)
#(xend-unix-xmlrpc-server yes)
#(xend-relocation-server no)
(xend-unix-path /var/lib/xend/xend-socket)
(xend-port            8000)

# Options for enabling live-relocations (warn, no access limits defined)
(xend-relocation-port 8002)
(xend-address '')
#(xend-address localhost)
(xend-relocation-address '')
(xend-relocation-hosts-allow '')
#(xend-relocation-hosts-allow '^localhost$^localhost\\.localdomain$')

#(console-limit 1024)
# (network-script network-bridge)
# (network-script 'network-bridge netdev=eth1')
# (network-script 'network-bridge bridge=<name>')

# Options for enabling bridging on multiple physical interfaces
(network-script network-bridge-custom)
(vif-script vif-bridge)
#(network-script network-route)
#(vif-script     vif-route)
#(network-script network-nat)
#(vif-script     vif-nat)
(dom0-min-mem 256)
(dom0-cpus 0)
#(enable-dump no)
#(external-migration-tool '')
#(vnc-listen '127.0.0.1')
(vncpasswd '')



The custom script /etc/xen/scripts/network-bridge-custom for bridging on multiple interfaces can be edited according to need, can be something like:

#!/bin/bash
dir=$(dirname "$0")
"$dir/network-bridge" "$@" vifnum=0
"$dir/network-bridge" "$@" vifnum=1
"$dir/network-bridge" "$@" vifnum=2

Xen VM installation via Kickstart
Autore: lab42 - Ultimo Aggiornamento: 2008-08-21 02:23:53 - Data di creazione: 2008-08-21 02:19:24
Tipo Infobox: TIPS - Skill: 5- SENIOR

A sample /etc/xen/vmhost template file that can be used for installation via kickstart and then, after few changes, as configuration file for the newly installed Virtual Machine.

# Template XEN config for kickstarting servers
# Use this for first install ( change: name , disk location , extra (ks file))

# It is serviced from puppet, so work on a copy

# QUICK REFERENCE
# 1- COPY this file to a new one with the name of the server (es: syslog.xen )
# 2- EDIT syslog.xen: Change name , disk location , extra (ks file)
# 3- INSTALL: xm create -c syslog.xen
# 4- ADAPT configuration file:
#  - Comment Kickstart bootstrap parameters
#  - Uncomment bootloader parameter
#  - Change on_reboot option, from destroy to restart

# Kickstart bootstrap parameters
kernel = "/boot/vmlinuz-xen-install"
ramdisk = "/boot/initrd-xen-install"
extra = "text ks=http://10.100.1.51/ks/XXX.ks ksdevice=eth1"


# Activate bootloader option after first install
# bootloader="/usr/bin/pygrub"

# Xen machine configuration settings
name = "XXX"
memory = "2048"
disk = [ 'phy:/dev/san/XXX_xen,xvda,w' ]
vif = [ 'bridge=xenbr0', 'bridge=xenbr1' ]
vcpus=8


# on_reboot should be destroy on first install, and restart in normal use
on_reboot   = 'destroy'
on_crash    = 'destroy'

Using NTP with XEN
Autore: lab42 - Ultimo Aggiornamento: 2008-08-21 02:47:10 - Data di creazione: 2008-08-21 02:43:00
Tipo Infobox: TIPS - Skill: 5- SENIOR

In order to effectively use an NTP source on a Xen Virtual Machine the sysctl kernel parameter xen.independent_wallclock must be set to 1.

Local clock on a Xen Linux machine is by default in sync with the clock of the Physical Host (Dom0), in order to change it and use time syncronization services as NTP, a kernel parameter must be set on the virtual machine:
echo 1 > /proc/sys/xen/independent_wallclock

For a boot resilitent configuration in the /etc/sysctl.conf of the virtual host add:
# Set independent wall clock time
xen.independent_wallclock=1

Xen shell commands
Autore: lab42 - Ultimo Aggiornamento: 2008-08-27 14:41:24 - Data di creazione: 2008-08-21 02:55:54
Tipo Infobox: DESCRIPTION - Skill: 5- SENIOR

Some more or less commonly used shell commands for managing Xen Virtual Machines (VM, also called Domains). Tested on Xen 3.0, should work also in other versions.

Basic commands      
Show the running Virtual Machines: xm list            
Start a virtual machine (myhost):   xm create myhost            
Gracefully shutdown (soft-reset) a virtual machine:  xm shutdown myhost            
Forced power Off (hard-reset) of a virtual machine:  xm destroy myhost            
Reboot a VM : xm reboot myhost           

Using the console      
Start a virtual machine and attach immediately a console:   xm create -c myhost            
Attach to the console of a VM (sample ID=4 for myhost, as shown in xm list):          
xm console myhost  or  xm console 4           
To leave / detach from the xen console press CTRL+5           

Resources management and usage      
To alter the RAM assigned to a VM (sample 256 Mb): xm mem-set myhost 256        
To alter the CPUs assigned to a VM (sample 2 CPUs or cores): xm vcpu-set myhost 2           

Shows resource utilization of the running hosts:  xm top  or  xentop            
Shows Virtual Machines uptimes:  xm uptime          

Saving and Restoring      
Virtual Machines state can be saved on a file and later restored (sample destination file /var/tmp/myhost.save)        
xm save myhost /var/tmp/myhost.save        
Note that after this command the VM is no longer active: you can reboot from start it with xm create myhost or restore the saved machine state with xm restore  /var/tmp/myhost.save        
Note also that the save file ( /var/tmp/myhost.save ) is only the dump on the VM memory, for backups it's of no use if you copy it to another physical host without copying also the  VM config file and the file/LVM/partition used for the disk) .        

Block Devices management      
It's is possible to add block devices (disks) to a running VM:      
To add a local file ( /var/tmp/data.disk ) as /dev/xvdc to the myhost paravirtualized VM, in write mode:      
xm block-attach myhost file://var/tmp/data.disk /dev/xvdc w      
Mode can be: w (read/write), r (read only), w! (shared read/write, when the samer device is attached to two different VMs).    
The above file can be created (here 4 Gb) with:    
dd if=/dev/zero of=/var/tmp/data.disk  bs=1024k count=4096    

To add a local physical disk, partition or LVM (for example an USB stick):      
xm block-attach myhost phy://dev/sda /dev/xvdc w      
Note that I/O performances are much better when using physical devices or LVM instead of plain files as block devices for the VMs.    

To list the currently attached block devices to a VM:      
xm block-list myhost --long or xm block-list myhost       
To detach a block device (51744 is the Vdev in xm block-list)      
xm block-detach myhost 51744      
      
Bridging management      
On Linux the bridge utils can be used to show and manage bridging:            
brctl show            
brctl showmacs xenbr0            
To manually create a new xen bridge interface and associate it a physical device.            
brctl addbr xenbr2            
brctl addif peth3

Privacy Policy