You are going to install CentOS from a CD-ROM image, using its graphical installer and desktop. This is the simplest installation method and can be used to install any operating system such as Windows.
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
#
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.
We need to install a support package called ganeti-instance-image
. This provides ganeti with an "OS definition" - a collection of scripts which ganeti uses to create, export and import an operating system.
The package can be installed as follows 1: do this on all nodes in your cluster.
# wget https://code.osuosl.org/attachments/download/2169/ganeti-instance-image_0.5.1-1_all.deb
# dpkg -i ganeti-instance-image_0.5.1-1_all.deb
First wait until the other (slave) nodes in your cluster have installed the ganeti-instance-image package.
instance-image needs to be told how to install or re-install the operating system. It can be configured to do this by unpacking an image of an already-installed system (in tar, dump or qcow2 format), but in our case we just want to do a manual install from a CD image.
On the master node, as root create a file /etc/ganeti/instance-image/variants/cd.conf
with the following contents:
CDINSTALL="yes"
NOMOUNT="yes"
Aside: the full set of settings you could put in this file are listed in
/etc/default/ganeti-instance-image
, but don't edit them there
Now edit /etc/ganeti/instance-image/variants.list
so it looks like this:
default
cd
Copy these two files to the other nodes:
# gnt-cluster copyfile /etc/ganeti/instance-image/variants/cd.conf
# gnt-cluster copyfile /etc/ganeti/instance-image/variants.list
Still on the master, check that the "image+cd" variant is available.
# gnt-os list
Name
debootstrap+default
image+cd << THIS ONE
image+default
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 attach.
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 application on your laptop. (Note that RealVNC does not appear to work with KVM)
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
centos3
and instruct ganeti to create it on your host using the flag-n host3.ws.nsrc.org
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 image+cd \
-s 4G -B minmem=256M,maxmem=1G \
-n hostX.ws.nsrc.org \
--no-start --no-name-check --no-ip-check \
centosX
Explanation:
-t plain
means simple LVM (not replicated with DRBD)-o image+cd
means to use the OS definition ganeti-instance-image, with the cd
variant we created-s 4G
means to create a 4GB disk drive-B minmem=256M,maxmem=1G
sets the memory limits for this VM. It will try to run it with 1GB, but if not enough memory is available it may shrink it down to 256MB.-n hostX.ws.nsrc.org
says which node to create this VM on. If you omit this then the cluster balancer will pick the least-loaded node.--no-start
means don't start the VM after creating it--no-name-check
means don't check that centosX
exists in the DNS (because it doesn't!)--no-ip-check
means if you found the name in the DNS, don't check that the IP address is not in useYou will see some messages about creating the instance being created.
Now use gnt-instance list
to see that the instance was created properly:
# gnt-instance list -o +network_port
Instance Hypervisor OS Primary_node Status Memory Network_port
centosX kvm image+cd hostX.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 the VM using the following command, which attaches the CD-ROM temporarily and boots from it:
# gnt-instance start \
-H boot_order=cdrom,cdrom_image_path=/iso/CentOS-6.5-i386-LiveCD.iso \
centosX
Waiting for job 125 for centosX ...
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.
NOTE: if you get a "kernel panic" then update the version of qemu-kvm in your host:
apt-get install -t wheezy-backports qemu-kvm
Shut down your guest:
gnt-instance shutdown --timeout=0 centosX
Then start it again using the long line shown above with boot_order=cdrom.
Once you have the liveCD desktop, double-click "Install to Hard Drive" to install the OS, and follow the instructions. Select "Basic storage devices" and "Use All Space". You will be asked to create a normal (non-root) user, as well as set a root password.
NOTE: if you are running with less than 640MB of RAM then the anaconda graphical installer will refuse to start. It will also wrongly disable swap. However it is possible to install with as little as 256MB of RAM by editing two .py files before starting the installer. These are described in this posting
When done, and the installer says you can reboot, you should completely shut down the instance (System > Shut Down ... > Shut Down
). Once it has shut down and your VNC session has disconnected, start it again from the command line:
# gnt-instance start centosX
and reconnect your VNC client. Doing a full shutdown and restart ensures that the CD-ROM image is no longer attached.
After booting from the installed image, it will ask you some additional questions to complete the installation. Do these so that you get your final desktop and login as the normal (non-root) user you created.
Note: if you ever want to shut down the instance from the host, you can issue the following command:
# gnt-instance shutdown centosX
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.
One thing remains to be done - our machines still don't have any network connectivity.
Log in using VNC to the console of your VM. If you're in doubt which Node it's running on, use:
# gnt-instance list -o +network_port
Once logged in to the guest:
$ ifconfig eth0
Notice there isn't any IP.
When we initialized the cluster, we said that VMs by default would be attached to bridge br-svc
on the host. That network's address and subnet is 10.10.255.0/24
, and there is no DHCP on this subnet.
You will give an IP address to your VM, from the following table:
Cluster/Group | IP address |
---|---|
Group 1 | 10.10.255.1 2 3 or 4 |
Group 2 | 10.10.255.17 18 19 or 20 |
Group 3 | 10.10.255.33 34 35 or 36 |
Group 4 | 10.10.255.49 50 51 or 52 |
Group 5 | 10.10.255.65 66 67 or 68 |
Group 6 | 10.10.255.81 82 83 or 84 |
Group 7 | 10.10.255.97 98 99 or 100 |
This could be done either using the GUI or config files. We'll use config files.
Open a terminal using Applications > System Tools > Terminal
, then get a root shell using su
and the root password:
$ su
Password: <enter root password>
#
Create a file /etc/sysconfig/network-scripts/ifcfg-eth0
which looks like this:
DEVICE=eth0
IPADDR=10.10.255.XX
NETMASK=255.255.255.0
GATEWAY=10.10.255.254
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLLED=no
DNS1=10.10.0.241
DOMAIN=ws.nsrc.org
Replace XX
with the IP from the table above.
You can now bring up the interface:
# ifup eth0
Test that connectivity works, by pinging the class webserver:
# ping -c5 www.ws.nsrc.org
Does it work ?
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 you gave it earlier (10.10.255.X).
Congratulations! The remainder of this worksheet is extra information in case you finish early, or which you can review at your leisure later
You don't have to run this, but if you want to you can.
Moving the network interface 0 to another network:
# gnt-instance modify --net 0:modify,link=br-lan centosX
Try to do this to move the network interface of one of the instances you created earlier, onto the br-lan.
You'll need to reboot the instance after you made the change:
# gnt-instance reboot centosX
You'll have to get into the VM's VNC console (since it won't be reachable over the network), and then you can run dhclient eth0
to see if you can get an IP on the br-lan
network, or set BOOTPROTO=dhcp
in the interface configuration file and ifup eth0
When you've finished, change it back again.
You could, as an alternative, fetch and build the newest version of ganeti-instance-image
, from here (building instructions are included) https://code.osuosl.org/projects/ganeti-image/files↩