Difference between revisions of "Xen"

From Tardis
Jump to: navigation, search
(Big changes for wotan.)
m (Work in progress save for new Xen docs)
Line 1: Line 1:
 +
''Work in progress. -- Thom 17/12/09''
 +
 
== Overview ==
 
== Overview ==
  
* We currently have a single Xen host: [[WOTAN]].  It replaced the previous Xen hosts as it has more of everything (disks, CPUs, RAM, PSUs).
+
* We currently have two Xen hosts: [[WOTAN]] and [[Oracle]].  
* We run i386 Xen 3.0.3 with PAE (as packaged in Debian etch).
 
* We use LVM to create volumes for each domU's root and swap partitions.
 
* We have a homebrew [http://jp-hosting.net/mkdomU.bash.html script] to create the LV and use debootstrap to install the OS.
 
  
== How to Add New Instances ==
+
== Creating new Xen instances ==
 +
  
The VM creation script gets the new system's IP address from DNS so the first job is to see the [[DNS_Service]] page for details on how to set up a new entry for your system.
+
==== Naming your host ====
 +
* Think of a name. We like Dr Who themed names! If you recycle a name you'll probably upset Thom -- why not ask Malcolm for advice?
 +
* At this point you should also create a wiki page explaining your VMs purpose and config. Use one of the other Xen machine's pages as a starting point.
 +
* Find a free IP and add forward and reverse mappings to the [[DNS_Service|DNS]].
  
Login to wotan, which is the main xen machine. Use the mkdomU.bash script to create the new instance like so:
+
==== Find a Xen host ====
 
+
* Our main constraints on Xen hosts are RAM and disk space.
<pre>
+
* Use <tt>vgs</tt> to show free disk space in the volume group
mkdomU.bash -vh <newmachinename>
+
* Check amount of RAM allocated to dom0 in <tt>xentop</tt> for a poor estimation of potentially free RAM.
</pre>
+
 +
==== Create disk volumes ====
 +
 
 +
* Create root volume: <tt>lvcreate -l 4GB -n &lt;hostname&gt;-root &lt;volume-group&gt;</tt>
 +
** 2GB is just about enough for a Debian install.
 +
** You can find out the volume group name with <tt>vgs</tt>
 +
* Create swap volume: <tt>lvcreate -l 256MB -n &lt;hostname&gt;-swap &lt;volume-group&gt;</tt>
 +
** Use your favourite rule of thumb for guessing a completely arbitrary quantity of swap space to allocate. If your machine starts thrashing you'll probably upset someone, so it's better off being small.
 +
* Create root filesystem: <tt>mke2fs -j /dev/&lt;volume-group&gt;/&lt;hostname&gt;-root</tt>
 +
* Create swap filesystem: <tt>mkswap /dev/&lt;volume-group&gt;/&lt;hostname&gt;-swap</tt>
  
Say yes to shadow passwords, type in root password (twice), say no to creating a user account.
+
==== Create Xen configuration file ====
  
If you want to do something complicated, have a look at /etc/mkdomU.conf, or at the script at /usr/local/bin/mkdomU.bash .
 
  
Don't forget to unmount the domU filesystem!
+
==== Run Debian installer ====
  
<pre>
 
umount /mnt/mkdomU
 
</pre>
 
  
Run
+
==== Booting your instance ====
  
 
<pre>
 
<pre>
Line 32: Line 40:
 
</pre>
 
</pre>
  
to get the instance up and running. You should be able to log in.  Use ctrl+] to get back to vislor's console.
+
to get the instance up and running. You should be able to log in.  Use ctrl+] to get back to the Xen host console.
  
 
== Booting and Shutting Down ==
 
== Booting and Shutting Down ==

Revision as of 20:24, 17 December 2009

Work in progress. -- Thom 17/12/09

Overview

Creating new Xen instances

Naming your host

  • Think of a name. We like Dr Who themed names! If you recycle a name you'll probably upset Thom -- why not ask Malcolm for advice?
  • At this point you should also create a wiki page explaining your VMs purpose and config. Use one of the other Xen machine's pages as a starting point.
  • Find a free IP and add forward and reverse mappings to the DNS.

Find a Xen host

  • Our main constraints on Xen hosts are RAM and disk space.
  • Use vgs to show free disk space in the volume group
  • Check amount of RAM allocated to dom0 in xentop for a poor estimation of potentially free RAM.

Create disk volumes

  • Create root volume: lvcreate -l 4GB -n <hostname>-root <volume-group>
    • 2GB is just about enough for a Debian install.
    • You can find out the volume group name with vgs
  • Create swap volume: lvcreate -l 256MB -n <hostname>-swap <volume-group>
    • Use your favourite rule of thumb for guessing a completely arbitrary quantity of swap space to allocate. If your machine starts thrashing you'll probably upset someone, so it's better off being small.
  • Create root filesystem: mke2fs -j /dev/<volume-group>/<hostname>-root
  • Create swap filesystem: mkswap /dev/<volume-group>/<hostname>-swap

Create Xen configuration file

Run Debian installer

Booting your instance

xm create -c <newmachinename>.conf

to get the instance up and running. You should be able to log in. Use ctrl+] to get back to the Xen host console.

Booting and Shutting Down

Xen's init scripts are set up to perform an `xm save` (copy the RAM to disk) for each domU that's running when vislor and/or adric are shut down and to restore saved domUs on boot. This should take care of the cases where tardis is shut down intentionally, but a bit more work will have to be done following an unexpected power loss. (When do they happen anyway? ;-)

To start all domUs on vislor do:

for foo in /etc/xen/*.conf; do xm create -c $foo; done
<WAIT FOR A LOGIN PROMPT>
ctrl+]
<WAIT FOR A LOGIN PROMPT>
ctrl+]
....