XEN Notes
Saturday, 28 March 2009
Building VM's with XEN on my server, example commands below...
XEN Commands
start
xm create /etc/xen/xen01.mybox.com.cfg
start on boot
ln -s /etc/xen/xen01.mybox.com.cfg /etc/xen/auto --force
list running xen machines (dom0 is host)
xm list
list all virtual images created by xen-create-image
xen-list-images
shutdown
xm shutdown xen01.mybox.com
shutdown immediately (as if you pulled the plug out)
xm destroy xen01.mybox.com
login
xm console xen01.mybox.com
to log in on that virtual machine (type CTRL+] if you are at the console,
or CTRL+5 if you're using PuTTY to go back to dom0),
or use an SSH client to connect to it (192.168.1.2).
ctrl+] to get back to host
show kernel
file /bin/ls
help
xm help
XEN VM Creation Examples
xen-create-image --hostname=xen01.mybox.com --size=10Gb --noswap --ip=192.168.1.2 --memory=256Mb --arch=i386 --role=udev
(debian lenny, 10gb hdd, no swap, 256mb ram, 32-bit kernel)
xen-create-image --hostname=xen01.mybox.com --size=10Gb --swap=128Mb --ip=192.168.1.2 --memory=256Mb --arch=amd64 --role=udev
(debian lenny, 10gb hdd, 128mb swap, 256mb ram, 64-bit kernel)
xen-create-image --hostname=xen01.mybox.com --size=10Gb --noswap --ip=192.168.1.2 --memory=256Mb --arch=i386 --dist fedora-core-8 --install-method rinse --role=udev
(fedora core 8, 10gb hdd, no swap, 256mb ram, 32-bit kernel)
XEN Customizations
Make VM use both processor cores...
nano /etc/xen/xen01.mybox.com.cfg
...and add this to the config
vcpus = '2'
Store vm's in /home/xen
mkdir /home/xen
nano /etc/xen-tools/xen-tools.conf
...find dir = ...
...and change to
dir = /home/xen
Installing XEN on Debian Lenny
Monday, 23 March 2009
Really needed to virtualize the server as I can't waste all those resources, so first tried vmware which was ok but I'm not that big a fan; I really wanted to go the XEN route.
So, after some experimenting with a dev machine I finally bit the bullet & installed it.
Check Support
The server processor is an AMD with an ASUS board, so first check you can support virtualization
grep "vmx" /proc/cpuinfo
For AMD, look for SVM, for Intel look for VMX.
Install Xen
Next install xen, 'from here on in, it gets scary fast'
aptitude install xen-linux-system-2.6.26-1-xen-amd64 xen-utils-3.2-1 xenstore-utils xenwatch xen-shell xen-tools
Setup
You're not out of the woods yet, edit /etc/modules if you're after image-based virtual machines; skip otherwise.
nano /etc/modules
...change
loop
...to
loop max_loop=64
Save then edit /etc/xen/xend-config.sxp
nano /etc/xen/xend-config.sxp
- Find (network-script network-bridge) and uncomment
- Make sure (network-script network-dummy) is commented
- Make sure (vif-script vif-bridge) is uncommented
e.g.
(network-script network-bridge)
#(network-script network-dummy)
(vif-script vif-bridge)
Checking
Now reboot
reboot
And check which o/s you've got
uname -r
Mine returns...
2.6.26-1-xen-amd64
more here
MAMP + Symfony
Sunday, 21 December 2008

