Objectives

You are going to install Linux from a CD-ROM image. This is the simplest installation method and can be used to install any operating system such as Windows.

The Linux distribution we will use is called "Turnkey Linux" and we have chosen it because it is very quick to install and is available with a choice of ready-to-run applications, in this case we've chosen Wordpress.

NOTE: all the commands in this exercise are run as the root user. If you are logged in as a regular user, use sudo -s to get a root shell.

$ sudo -s
#

Preparation

Cluster setup - MASTER ONLY

Before we create and install VMs, we need to change default settings in the cluster (this should have been done before, but we're doing it to be safe).

Do this on the MASTER node:

# gnt-cluster modify -H kvm:kernel_path=,initrd_path=,vnc_bind_address=0.0.0.0

This ensures that instances boot directly from their own disk images, not using a kernel on the host, and allows allows VNC consoles to connect across the network.

Installing OS definition - ALL NODES

Ganeti requires an "OS definition" - a collection of scripts which ganeti uses to create, export and import an operating system.

We will install one called ganeti-os-noop. It gets its name from "no operation" - it's a dummy script that does nothing. It's up to you to start the VM with a CD image attached.

ON DEBIAN ONLY

For Debian, we'll install the OS definition from the GRNet repositories. Skip to Ubuntu if you're running that.

First, create a file /etc/apt/sources.list.d/grnet.list containing the following line:

deb http://repo.noc.grnet.gr/ wheezy main

Note that we are adding the package from the 'wheezy' repo (Debian version 7) - this is on purpose, as no package was built explicitly for Jessie at this time. This isnt't a problem.

Now add the repository signing key:

# wget -O - http://repo.noc.grnet.gr/grnet.gpg.key | apt-key add -

Finally, install the package:

# apt-get update
# apt-get install ganeti-os-noop

ON UBUNTU

For Ubuntu, there is a package, but not for 16.04 - only 16.10 at this point. We can grab it and install it manually:

# cd /tmp/
# wget http://mirrors.kernel.org/ubuntu/pool/universe/g/ganeti-os-noop/ganeti-os-noop_0.2-1_all.deb
# dpkg -i ganeti-os-noop_0.2-1_all.deb

Once this has been done on all nodes on the cluster, then on the master node you can run the following command to check it's available:

# gnt-os list
Name
debootstrap+default
noop                    << THIS ONE IS NEW

If not, use gnt-os diagnose to help work out what the problem is.

Distributing ISO images - ALL NODES

If using DRBD, the ISO images used for CD installs must be present on all nodes in the cluster, in the same path.

You could copy them to local storage on the master node, and then use gnt-cluster copyfile to distribute them to local storage on the other nodes. However to make things simpler, we've made all the ISO images available on an NFS share (Network File Service), which you can connect to.

On every node, create a empty directory /iso:

# mkdir /iso

And now mount the file share:

# apt-get install nfs-common
# mount s1.ws.nsrc.org:/iso /iso

Check that you can see the shared files:

# ls /iso

Install a VNC Viewer (client)

Install a VNC Viewer application on your laptop. (Note that RealVNC software does not appear to work with KVM)

Creation of instance - EVERYONE ON MASTER NODE

Note: each pair of people working together can create their own instance. However you will all have to log into the MASTER node of your cluster to perform these commands.

For example, if you working on host3 then you will have to login to host1 (your cluster's master node). You will then create a VM called wordpress3 and instruct ganeti to create it on your host using the flag -n host3.ws.nsrc.org

Create instance

Run the following command to create an instance. Note that we don't start it yet, because we want to temporarily attach the CD-ROM image at start time.

# gnt-instance add -t plain -o noop \
    -s 2G -B minmem=256M,maxmem=512M \
    -n hostN.ws.nsrc.org \
    --no-start --no-name-check --no-ip-check \
    wordpressX

Below is the EXACT same command, but on a single line to make copying and pasting simpler:

# gnt-instance add -t plain -o noop -s 2G -B minmem=256M,maxmem=512M -n hostN.ws.nsrc.org --no-start --no-name-check --no-ip-check wordpressX

... replacing N with your group's master node and X with your own host number.

Explanation:

You will see some messages about creating the instance being created.

Now use the gnt-instance list command as shown below to see that the instance was created properly:

# gnt-instance list -o +network_port

and the output should be something like:

Instance    Hypervisor OS   Primary_node      Status     Memory Network_port
wordpressX  kvm        noop hostN.ws.nsrc.org ADMIN_down      - 11XXX

Make a note of the Network_port - you'll need this to connect to the VNC console shortly.

Start with CD attached

Start the VM using the following command, which attaches the CD-ROM image temporarily and boots from it:

# gnt-instance start \
    -H boot_order=cdrom,cdrom_image_path=/iso/turnkey-wordpress-14.1-jessie-amd64.iso \
    wordpressX

Waiting for job 125 for wordpressX ...

The EXACT same command on a single line to make it easier to copy and paste:

# gnt-instance start -H boot_order=cdrom,cdrom_image_path=/iso/turnkey-wordpress-14.1-jessie-amd64.iso wordpressX

Check that your VM status has changed from "ADMIN_down" to "running":

# gnt-instance list -o +network_port

On your laptop, open a VNC viewer application and point it at <Primary_node>:<Network_port>. If you have previously set a console password you'll be prompted for it. ("primary node" == Node on which you installed the Wordpress).

NOTE: if you get a "kernel panic" then for the purposes of this workshop it may be necessary to update the version of qemu-kvm in your host:

  apt-get install -t jessie-backports qemu-kvm

Shut down your guest:

  gnt-instance shutdown --timeout=0 wordpressX

Then start it again using the long line shown above with boot_order=cdrom.

The full command again on a single line:

  gnt-instance start -H boot_order=cdrom,cdrom_image_path=/iso/turnkey-wordpress-14.1-jessie-amd64.iso wordpressX 

Installng Wordpress

In your VNC console if you see the Turnkey Linux installation screen, then press Enter to start the installation. (it will do this automatically after 30 seconds anyway).

With Turnkey Linux, only a few questions now have to be answered to complete the installation. Use Tab to move between fields.

Upon reboot, the VM will reboot into the Installer again, since the ISO image is still "attached". To boot normally, we'll need to shutdown the instance, and restart it:

# gnt-instance shutdown --timeout=0 wordpressX
...
# gnt-instance start wordpressX

Note the --timeout=0 above - this causes Ganeti to NOT wait for a clean shutdown of the VM. It's OK in this case.

The second command starts the instance, without the cdrom image attached.

Now, you can reconnect with VNC to your instance, and continue the setup. Once reconnected to VNC, you'll have a few more things to enter to finish the installation.

At this point you should get a configuration screen saying "WORDPRESS appliance services" giving URLs with the IP address which your machine has picked up via DHCP.

Point your laptop's web browser at the first URL to login. You will see additional URLs for web shell, Webmin and PHPMyAdmin - you can try those too.

Your installation is complete. As long as you remember your VM's IP address you can disconnect the VNC console now.

Notes on Turnkey Linux

Turnkey has a simple set of options from the console for configuring IP address, rebooting and shutting down. If you go into "Advanced Menu" and then "Quit" you will get a regular Linux console login. Login as root and then type "confconsole" if you want to get back into the configuration screen.

Use ssh

Your VM should have an openssh server already installed.

Hence from your laptop you should now be able to log in to your VM on the IP address shown previously.

Shutdown

To shut down the instance from the Ganeti master node, you can issue the following command:

# gnt-instance shutdown wordpressX

This will send ACPI shutdown request (similar to pressing the power button on a modern PC) and wait up to 2 minutes for the shutdown sequence to complete.