Nov 28 2008

Development environment for Seaside

This is my development environment for Seaside.

One virtual machine (vm1) is for Seaside over Squeak development. I work here most time, forwarding X to my host machine and testing the application by pointing to http://vm1:8080/seaside/myapp. Details here.

The second machine (vm0) is for testing integration of my Seaside application on Gemstone/S 64. After loading my app to Gemstone I test the app by pointing to http://vm0:8080/seaside/myapp. Details here.

Finally, in my host machine I have Debian GNU/Linux 5.0 amd64 (Lenny) for my every day work (writing docs, hearing music, watching videos, browsing internet, writing blog posts, IM, etc). Also, from my host machine I can fire the stress tools to test either the load capacity or the load balancing of the application.

Advantages:

  • I start the virtual machines only when I need them.
  • My host laptop boot time it is minimal.
  • I don’t have to create a 32 bit chroot inside my laptop
  • I have a clean 32 bit Debian and a clean 64 bit Debian for other uses
  • I can test having the static content in a virtual machine and the application in other and use a proxy to redirect to the correct machine.
  • I can test having my application behind a proxy
  • I can test load balancing of my servers

Disadvantages:

  • More machines to administer
  • More configuration and setup involved
  • You need a 64 bit machine and a decent amount of RAM and a capable CPU (I have 4GB RAM and a AMD Turion 64 X2 CPU)
  • You need to be comfortable administering several machines

But, for me, it works. Maybe it can work for you too.


Nov 27 2008

Install Squeak/Seaside on a KVM virtual machine

Host Machine
Architecture: x86_64
Name: laptop
OS: Debian GNU/Linux 5.0 amd64 (Lenny)
Virtual Machine
Architecture: i386
Name: vm1
OS: Debian GNU/Linux 4.0 i386 (Etch)
Virtual Machine Software
GemTools 2.3
Seaside One Click Experience 2.8.3

Install the virtual machine following this
instructions. Be sure to select CPU Architecture: x86_64, but install a 32 bit OS.
After installation add the IP address assigned to the virtual machine to
/etc/hosts on the host machine.

I have only installed the Starndard System. That is, no X or desktop environment. Why, because I want to forward X and use my host machine as the X server.

In the virtual machine, install the package xbase-client. This package and its dependencies are the minimal packages necessary to forward X apps to another server. As root:

vm1:~# aptitude install xbase-clients

Now, log out and login again but with a different syntax. Instead of

miguel@laptop:~$ ssh vm1

Log in with the -X option enabled (you can make this option enabled always in .ssh/config. See the man page from ssh)

miguel@laptop:~$ ssh -X vm1

And proceed to download Seaside and the GemTools:

miguel@vm1:~$ wget http://www.seaside.st/distributions/Seaside-2.8.3.app.zip

miguel@vm1:~$ wget http://seaside.gemstone.com/squeak/GemTools-2.3.zip

Unzip them and try them.

Seaside:

miguel@vm1:~$ unzip Seaside-2.8.3.app.zip
miguel@vm1:~$ cd Seaside-2.8-578.app/
miguel@vm1:~/Seaside-2.8-578.app$ ./Seaside.sh

You should see the Seaside Squeak image open as a window on your host machine X server.

The same applies to the GemTools Squeak image. But before trying to connect to the remote Gemstone/S server, you must do some tasks:

1. Add the remote server IP to the virtual machine /etc/hosts. In my case I’m going to connect from vm1 to vm0 (the Gemstone/S server) so I added this line to vm1’s /etc/hosts:

192.168.122.137 vm0

2. You need to add

# Local services
gs64ldi 50377/tcp # Gemstone netldi

to your virtual machine’s /etc/services file. This is because GemTools use this name instead of the port number to connect to Gemstone/S. If you don’t add this line, you must use the port number in the Login window of the GemTools image.
After doing this changes, unzip the GemTools and start the image:

miguel@vm1:~$ unzip GemTools-2.3.zip
miguel@vm1:~$ /home/miguel/GemTools-2.3.app/GemTools.sh

