Monday, June 13, 2011

Notes on Innodb code

I am recently reading the code of Innodb. A lot of things are new for me. So it is a good idea to write down what I can understand from the code. Many basic knowledges of database management systems can be learned from below two books. So I am reading the books with the code together.
"Database Systems: The Complete Book (2nd Edition) "
"Transaction Processing: Concepts and Techniques"

The key functions of Innodb include:
- Transaction Management
- Lock Management
- Data Format
- Buffer Pool
- I/O Control
- Thread Control

Wednesday, December 8, 2010

Install BT4-rc2 on KVM+Virtio

Recently, I tried to migrate my virtual machines KVM.  I tried to install BT4-rc2 on KVM as soon as I got it.  I first set the disk type IDE, but I found it was very slow to install BT4-rc2 in the virtual disk.  So I changed the virtual disk's type to virtio.  I finally could run it after a few hours struggle.

Here is a brief summary.
* Boot from BT4-rc2.iso.
* Compile and load virtio modules.
* Install BT4-rc2.
* Make new initrd file
* Copy virtio modules and initrd file to the target disk.

** Compile and load virtio modules
   virtio modules are not included in BT4-rc2's kernel.  So the installation program could not find the virtio disk /dev/vda.  For supporting virtio disk, I compiled and loaded virtio modules.
   > cd /usr/src/linux

   --- Config Virtio Modules ---
   > make menuconfig
     Mark all virtio modules, they are in
     ->Virtualization                (Basic Modules of Virtio)
     ->Device Drivers->Block Drivers (Virtio Disk Driver)
     ->Device Drivers->Net Drivers   (Virtio Net Driver)

   --- Compile Basic Virtio Modules ---
    > make SUBDIRS=drivers/virtio modules
    > mkdir drivers/net/virtio

   --- Compile Virtio Net Module ---
    > mkdir drivers/net/virtio
    > cat drivers/net/Makefile|grep virt> drivers/net/virtio/Makefile
    > cp drivers/net/virtio_net.c drivers/net/virtio
    > make SUBDIRS=drivers/net/virtio modules

   --- Compile Virtio Block Module ---
    > mkdir dirvers/block/virtio
    > cat drivers/block/Makefile |grep virt> drivers/block/virtio/Makefile
    > cp drivers/block/virtio_blk.c drivers/net/virtio
    > make SUBDIRS=drivers/block/virtio modules

   --- Copy and Load Modules ---
    > mkdir /lib/modules/
    > cp drivers/virtio/*.ko /lib/modules/
    > cp drivers/net/virtio/*.ko /lib/modules/
    > cp drivers/block/virtio/*.ko /lib/modules/
    > depmod -ae
    > modprobe virtio_blk
    > modprobe virtio_pci

** Make new initrd file
   > mkinitramfs -o /tmp/initrd.img-

** Copy to target
   Copy virtio modules and initrd file to target disk after BT4-rc2 has been installed.
   > mount /dev/vda1 /mnt
   Replace vda1 by the partition in which BT4-rc2 is installed.
    > mv /mnt/boot/initrd.img- /mnt/boot/initrd.img-
    > cp /tmp/initrd.img- /mnt/boot/
    > mkdir /mnt/lib/modules/
    > cd /usr/src/linux
    > cp drivers/virtio/*.ko /mnt/lib/modules/
    > cp drivers/net/virtio/*.ko /mnt/lib/modules/
    > cp drivers/block/virtio/*.ko /mnt/lib/modules/
    > cp /lib/modules/* /mnt/lib/modules/