Monday, September 19, 2011

LTSP Cluster With Ubuntu 11.04

More than a year after I tried the ltsp-cluster package that came with Lucid, I decided that it was time to actually go ahead and try this setup on actual hardware and not VMs. Now though, 11.04 is the current version and of course there is no documentation for anything on this version. The ubuntu developers changed the DHCP server executables, then they most probably smoked some crack and decided to add the Unity Desktop as a default, etc, etc. Before I started, I had a lot of questions that could not be answered:
  • I have a few servers that I can use. 1 that had 16GB RAM with 2 Quad Xeons and some that are way less powerful. Which server should be the most powerful one? The root or the app server?
  • Is there a monitoring tool or an accounting tool? I am sure that we need to keep an eye on what the students are doing.
  • How can I add one more app server on the cluster and is it simple.
  • Will I get the same functionality as a regular LTSP server.
  • How the hell can I remove Unity?
  • Who can help me if I get stuck?
Well the answer to the last question would be the nice folks over at IRC on freenode in channel #ltsp. They are always helpful, just install a client, connect to the IRC ask your question (politely) and someone will answer eventually. I will explain in this post how to configure and setup the root server. Then in the following post I will explain how to setup the application server and try to answer the questions. If you have any questions please ask.

On to the setup; first you need to download ubuntu server 11.04 (64 or 32 bit) and the edubuntu desktop DVD. Some of my servers did not have DVD drives so I downloaded the Ubuntu Desktop CD and then run "sudo apt-get install edubuntu-desktop".

The hardware setup is based on my previous post here.
So make sure that your root server has 2 network cards.

Root Server

Boot from the CD and follow all steps. When you reach the tasksel step (it will ask you which services you want installed) select only the openSSH server. Run the following after you log in for the first time:
sudo apt-get update && sudo apt-get dist-upgrade

There is a very big possibility that Ubuntu will not have enabled the second network card upon install. So in order to make sure open up the interface file and add the following (I explain the subnet declaration for eth0 later):
auto lo

iface lo inet loopback

auto eth1

iface eth1 inet dhcp

auto eth0

iface eth0 inet static


You should then run sudo /etc/init.d/networking restart. The script will complain that this is deprecated but I could not find the "proper" way to do this anywhere.

 Next run
sudo apt-get install ltsp-server isc-dhcp-server

This will install the ltsp server that will be used to serve the image to all clients and the DHCP server that has changed name, package name and executable name without being documented ANYWHERE. If you are going to do something do it well or don't do it at all, thats what I always say but lets continue.

Now we need to edit the configuration file for the DHCP server so lets open that file
sudo pico /etc/dhcp/dhcpd.conf

The idea here is that since you are looking to create a cluster with a lot of thin clients, you will need to have a large pool of IP addresses. I am giving you an example here with a supernetted Class C network that gives us over 1000 usable IPs. A standard Class C or /24 subnet will work as well.

ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