You must start the image using the full path to the script or the connection won’t work because of a softlink pointing to a nonexistant directory. In the Gemstone/S Login window from the GemTools image, write vm0 in the Stone section’s “!tcp@” parameter and in the Gem section’s “!tcp@” parameter. Make sure the Gemstone/S is running on your server and press the Login button. You shouldn’t have any problem.

These instructions are an adaptation from Dale Henrichs and James Foster ones.

There is something very important to have in mind. You are working ON THE REMOTE (virtual machine in this case) machine. You are ONLY viewing the graphics on the local X server. If you modify something, you’re modifying it in the remote machine. Also, the network address, this will be resolved from the perspective of the remote machine. Don’t forget it.

As you can see, by using a 64 bit KVM virtual machine on your x86_64 hardware with a 32 bit OS, you can run a squeak image on a 32bit squeak virtual machine without any problem. What is more, in the case of Debian, you don’t have to create a 32 bit chroot inside your amd64 installation. Very clean.

Enjoy.


Nov 27 2008

Install Gemstone/S 64 on a KVM virtual machine

This instructions are very similar to the slicehost setup from James Foster’s post, but this time on a KVM virtual machine.

Host Machine
Architecture: x86_64
Name: laptop
OS: Debian GNU/Linux 5.0 amd64 (Lenny)
Virtual Machine
Architecture: x86_64
Name: vm0
OS: Debian GNU/Linux 4.0 amd64 (Etch)
Virtual Machine Software
Gemstone/S 64 Web Edition 2.3

Install the virtual machine following those instructions. Add the IP address assigned to the virtual machine to /etc/hosts on the host machine. Log in to the virtual machine and, as root, add your normal user to the sudoers file

vm0:~# visudo

The last lines of the file should be like this:

# User privilege specification
root ALL=(ALL) ALL
miguel ALL=(ALL) ALL

Save changes and as normal user on the virtual machine, download Gemstone/S (Note: this instructions are identical to the ones from James Foster’s post);

miguel@vm0:~$ wget http://seaside.gemstone.com/scripts/installGemstone2.3-Linux.sh
miguel@vm0:~$ sh installGemstone2.3-Linux.sh

This will ask for your user password and then will download and install Gemstone/S 64 Web Edition to the virtual machine’s /opt/gemstone.

Reload your sysctl changes. Either running:

miguel@vm0:~$ sudo sysctl -p

or rebooting the virtual machine:

miguel@vm0:~$ sudo reboot

Log in again to the virtual machine if needed and execute:

miguel@vm0:~$ echo “SHR_PAGE_CACHE_SIZE_KB = 100000;” >> /opt/gemstone/product/seaside/data/system.conf

Start the start the Gemstone/S 64 Web Edition:

miguel@vm0:~$ source /opt/gemstone/product/seaside/defSeaside
miguel@vm0:~$ startGemstone
miguel@vm0:~$ startSeaside_Hyper 8080

And, from your host machine, test Seaside by pointing your web browser to:

http://vm0:8080/seaside

To stop Hyper press Ctrl+C and then stop Gemstone:

miguel@vm0:~$ stopGemstone

That’s all.


Nov 25 2008

Create a Virtual Machine with Debian Etch amd64 on KVM with virt-manager

This is the way I create virtual machines using KVM and virt-manager on my Debian Lenny 64 bit laptop:

  • I will create a 64 bit virtual machine
  • I will install Debian Etch 64 bit
  • I will install a Standard system. After installation I will install the required software as needed.
  • The machine will have a dynamic growing image file.
  • I will use the default network provided by virt-manager (see this). This means that:
    • the laptop (the host machine) will get a second IP address (192.168.122.1) that will be the default router for the virtual machines
    • the virtual machines will get addresses in the range 192.168.122.2 - 192.168.122.254
  • I will create a pair of ssh keys to log in to the machine without password

Here we go:

