Total Memory on a Xen Node

I ran into an interesting issue the other day that I figured I’d make a post about in order for others. Since my company is getting more into Xen Hosting, I’ve tried to be at the forefront of the virtualization software for the company. We did run into an interesting issue though the other day when it came to determining the total amount of memory on a hardware node. Since we set up the Domain-0 to use only 512MB of memory, we were having a tough time determining how much total RAM is in the server. After googling for awhile and asking some co-workers, I discovered the following command:

xm info

This command shows quite a few interesting metrics including the total memory for the server. Using this I was able to easily discern the total amount of memory and write a quick script to compute total amount of memory:

1
2
3
4
5
6
7
8
9
10
#!/bin/bash
 
total_memory=$(xm info | grep total_memory | awk '{print $3}')
remaining=$(xm info | grep free_memory | awk '{print $3 - 512}')
used_memory=$((total_memory-remaining))
 
 
echo -e 'Total Memory:\t'$total_memory'MB ('$((total_memory/1024))'GB)'
echo -e 'Memory Used:\t'$used_memory'MB ('$((used_memory/1024))'GB)'
echo -e 'Remaining:\t'$remaining'MB ('$((remaining/1024))'GB)'

Hope this helps anyone else trying to figure out accurate Xen Memory usage

Install Xen 3.4.3 on CentOS 5.x

So I have had to install Xen 3.4.3 recently 3 different times so I thought I’d make a quick post regarding the best route I have found to do this. Please note, this may not be the most optimal route but it has worked well for me 3 times now:

yum install xen PyXML mesa-libGL
yum remove xen python-virtinst libvirt-python libvirt xen-libs
mkdir rpms
cd rpms
wget http://www.gitco.de/repo/xen3.4.3/libvirt-0.7.0-6.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/libvirt-client-0.7.0-6.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/libvirt-python-0.7.0-6.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/python-virtinst-0.500.0-1.el5.noarch.rpm
wget http://www.gitco.de/repo/xen3.4.3/xen-3.4.3-1.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/xen-libs-3.4.3-1.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/glusterfs-client-2.0.8-1.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/glusterfs-common-2.0.8-1.el5.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/fuse-2.7.4-1.rf.x86_64.rpm
wget http://www.gitco.de/repo/xen3.4.3/libibverbs-1.1-1.x86_64.rpm
rpm -ivh *.rpm

After that block, make sure you edit /etc/grub.conf to set the following lines:

---snip---
default = 0
---snip---
kernel /xen.gz-3.4.3 dom0_mem=512m
---snip---

The first will set the xen kernel as the default and the second will limit dom0 to only be able to use 512m of memory, leaving the rest for your VEs. After these changes, go ahead and reboot. Let me know if this route works for you!