Playing around with the Symfony framework for an interesting idea I have, sort of a Google Maps mashup.
Anyway, on OSX Leopard I'm using MAMP to handle the lamp environment and so need to supplement it's support with Symfony; which isn't too big a challenge to add.
Install MAMP on Leopard
First off download MAMP free here it's a 130mb download so you'll have to wait a while on a slow connection (we've got fibre so it's super quick). Once downloaded open & drag the MAMP folder into your Applications directory.
Next run up the MAMP application from within your /Applications/MAMP dir, this should give you MySQL running with these settings,
...location
Host: localhost
[Port: 8889]
User: root
Password: root
...via php
$link = mysql_connect('localhost', 'root', 'root');
...via sockets
Socket: /Applications/MAMP/tmp/mysql/mysql.sock
User: root
Password: root
...via php + sockets
$link = mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'root');
Add to PATH
Next using Terminal, add your PHP directory to your path by adding it to your .bash_profile file (need to reopen Terminal to read the new variable)
mate .bash_profile
Add this to the end of the file & save it,
export PATH=$PATH:/Applications/MAMP/bin/php5/bin
Check you've got PHP5 up and running by typing this at the Terminal, you should see PHP 5.2,
php -v
Install Symfony
Run these commands thru Terminal to install the Symfony framework into your PHP install,
/Applications/MAMP/bin/php5/bin/peardev channel-discover pear.symfony-project.com
/Applications/MAMP/bin/php5/bin/peardev install symfony/symfony
Now check you've got Symfony installed by typing this into the Terminal,
symfony -V
Next grab the Sandbox application to start with via here and extract it into the default root dir of your PHP install; being MAMP this will be:
/Applications/MAMP/htdocs
Afterwhich via your web browser you should be able to test the sandbox app at:
http://localhost:8888/sf_sandbox/web/frontend_dev.php/
Create your First Project
The Symfony framework provides an excellent starter for your application, with the data, app code, cache and logs all stored within a design much like Rails and it's MVC pattern so you can get up & running fast.
So to create your application do,
mkdir ~/myproject
cd ~/myproject
symfony init-project myproject
Note the symfony command must be run within the directory you want your app put together so create a directory for it first, move into it then run the line above.
And within MAMP,
mkdir /Applications/MAMP/htdocs/myproject
cd /Applications/MAMP/htdocs/myproject
symfony init-project myproject
Add your Application
Now you won't able to see anything until you've created your first app within myproject via,
symfony init-app myapp
This will create some files to get you up & started along with a simple index.php file within the /web dir to show things went ok,
http://localhost:8888/myproject/web/index.php
You'll probably get a message saying it can't find your application's web/sf directory for the images, as you've already got the sandbox app installed, copy it from there.
cp -R /Applications/MAMP/htdocs/sf_sandbox/web/sf /Applications/MAMP/htdocs/myproject/web/sf
Or from your original PEAR install,
cp -R /Applications/MAMP/bin/php5/lib/php/data/symfony/web/sf /Applications/MAMP/htdocs/myproject/web/sf
Your project should be much happier now.
Obviously you shouldn't be sticking your projects entire framework inside your /htdocs directory for production as it'll make the whole thing visible to the outside world but for this simple example it'll do for now.
But if you really want to you can edit your Apache's document root directory via the Apache config file:
mate /Applications/MAMP/conf/apache/httpd.conf
And change,
DocumentRoot "/Applications/MAMP/htdocs"
...to
DocumentRoot "/Applications/MAMP/htdocs/myproject/web"
Simple for now but you can expand on it later with virtual server configs and the like later.
More on this via Symfony's official documentation here
MATE ?
...please note i've got TextMate installed along with the path integration so I can access it via Terminal with mate so if you don't have TextMate, substitute mate for nano or vi if you're old-school ;-)
Log Maintenance (SQL SERVER)
Wednesday, 19 November 2008
Over time your SQL Server transaction log will fill up and if you don't watch it it'll consume all your server's disk space.
So to cure that problem it's best adding a weekly job to SQL Agent with these commands
Truncate log...
USE [databasename]
GO
BACKUP LOG databasename WITH TRUNCATE_ONLY
GO
Shrink database...
USE [databasename]
GO
DBCC SHRINKDATABASE(N'databasename' )
GO
(truncating only clears the logfile, to reclaim that space you have to shrink the database)
Important!
Do remember to schedule a full database backup before this so you don't lose any important transactions; critical in a live environment.
Installing VMWare Server on Ubuntu
Tuesday, 23 September 2008
First install the pre-requisites;
sudo aptitude install linux-headers-`uname -r` build-essential
sudo aptitude install xinetd
Download VMWare Server .tar.gz file from here.
Remember to signup for a Serial Number, you'll need that during the install
Download the latest vmware-any-any-update patch here,
Now extract VMWare Server and terminal into it's directory, run,
cd vmware-server-distrib
sudo perl vmware-install.pl
When asked Before running VMware Server for the first time, you need to configure it by invoking the following command: "/usr/bin/vmware-config.pl". Do you want this program to invoke the command for you now? [yes] enter NO and patch VMWare with that file.
Extract the files within that patch and Terminal into it's directory,
cd vmware-any-any-update115
sudo ./runme.pl
It should prompt you to run vmware-config.pl, this time say YES and continue with the install.
Afterwards start vmware with,
vmware
You might get a load of errors like this,If you get compile errors, do this;
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib32/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib32/libstdc++.so.6)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib32/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib32/libstdc++.so.6)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib32/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib32/libstdc++.so.6)
That's because one part of the vmware package was compiled with a different version of gcc than the one you're running now, to fix that do:
sudo cp /lib/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1/
sudo cp /usr/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0/
Now you should be able to start VMWare Server
(tested and working on Ubuntu Hardy 8.04 64-bit)
Tomorrow...
Saturday, 02 August 2008

Well after a lot of research and hard work the server's ready to drop off at colocation. There's still some grey areas but in all everything looks ready to go, better off there and running than sitting it home waiting.
So tomorrow I'll be driving down to RapidSwitch in Slough to drop it off, after which Michelle wants us to visit her grandparents who live in Farnborough; not far off from the facility.
Here's a quick rundown of the spec:
- O/S: Debian Etch 4.0 64-bit
- HDD: Software RAID 1 - 1TB
- MEMORY: 4GB Corsair
- CPU: AMD AM2 2+ghz
- BANDWIDTH: 3TB per month
Bit of a step up from the virtual server environment I get from SliceHost, but fingers crossed it should all go fine; had so much fun putting it together already planning the next incarnation ;-)
P.S.
Dark Knight is really really good, Heath Ledger has pulled off such a believable and terrifying character; have to see it again.
Update
Just got back from her grandparents; boy do they know how to cook a sunday lunch, lovely couple.
Server's online, it's stopped resyncing the raid drives thankfully, was a little worried about that but everythings loaded running and operating well.
Cat sitting next weekend, let's hope mickey isn't in one of his moods ;-)
All the best, have a great week people.