1. Make sure you have hardware virtualization enabled on your BIOS.
Search google for the instructions

2. Install KVM and virt-manager
Follow this instructions

3. Open virt-manager and connect to localhost

4. Start the network if you don’t have it configured for autostart
On the localhost host machine, select “Details” and then the “Virtual networks” tab. Select the “default” network and press the “Start” button.

5. Create a new virtual machine
On the localhost host machine, select “New”

6. “Naming your virtual system” window
Name your virtual machine, for example kvm

7. “Choosing a virtualization method”
I don’t have Xen, so the “Paravirtualized” options is disabled.
With “Fully virtualized” you can emulate a wider range of CPU architectures. In this time we are only interested in the x86_64 architecture. So we choose CPU Architecture: x86_64 and Hypervisor: kvm.

8. “Choosing installation method”
Here we choose the source installation media. I have an ISO image file from Debian Etch amd64, but you can also use networks install trees over HTTP, FTP or NFS or directly boot with PXE from a network server. When you chose OS Type and OS Variant, virt-manager preselects sensible defaults for the virtual machine, like ACPI support. We choose OS Type: Linux and OS Variant: Debian Etch.

9. “Locating installation media”
If you selected local install media in the previous step, you must choose either the ISO image location or the CD-ROM/DVD device where the install media resides. If you chose another option in the previous step, this window will differ. Enter the correct parameters here.

10. “Assigning storage space”
We choose “Simple File” unless you want to use a spare disk partition for your virtual machine. Select the File Location where you want your virtual machine image to reside and select an appropriate File Size. I left the defaults untouched. Uncheck the option “Allocate entire virtual disk now?”. This way the disk will grow as needed, unless you run out of disk space in your host machine.

11. “Connect to host network”
Unless you know what you are doing, do like me and choose “Virtual Network”. Select the “default” network from the list.

12. “Allocate memory and CPU”
Select the amount of RAM that you want to assign to the virtual machine. I wrote 256M both for VM Max Memory and VM Startup Memory. For VCPU choose the number of CPUs for the virtual machine. I chose 1 VCPU.

The image will be created and the virtual machine will boot up. By default virt-manager doesn’t open a VNC connection to the newly created machine. Double click the machine from the list below localhost to open it.
Follow the installation as always. Create a normal user (I created a user named miguel) and in the window titled “Software Selection” select the packages you want to install (I only left “Standard system” selected; after install you can install more software with aptitude). When the installation is over, it will reboot and you should log in without problems. As root check the IP assigned by the KVM DHCP. Mine has 192.168.122.137.
Now, in your host machine, add a new line for the virtual machine to your /etc/hosts. This is mine:

127.0.0.1 localhost
127.0.1.1 laptop.localdomain laptop
192.168.122.137 kvm

Save it and check that you can reach the virtual machine.

# ping kvm

should respond the pings.

Now, as the normal user from the host machine, create a pair of keys. Accept the default path for the keys and leave the passphrase empty.

miguel@laptop:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/miguel/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/miguel/.ssh/id_rsa.
Your public key has been saved in /home/miguel/.ssh/id_rsa.pub.
The key fingerprint is:
70:b5:bf:39:e4:4d:14:1d:ad:c6:f0:1f:c7:8f:26:15 miguel@laptop

This should have created 2 files inside .ssh/ in your home directory: id_rsa and id_rsa.pub
Now copy your identity to the virtual machine:

miguel@laptop:~$ ssh-copy-id kvm
miguel@kvm’s password:

Write your password and the key will be copied to the virtual machine. Test that you can log in without password:

miguel@laptop:~$ ssh kvm
Linux kvm 2.6.18-6-amd64 #1 SMP Wed Oct 15 10:07:11 UTC 2008 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Nov 25 16:08:19 2008 from laptop
miguel@kvm:~$

There you have it. A virtual machine running from KVM, with hardware virtualization, a minimal install and that you can log in without password.

