Posts

Showing posts from 2010

Howto make your private VM Cluster, Part III

Continuing with my saga , next up is DRBD . I'm using DRBD because I also want to test it as a viable alternative for network raid . To use DRBD I first created a LVM volume to use: lvcreate -n drbd-demo -L 100M internal-hd Then I configured DRBD on both nodes, fortunately gentoo simplifies a great part of the process (you have to do this on both nodes): cd /etc cp /usr/share/doc/drbd-*/drbd.conf.bz2 . bunzip2 drbd.conf.bz2 Then I created a wwwdata resource by first configuring it (again on both nodes). This is done by creating a file /etc/drbd.d/wwwdata.res with the contents: resource wwwdata { meta-disk internal; device /dev/drbd1; syncer { verify-alg sha1; } net { allow-two-primaries; } on node1 { disk /dev/mapper/internalhd-drbd--demo; address 192.168.100.10:7789; } on node2 { disk /dev/mapper/internalhd-drbd--demo; address 192.168.100.11:7789; } } I added the drbd module

Howto make your private VM Cluster, Part II

In the previous entry I showed how to build the basic structure for your own private VM Cluster. Today I'm going to show you how to create a cluster with two VMs that provides High-Availability for a WebServer using DRBD to replicate the Web Site. First you need to create a virtual machine. I decided to create a VM with Gentoo . I will use LVM to keep the partition to use for drbd small since this is a simple test. I created a qemu-img for a base gentoo installation (my goal is to install gentoo on the VM and then reuse it as base for the other VMs). To create the image just run: qemu-img create -f qcow2 gentoo.qcow2 10G I started the VM using that image and followed Gentoo's installation guide . My partition scheme was 100Mb (boot), 512Mb (swap), 5Gb (root), rest for lvm. I used the gentoo-sources, configuring all virtio devices, drbd and the device-mapper. I configured genkernel to use lvm so it detects the lvm volumes at boot. I used grub and added all the genkern

Howto make your private VM Cluster, Part I

I wanted to make some experiments with DRBD , pacemaker and others. The goal is to test a few configurations for an high availability scenario. Since I don't want to make changes to my machine the solution is to use Virtual Machines. I decided to go all open source and use KVM . Since I want more that a single VM I decided to setup a private bridge to which all the VMs would connect. The bridge would provide DHCP and DNS services and NAT + Firewall to the internet. I use Gentoo . If you use another distribution or firewall tool you should adapt these instructions and scripts to fit your needs. First I created a script that sets up my bridge. The script is as follows (I called it setupBridge): # !/bin/ bash set -x # Setup the bridge sudo brctl addbr br0 sudo ifconfig br0 192.168.100.1 netmask 255.255.255.0 up # Launch DNS and DHCP Server on br0 sudo dnsmasq -q -a 192.168.100.1 --dhcp-range=192.168.100.50,192.168.100.150,forever --pid-file=/tmp/br0-dnsmasq.pid # Launch updated fire

Laptop Power Saving

Today I had an issue updating the kernel on my company's laptop. I ended up reconfiguring it from strach istead of doing the oldconfig option (make oldconfig didn't ask anything but the kernel hard locked on boot). I took the oportunity to try to get a more duration out of the battery. How? By consuming less power. PowerTop came in and lend a helping hand but it was not sufficient. When I enabled USB Suspend (CONFIG_USB_SUSPEND) the keyboard didn't work well. I have a keyboard, mouse and webcam connected to a hub that I use when I'm on my desk. Everything was working, power was being saving, even for the keyboard. The problem was that when the keyboard entered power saving mode and I pressed a key the first key that I pressed would be lost. The documentation talks about this issue but I didn't want to loose on the opportunity to increase my laptop's autonomy. Solution: udev to the rescue. I created a udev rule that detects the USB Keyboard (by vendor and produ

When hackers have fun!

Today I was building the RRDTool from source and I noticed the output of the configuration part was ordering a CD. config.status: executing po-directories commands config.status: creating po/POTFILES config.status: creating po/Makefile config.status: executing default commands checking in... and out again ordering CD from http://tobi.oetiker.ch/wish .... just kidding ;-) ---------------------------------------------------------------- Config is DONE! This shows that hackers love to play ;-)

A new Laptop

I just got a bran new Sony Vaio VPCF11Z1E as part of a compensation of making the b2b web site for my family's company. It comes preloaded with Windows 7 that I intend to leave there just in case. I'll put any special instruction on getting it running with Gentoo, my Linux distribution of choice, but first I like to talk about the hands on experience with such a computer. I decided to turn it on and let Windows 7 do its thing. After all, it has 500Gb of disk space and the goal is to replace my old broken laptop that served me for almost 10 years and that one had a 80Gb hard disk. So, if I leave windows with 100 Gb of disk space it should be more than sufficient. After turning on the PC I decided to follow the guideline and let windows and Sony's update tools run. It took an amazing 4 hours to download and install everything. I have an ADSL connection that could do 24Mbit/s but since I'm far away from the phone box it only does 8Mbit/s. What Amazed me is that just for S

GWT Part II: From Ant to Maven

In the last entry I showed how to get started with GWT and get a nicer build file with Ant. In this entry I'll explain the process of moving from Ant to Maven. My goal here is to take advantage of all of Maven's features while still maintaining a workable project configuration that I can use from a command line and from Eclipse. GWT's tools generate an Eclipse project but don't do other things like, for instance, adding dependencies to the Eclipse project when you add them to the build file. Maybe you can do this using Apache's Ivy . I haven't tried it, maybe I will someday if I end up hitting a wall using Maven... First thing to do is to rearrange our source code. Maven expects things to be on different paths and we will have to do that. I started by moving all java source code to a newly created "src/main/java". I'm using git so I just did: $ mkdir -p src/main/java $ git mv src/org src/main/java/org I had to do a similar step for the unit tests:

GWT Start-up: improving the Ant Build file

GWT Start-up: improving the Ant Build file In the past weeks I've been investigation Google's Web Toolkit . I started looking at it because I wanted a good "Web 2.0" application and JSF was cutting it. I tried using JSF and Porlets but Portlets 2.0 isn't ready for prime time yet: the JSF bridges I've tested still don't work, but that is a topic for another post. Today I want to make a fast track introduction to GWT and to summarise some of those issues and how I worked around them. For now I'll start with the basic project setup. GWT has first class support for Apache's Ant but I wanted to use Maven. Why Maven? It simply makes sense to me because of all the Project Management support it has. You can improve Ant with Ivy but for me it still feels like shell scripting in XML. If I'm going to pay the price for XML than I want something in return. There is an archetype for GWT and Maven but I simply don't like it so I decided to start with GW

Simplified Option Icon 255 on Gentoo

I have an Option Icon 255 from work to use when I'm out of the office. It is a 3G USB pen. I've used many outside scripts and graphical user interfaces but I never liked them. They crashed a lot and never seemed natural. Also I wanted a script that actually worked all the time instead of failing sometimes because it took the device a couple more seconds to register in the network. My solution: a mix of udev and shell scripts. First I made udev rules for the device. I want it to always have the same name on the /dev file system and that as soon as I connect it to the laptop it should validate the PIN and register in the network.I created a "49-hso.rules" (hso is the name of the kernel driver for the device) in the "/etc/udev/rules.d" folder as follows: ACTION!="add", GOTO="hso_end" SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Control", SYMLINK+="wctrl0" SUBSYSTEM=="tty", SUBSYST