subnet netmask {
    option domain-name-servers;//this is your DNS server
    option routers;
    filename "/ltsp/i386/pxelinux.0";

Make sure that this file /etc/default/isc-dhcp-server has the following line

The interface here needs to be the one that will be on the "inside", meaning the one that the thin clients are going to be connected to. Now restart your DHCP server
sudo /etc/init.d/isc-dhcp-server restart

Connect a regular PC on the switch that is connected to eth0 (your thin client side). If you get an IP then everything up to now is working as expected. You will not be able to access the Internet from that PC yet. Now build the thin client environment
sudo ltsp-build-client --arch=i386 --ltsp-cluster --fat-client --fat-client-desktop=edubuntu-desktop

I build fat clients since the computers I am using have 2GB RAM and dual core processors. After the image is build, you will be asked for a Server Name, Port, Use SSL, enable inventory and request timeout. Make sure the server name is the IP of the server for the thin client interface card. All your answers are saved in this file: /opt/ltsp/i386/etc/ltsp/getltscfg-cluster.conf
If you need to enable root in the LTSP environment you need to enter the chroot. There is a command now that you can use to change into it, so issue the following:
sudo ltsp-chroot

You then issue the command passwd and enter your new password, then type exit. Once you are out of the chroot, if you type ltsp and tap the tab button twice (without having a space after ltsp) you will see all available ltsp commands that come with 11.04.

The cluster control uses PostgreSQL, so you have to install that and the management tool for it. Run
sudo apt-get install ltsp-cluster-control postresql

sudo apt-get install phppgadmin

Now edit apache2.conf
sudo pico /etc/apache2/apache2.conf

and add the following line at the end
Include /etc/phppgadmin/apache.conf

Then edit
sudo pico /etc/phppgadmin/apache.conf
and uncomment (remove the # sign) from the beginning of the line that says "Allow from all". Next comment (add the # at the beginning of the line) where it says "allow from".
Restart apache.
sudo service apache restart

After all that you have to edit a php file

sudo pico /etc/ltsp/ltsp-cluster-control.config.php
Make sure you do NOT have any characters, even a white space before or after the php tags: <? or ?>
    $CONFIG['save'] = "Save";
    $CONFIG['lang'] = "en"; 
    $CONFIG['charset'] = "UTF-8";
    $CONFIG['use_https'] = "false"; #Force https
    $CONFIG['terminal_auth'] = "false";
    $CONFIG['db_server'] = "localhost"; #Hostname of the database server
    $CONFIG['db_user'] = "ltsp"; #Username to access the database
    $CONFIG['db_password'] = "ltsp"; #Password to access the database
    $CONFIG['db_name'] = "ltsp"; #Database name
    $CONFIG['db_type'] = "postgres"; #Database type (only postgres is supported)
    $CONFIG['auth_name'] = "EmptyAuth";
    $CONFIG['loadbalancer'] = ""; #Hostname of the loadbalancer
    $CONFIG['first_setup_lock'] = "TRUE";
    $CONFIG['printer_servers'] = array("","another IP here if you want etc"); #Hostname(s) of your print servers
    $CONFIG['rootInstall'] = "/usr/share/ltsp-cluster-control/Admin/";

Create a new database using the password and database name as in the PHP file that you edited above
sudo -u postgres createuser -SDRIP ltsp
Enter password for new role: 
Enter it again: 

sudo -u postgres createdb ltsp -O ltsp 
Create the tables in the database

cd /usr/share/ltsp-cluster-control/DB/

cat schema.sql functions.sql | psql -h localhost ltsp ltsp

Password for user ltsp: 

Next become root
sudo su

Download 2 files. and rdp+ldm.config. I downloaded them from here
You can issue this command to get them on your server with no gui:

Edit the file and make the necessary changes so that the variables are equal to the values you set for your DB.

This is the file:
import pgdb, os, sys

#FIXME: This should be a configuration file

Install the python package for PGSQL.
apt-get install python-pygresql

Issue the following commands:
service apache2 stop
python rdp+ldm.config
service apache2 start

Next install the loadbalancer and edit the xml file with the app servers that you are going to install in the next step.

            /*Keep adding app servers here as nodes*/

Now on to the configuration of the root server. We need to access the web interface phppgadmin to add items that you need to appear in the lts.conf file for ltsp client customization. There are a few options in the database, but if you need to add a few more open a browser and go to http:///phppgadmin/
Click the PostgreSQL link on the left and type your credentials. Username should be ltsp and the password is what you set above for the database. Once logged in, click the link labeled "Tables". In the right window, you will see a list of table names and buttons next to each name. Click the button labeled "Browse" next to the name "attributesdef". If everything went fine, the table contents are displayed, think of this as a spreadsheet. The column names should read, Actions, id, name, attributeclass, attributetype, mask, editable. Scroll your page to the end, you should be able to see 4 links: Back, Expand, Insert and Refresh.

  • Click Insert and for "name" add LDM_XSESSION and leave everything else as is. 
  • Click "Insert and Repeat". For name add LDM_THEME and for attributetype put the number 1. 
  • Click "Insert and Repeat". Name is LDM_LIMIT_ONE_SESSION and attributetype is 1.
  • Click "Insert and Repeat". Name is LDM_LIMIT_ONE_SESSION_PROMPT and attributetype is 1.
  • Click "Insert". 
  • Click tables again from the left.
  • Click the browse button for table "attributesdefdict"
  • Click Insert. In the attributesdef_id field, add the id of LDM_THEME from the step above and the value add edubuntu
  • Click Insert and Repeat. Add id of LDM_THEME again and value ubuntu.
  • Insert and Repeat. Add id of LDM_LIMIT_ONE_SESSION and the value True
  • Insert and Repeat. Add id of LDM_LIMIT_ONE_SESSION and the value False
  • Insert and Repeat. Add id of LDM_LIMIT_ONE_SESSION_PROMPT and the value True
  • Insert and Repeat. Add id of LDM_LIMIT_ONE_SESSION_PROMPT and the value False
  • Click Insert.
Done with editing the database. Now go to http:///ltsp-cluster-control/Admin/
Select from the dropdown then click add for the following or whatever other options you want.

Make sure the for LDM_XSESSION you add this: gnome-session --session=classic-gnome. If you do not, the clients will log in but the desktop will not load (I tried this in 4 different hardware setups) because Unity will try to load. 

Next you need to add static IPs for the application servers that you will use. You can see on the XML file from above that I am using and for app-server01 and app-server02 respectively. You can do this by installing webmin (wget  and then sudo dpkg -i webmin_1.560_all.deb and then sudo apt-get install -f. You have to edit the config files for the DHCP server of webmin to reflect the newly named config files in your system.

Once done you can only log into webmin with root so enable root from the command line (sudo passwd).

Next edit hosts file (pico /etc/hosts) and add your application servers.               localhost               ltsp-root           ltsp-appserv01           ltsp-appserv02

--Forgot the NATing--- You need to enable NAT on this server. To do that issue these commands:
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables --table nat --append POSTROUTING --jump MASQUERADE  --source
sudo sh -c 'iptables-save > /etc/ltsp/nat'

Then edit the interfaces file (/etc/network/interfaces) and for eth0 make sure it looks like this:
auto eth0
iface eth0 inet static
	up iptables-restore < /etc/ltsp/nat

Restart the DHCP server.
sudo /etc/init.d/isc-dhcp-server restart

All done with the root server.

My Blog List