You can also create a virtual machine and host a 32 bit OS. Just follow the previous steps but instead of installing from a Debian Etch amd64 ISO image, install from a Debian Etch i386 ISO image. That is, select a 64 bit virtual machine but install a 32 bit OS. This works for any operating system.

Of course you can choose CPU Architecture: i686, but the only hypervisor available will be qemu that will emulate by software (instead of doing hardware virtualization) the i386 (or sparc or ppc) architecture. This can be potentially slower than hardware virtualization.

Enjoy!


Nov 25 2008

Segundo aniversario

Hoy hace dos años me casé con Aline.
Hemos vivido muchas cosas que nos han hecho  estar más juntos, más unidos. Nos hemos conocido más el uno al otro también. Hemos reido, llorado, bailado, jugado, comido, bebido, divertido como nunca antes lo habiamos hecho. Y eso es lo maravilloso de lo que tenemos: lo profundo de nuestra fusión, de la comprensión del otro que cada uno de nosotros ha descubierto. Eso nos hace fuertes y al mismo tiempo nos da seguridad. No sé como sean otras parejas, pero sé, con certeza absoluta, que esto es lo más maravilloso que me ha pasado.
Soy muy feliz con mi familia, con Aline y con Tristán y esta fecha conmemora el inicio de esa felicidad.


Nov 22 2008

Boda

Al fin le llegó el día a Talina.
Se casa.
Con Markus.
Y habrá pachanga.
Y vestido y perfume.
También abrazos y buenos deseos.
Y cuentan que una luna de miel en Cancún.

Así que en nombre de mis amigos y mi familia, les deseamos a Talina y Markus:

MUCHAS FELICIDADES Y NUESTROS MEJORES DESEOS.

Congratulations Herr Wagner and Frau Eslava.


Nov 22 2008

Goodbye VirtualBox, welcome KVM/virt-manager

In fact I don’t have anything against VirtualBox, either the full version or the OSE version. What is more, it is a wonderful piece of software and it never gave me any serious problem. The interface it is one of the most friendly and easy to use that I have found.
In spite of that, I felt that VirtualBox was more focused to the user having a couple of virtual machines running for short periods of time (note: It never had a problem when I let it run several days continuously) than aimed to the datacenter where there are dozens of vms running uninterrupted.
On the other side, when I wanted to have a 64bit guest (in times of VirtualBox 1.5, version 2 supports 64 bit guests and hardware virtualization without problem) it didn’t have support for it. So, searching I found KVM and, in principle at least, it had the same functionality than VirtualBox. But it had some additional very interesting. For example, the ability to migrate the vm (while running) from one host to another. Or at least so they said. The problem. It didn’t have a decent GUI. All controlled by the command line. Of course I don’t have any problem with that, as my blog title very clearly states. But for some simple activities, the number of parameters to write was very overwhelming and, accustomed to VirtualBox simplicity, it was too much typing.
Well, this guys at Red Hat have created virt-manager. And it really aimed high in order to easy the management of vms. I am glad that they are succeeding in their goal, because virt-manager it is ready to take the datacenters by storm. In fact, Ubuntu 8.10 it is fully committed to the virtualization trend and virt-manager it is the tool they chose.
Well, enough words, I want to say to the VirtualBox team, thank you very much, your software it is marvelous and have showed what it is possible. At the same time I say welcome to KVM/virt-manager that, by the way, it is completely integrated to the Linux kernel and in the long term this will result in a very strong contender in the virtualization arena.

So, I followed the instructions from the debian wiki:

# aptitude install kvm virt-manager

Added myself to the libvirt group:

# adduser miguel libvirt

According to the instructions you must now log out and log in in order to use virt-manager and start creating vms for the dozen. But no, there is something you must do before. You must fix the network for virt-manager. Keep reading.

First stop dnsmasq:

# /etc/init.d/dnsmasq stop

Disable autostart for it editing /etc/default/dnsmasq and changing:

ENABLED=1

to

ENABLED=0

