Sunday, 23 May 2010

Compile and install python with mysql for users

To run custom python version for a useraccount:

download the latest version of python

$ wget http://www.python.org/ftp/python/2.6.5/Python-2.6.5.tgz
$ tar xvzf Python-2.6.5.tgz
$ cd Python-2.6.5
$ ./configure --prefix=/home/username/python-2.6.5
$ make
$ make install


Install setuptools
as root:

# ln -s /home/username/python-2.6.5/bin/python2.6 /usr/bin/ *this is required for setuptools

as normal user:

$ wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
$ tar xvzf setuptools-0.6c11.tar.gz
$ sh setuptools-0.6c11-py2.6.egg --prefix=~/python-2.6.5/


download mysql-python

$ wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz?use_mirror=citylan
$ tar xvzf MySQL-python-1.2.3c1.tar.gz
$ cd MySQL-python-1.2.3c1
$ /home/username/python-2.6.5/bin/python setup.py build
$ /home/username/python-2.6.5/bin/python setup.py install

Done:

sh-3.00$ python2.6
Python 2.6.5 (r265:79063, May 23 2010, 14:40:28)
>>> import MySQLdb
>>>

./arun

Friday, 14 May 2010

KVM image on LVM

Convert qcow2/raw images to LVM logical volume to use with KVM:

- Convert the qcow2 image to raw format (if it is in qcow2)
$ qemu-img convert image.qcow2 -O raw image.raw

- Create the physical volume for LVM
# pvcreate /dev/sdb
(replace the device with correspond to the system)

- Create the volume group
# vgcreate pool1 /dev/sdb
(replace pool1 with the name as required)

- Create Logical volume with same size as the image
# lvcreate -n justaname --size 50G pool1
(replace justaname and size as per the requirements)
Use lvresize incase you required the change the volume size

- dd the raw image to lvm logical volume
# dd if=image.raw of=/dev/pool1/justaname bs=8M
(Change the block size according to the requirements.

Edit the kvm xml configuration for the corresponding virutal machine to use the logical volume

< disk type='block' device='disk' >
< source dev='/dev/pool1/justaname'/ >
< /code >


./arun