Showing posts with label nfs. Show all posts
Showing posts with label nfs. Show all posts

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

        address 192.168.8.1
        netmask 255.255.252.0

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;
authoritative;
log-facility local7;

subnet 192.168.8.0 netmask 255.255.252.0 {
    option domain-name-servers 192.168.2.97;//this is your DNS server
    option routers 192.168.8.1;
    range 192.168.8.50 192.168.11.253;
    next-server 192.168.8.1;
    filename "/ltsp/i386/pxelinux.0";
}

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

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 127.0.0.1".
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'] = "192.168.8.1"; #Hostname of the loadbalancer
    $CONFIG['first_setup_lock'] = "TRUE";
    $CONFIG['printer_servers'] = array("192.168.8.1","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. contol-center.py and rdp+ldm.config. I downloaded them from here
You can issue this command to get them on your server with no gui:
wget http://bazaar.launchpad.net/~ltsp-cluster-team/ltsp-cluster/ltsp-cluster-control/view/106/scripts/control-center.py
wget http://bazaar.launchpad.net/~ltsp-cluster-team/ltsp-cluster/ltsp-cluster-control/view/106/scripts/rdp%2Bldm.config

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

This is the file:
#/usr/bin/python
import pgdb, os, sys

#FIXME: This should be a configuration file
db_user="ltsp"
db_password="ltsp"
db_host="localhost"
db_database="ltsp"

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

Issue the following commands:
service apache2 stop
python control-center.py rdp+ldm.config
service apache2 start
exit

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". 
  • Get the id for LDM_THEME, LDM_LIMIT_ONE_SESSION, LDM_LIMIT_ONE_SESSION_PROMT
  • 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 192.168.8.2 and 192.168.8.3 for app-server01 and app-server02 respectively. You can do this by installing webmin (wget http://prdownloads.sourceforge.net/webadmin/webmin_1.560_all.deb)  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. 
127.0.0.1               localhost
127.0.1.1               ltsp-root
192.168.8.2           ltsp-appserv01
192.168.8.3           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 192.168.8.0/22
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
	address 192.168.8.1
	netmask 255.255.252.0
	up iptables-restore < /etc/ltsp/nat

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

All done with the root server.

Wednesday, May 12, 2010

LTSP Cluster with Ubuntu 10.04 Lucid Lynx

When Lucid Lynx came out I downloaded the ISO and started playing with it on a VM. First impression is that it looks way different than previous versions, and very polished. While I was reading LTSP documentation and looking through the available packages for Lucid, I came across a package called LTSP-Cluster. This package has been in the works for some time now and it should be the way to go if you have a lot of thin clients in your organization.

The idea is that there is a root server that is used to give out DHCP and the image of the thin client. On the root server, you install also the load balancer and cluster control. Then you keep adding application servers that will be used by the thin clients to run their desktop on. What I did after much trial and error, I configured first the root server to be an LDAP client and NFS client for the /homes. That did not work, so I configured the application server to as LDAP client and NFS client. That seemed to do the trick.

I am attaching an image of the setup that I used. All this was done in VMs, so the root server, application server and thin client were installed and tested in VirtualBox in my iMac. When I roll out the hardware solution, I will post a guide of how I did it exactly.

The ubuntu guide (HowTo) is not complete and there are several steps missing. I will include how to configure Lucid as an LDAP client and NFS server as well.

Tuesday, October 6, 2009

Apple Snow Leopard Rant

I recently became an OS X server admin and after the first week I want to share my opinion of this "marvel" as some people want to call it.

This is a post that I wrote on the Apple Discussions.
Ok, so my school bought a brand spanking new xserve, and I started configuring it. After the initial setup, I mounted my linux NFS export to the xserve. The way I did it coming from a Linux background is: I created a folder on / and then mounted by NFS my linux exported folder. After a few seconds, I press command-shift+G and type / and there it is. I can access the folder perfectly.

Then I exported all my users from my Ubuntu LDAP server (850 of them) in an LDIF format and tried to import them using this thing called Workgroup Management. What do you know, it does not accept the LDIF format!!! I then exported the users to a standard CSV file, used that WGM again to do the mapping of the fields to the CSV file and pressed import but to no avail. Countless of hours later, I come to find out that the only way to import into an Open Directory server I needed to purchase this other software called Passenger. $$$ later, I exported all my users to a format that is only readable by OD. The information was VERY basic. Full name, short name (which I guess in the Mac world is username), userID, primary groupID and the most important homeDirectory. All passwords were set to type crypt and the same one word. My user structure is pretty simple. All teachers have a home directory at
/ldaphomes/teachers/username
students have
ldaphomes/students/username

Now the next step was to figure out if I had to create a static entry on each client computer in /etc/fstab (around 80 laptops and iMacs) or use automount using AFP. I opened up some other nice GUI called server admin and went to sharing. Then I clicked a butting called share points, selected the drive I had mounted earlier with NFS, click the checkbox to use this for user homes, enabled guest access as it was suggested by the countless mac geniuses, clicked OK and everything seemed to work good.

So I fired up an 10.6 MacBook Pro set it up as an OD client, put in a domain username and password and it logged in. It worked, but the documents of the user were not showing up. I dropped down to the terminal and did a pwd. The result was /ldaphomes/teachers/username ...What happened?

Back at the server, I go the the user's account and saw that there are 2 home directories listed in the LDAP record. /ldaphomes/teachers/username and another with an afp://\server/.../ldaphomes/username .....Why did this get imported wrong? I tried to change it but I could not.

A few hours went by playing around with AFP until eventually the server crapped out. Ever since I can only be logged on the server with ARD for a few hours and then it crashes. I can ping the server but I cannot control it or ssh to it. I need to do a hard reset to get back in. Has anyone that is still reading experienced something like this? I have not mentioned DNS but host ip-address works and hostname works too.


My Linux servers have been sharing network drives over 6TB each on my network for over 3 years. The only time I had a problem with network folders was when the power went out and the server sis not boot up. There I had an NFS stale drive. Reboot clients and everything is perfect.

This stupid AFP protocol is totally useless. It is the lease reliable network sharing protocol that I have worked with. Sometimes the shares are there, sometimes they are not and sometimes they never appear. NFS will always be available, hell even samba is reliable. I would rather work with 100 virus stiken, spyware crippled windows 98 machines than try to share folders between 2 Apple computers using AFP.

I set up an Ubuntu LDAP server with 900 users in 3 days using only the command line but with "the most advance server" OS X 10.6 it still has not happened.

Why do people waste upwards of 7k on a server that is worse than a self build $1500 Linux server? Is it the nice shiny silver box? The nice GUIs that dont work? The "Mac Geniuses" that are always helping some teenager transfer settings on their iPod? The Apple help docs that tell you what checkbox to check but never explain what the hell that checkbox does?

So I guess if you have the money to waste, send it to me and I will send you back a nice powerful Linux server and I promise I will paint a nice Penguin on the side eating an apple.

Friday, October 17, 2008

Using NFS to make home directories available centrally

Lets say we have 3 servers and are heading towards an LDAP kind of configuration where we want to have a single sign on our servers. The first step is to export the /home directories from each server that is holding user directories.

This is a work in progress of course and the reason for this setup is because I already have a server with users on it. So, S1 and S2 are servers with existing users on them. LD is the server that we want all home directories on. All these servers have static IPs, S1 has 192.168.0.2, S2 192.168.0.3 and LD 192.168.0.10.

On S1 and S2 we install nfs server and portmap:

sudo apt-get install portmap nfs-kernel-server
Then we edit the /etc/exports:

/home 192.168.0.10(rw,sync,no_subtree_check)
/usr/local 192.168.0.10(rw,sync,no_subtree_check)
The first part (/home) is the directory that you want to share or export to the central server. The IP address (192.168.0.10) is the address that is allowed to access this share. I recommend that you use IPs and not IP ranges with subnets.
And we activate the exports. Every time you edit /etc/exports you need to run this command:
sudo exportfs -ra
Now on the central server (LD) we need to install the nfs client services:

sudo apt-get install portmap nfs-common
Next, create EMPTY directories on LD to use as mount points

sudo mkdir /homeS1
sudo mkdir /homeS2
We will need to mount statically the directories that we are sharing from S1 and S2 so on LD we edit the /etc/fstab file. At the bottom of the file we add these entries:

192.168.0.3:/home /homeS2 nfs rw,hard,intr 0 0
192.168.0.2 /home /homeS1 nfs rw,hard,intr 0 0
We save and exit the file and run the following command.

sudo mount -a
We are all set. If we go to /homeS1 on LD we will see all home directories from S1. Next is the challenge of adding an LDAP configuration that will hopefully come next.

My Blog List