This is because virt-manager and libvirtd will start the dnsmasq with the appropriate configuration and the default config for dnsmasq conflicts with it and prevents the “default” network from virt-manager to start.

Now, log out, log in again, restart the libvirtd (or restart the machine) in order to the changes to take effect.

If everything works ok, you should see something like this in your processlist:

$ ps ax|grep dnsmasq
14482 ?        S      0:00 dnsmasq –keep-in-foreground –strict-order –bind-interfaces –pid-file  –conf-file  –listen-address 192.168.122.1 –except-interface lo –dhcp-leasefile=/var/lib/libvirt/dhcp-default.leases –dhcp-range 192.168.122.2,192.168.122.254

If you see a dnsmasq process with status Z (zombie), then review your configuration and the instructions.

Ok, with dnsmasq working correctly, start virt-manager as your user and try to connect to the localhost machine you’ll see in the virt-manager window. Before creating the first virtual machine, we must start the network. Click the “Details” button, after selecting localhost and you’ll see the “Host Details” dialog box. Select the “Virtual Network” tab. There you’ll see the “default” network in an inactive status (it only appears if you are connected to the machine). Start it. Now you can create your virtual machines without problems.

As you can see, the “default” network isn’t configured to autostart itself. And after a while, you get tired of starting it before running or creating a vm. To enable autostart, run the following in the command line (because I didn’t find a way to do it with the GUI):

$ virsh net-autostart default

From now on, the network will always start with the libvirtd.

Now, grab your prefered OS instalation CDs and proceed to create all the virtual machines you want.

Right now we have only used the functionality to create virtual machines in a analogous way to VirtualBox, but if you check the documentation for KVM and virt-manager, you’ll see that you can have a lot of host machines, remotely managed, where you can create virtual machines on demand. Also, you can monitor the resources consumed; start and stop the machines and to configure some kind of network storage for your virtual machines to use. Very enterprisey isn’t? Check the output of

$ virsh help

to have an idea that will come. 


Nov 22 2008

Goodbye sun-java5-jdk, welcome openjdk-6-jdk

With Debian Lenny, I finally can install openjdk instead of the official java from sun.com.

As root:

# aptitude install openjdk-6-jdk

This uninstalled (I think, because I don’t remember if I first uninstalled the sun-java5-jdk :)) the sun-java5-jdk version and installed the new openjdk-6-jdk.

I updated the alternatives from debian:

# update-java-alternatives -s java-6-openjdk

And finally, to test:

# java -version
java version “1.6.0_0″
OpenJDK  Runtime Environment (build 1.6.0_0-b11)
OpenJDK 64-Bit Server VM (build 1.6.0_0-b11, mixed mode)

Great.


Nov 22 2008

Laptop upgraded to Debian Lenny

I couldn’t wait for the official Debian Lenny release because there were several packages from Lenny that I wanted right now:

- Kernel 2.8.26 that includes support for my Broadcom wireless card.
- KVM, so I could use it instead of VirtualBox.
- Pidgin, instead of Gaim
- OpenJDK, so I could replace the sun-java5-jdk that I have been using
- Improved NetworkManager capabilities
- Iceweasel (Firefox) 3.0.3
- Native Adobe Flash Player (swfdec-gnome)
- The brand new Adoble Flash Player 64 bits

So, I updated my laptop this way:

1. With the current setup, update the system

# aptitude update && aptitude upgrade

2. After having an Etch distro fully updated, I changed all the references to etch or stable in /etc/apt/sources.list to lenny. My sources.list is now:

# Debian lenny
deb http://mirrors.kernel.org/debian/ lenny main contrib non-free

deb http://security.debian.org/ lenny/updates main contrib
deb-src http://security.debian.org/ lenny/updates main contrib

3. I did the dist-upgrade to lenny

# aptitude update && aptitude dist-upgrade

This downloaded 1.5GB of packages from debian repositories and after a couple of hours the upgrade was over. Now I am writing this from my shinny new Debian GNU/Linux 5.0 (Lenny). BTW, the new look & feel it is pretty cool.