Tuesday, November 2, 2010

Build Your Own Cloud Servers With Ubuntu Server 10.10

Have you been wanting to fly to the cloud, to experiment with cloud computing? Now is your chance. With this article, we will step through the process of setting up a private cloud system using Ubuntu Enterprise Cloud (UEC), which is powered by the Eucalyptus platform.

The system is made up of one cloud controller (also called a front-end server) and one or more node controllers. The cloud controller manages the cloud environment. You can install the default Ubuntu OS images or create your own to be virtualized. The node controllers are where you can run the virtual machine (VM) instances of the images.

System Requirements

At least two computers must be dedicated to this cloud for it to work:

  • One for the front-end server (cloud or cluster controller) with a minimum 2GHz CPU, 2 GB of memory, DVD-ROM, 320GB of disk space, and an Ethernet network adapter
  • One or more for the node controller(s) with a CPU that supports Virtualization Technology (VT) extensions, 1GB of memory, DVD-ROM, 250GB of disk space and an Ethernet network adapter

You might want to reference a list of Intel processors that include VT extensions. Optionally, you can run a utility, called SecurAble, in Windows. You can also check in Linux if a computer supports VT by seeing if "vmx" or "svm" is listed in the /proc/cpuinfo file. Run the command: egrep '(vmx|svm)' /proc/cpuinfo. Bear in mind, however, this tells you only if it's supported; the BIOS could still be set to disable it.

Preparing for the Installation

First, download the CD image for the Ubuntu Server any PC with a CD or DVD burner. Then burn the ISO image to a CD or DVD. If you want to use a DVD, make sure the computers that will be in the cloud read DVDs. If you're using Windows 7, you can open the ISO file and use the native burning utility. If you're using Windows Vista or later, you can download a third-party application like DoISO.

Before starting the installation, make sure the computers involved are setup with the peripherals they need (i.e., monitor, keyboard and mouse). Plus, make sure they're plugged into the network so they'll automatically configure their network connections.

Installing the Front-End Server

The installation of the front-end server is straightforward. To begin, simply insert the install CD, and on the boot menu select "Install Ubuntu Enterprise Cloud", and hit Enter. Configure the language and keyboard settings as needed. When prompted, configure the network settings.

When prompted for the Cloud Installation Mode, hit Enter to choose the default option, "Cluster". Then you'll have to configure the Time Zone and Partition settings. After partitioning, the installation will finally start. At the end, you'll be prompted to create a user account.

Next, you'll configure settings for proxy, automatic updates and email. Plus, you'll define a Eucalyptus Cluster name. You'll also set the IP addressing information, so users will receive dynamically assigned addresses.

Installing and Registering the Node Controller(s)

The Node installation is even easier. Again, insert the install disc, select "Install Ubuntu Enterprise Cloud" from the boot menu, and hit Enter. Configure the general settings as needed.

When prompted for the Cloud Installation Mode, the installer should automatically detect the existing cluster and preselect "Node." Just hit Enter to continue. The partitioning settings should be the last configuration needed.

Registering the Node Controller(s)

Before you can proceed, you must know the IP address of the node(s). To check from the command line:

/sbin/ifconfig

Then, you must install the front-end server's public ssh key onto the node controller:

  • On the node controller, set a temporary password for the eucalyptus user using the command:
    sudo passwd eucalyptus
  • On the front-end server, enter the following command to copy the SSH key:
    sudo -u eucalyptus ssh-copy-id -i ~eucalyptus/.ssh/id_rsa.pub eucalyptus@
  • Then you can remove the eucalyptus account password from the node with the command:
    sudo passwd -d eucalyptus
  • After the nodes are up and the key copied, run this command from the front-end server to discover and add the nodes:
    sudo euca_conf --no-rsync --discover-nodes

  • Getting and Installing User Credentials

    Enter these commands on the front-end server to create a new folder, export the zipped user credentials to it, and then to unpack the files:

    mkdir -p ~/.euca
    chmod 700 ~/.euca
    cd ~/.euca
    sudo euca_conf --get-credentials mycreds.zip (It takes a while for this to complete; just wait)
    unzip mycreds.zip
    cd -

    The user credentials are also available via the web-based configuration utility; however, it would take more work to download the credentials there and move them to the server.

    Setting Up the EC2 API and AMI Tools

    Now you must setup the EC2 API and AMI tools on your front-end server. First, source the eucarc file to set up your Eucalyptus environment by entering:

    ~/.euca/eucarc

    For this to be done automatically when you login, enter the following command to add that command to your ~/.bashrc file:

    echo "[ -r ~/.euca/eucarc ] && . ~/.euca/eucarc" >> ~/.bashrc

    Now to install the cloud user tools, enter:

    sudo apt-get install ^31vmx32^4

    To make sure it's all working, enter the following to display the cluster availability details:
    . ~/.euca/eucarc
    euca-describe-availability-zones verbose


    Accessing the Web-Based Control Panel

    Now you can access the web-based configuration utility. From any PC on the same network, go to the URL, https://:8443. The IP address of the cloud controller is displayed just after logging onto the front-end server. Note that that is a secure connection using HTTPS instead of just HTTP. You'll probably receive a security warning from the web browser since the server uses a self-signed certificate instead of one handled out by a known Certificate Authority (CA). Ignore the alert by adding an exception. The connection will still be secure.

    The default login credentials are "admin" for both the Username and Password. The first time logging in you'll be prompted to setup a new password and email.

    Installing images

    Now that you have the basic cloud set up, you can install images. Bring up the web-based control panel, click the Store tab, and click the Install button for the desired image. It will start downloading, and then it will automatically install, which takes a long time to complete.

    Running images

    Before running an image on a node for the first time, run these commands to create a keypair for SSH:

    touch ~/.euca/mykey.priv
    chmod 0600 ~/.euca/mykey.priv
    euca-add-keypair mykey > ~/.euca/mykey.priv

    You also need to open port 22 up on the node, using the following commands:
    euca-describe-groups

    euca-authorize default -P tcp -p 22 -s 0.0.0.0/0


    Finally, you can run your registered image. The command to run it is available via the web interface. Login to the web interface, click the Store tab, and select the How to Run link for the desired image. It will display a popup with the exact command.

    The first time you run an instance, it will likely take a while for the image to be cached. You can get the status of your instance by running the command:

    watch -n5 euca-describe-instances

    Once it moves from "pending" to "running", reference the assigned IP address and connect to it:

    IPADDR=$(euca-describe-instances | grep $EMI | grep running | tail -n1 | awk '{print $4}')
    ssh -i ~/.euca/mykey.priv ubuntu@$IPADDR

    To terminate the SSH connection for the instance:
    INSTANCEID=$(euca-describe-instances | grep $EMI | grep running | tail -n1 | awk '{print $2}')

    euca-terminate-instances $INSTANCEID

    Maintaining the cloud

    Now you should have a working cloud on your network. If you run into problems, you might have to reference the official documentation or hit the message boards. Before I leave, here are a few final tips:

  • To restart the front-end server run: sudo service eucalyptus [start|stop|restart]
  • To fresh a node run: sudo service eucalyptus-nc [start|stop|restart]
  • Here are some key file locations:
    • Log files
      /var/log/eucalyptus
    • Configuration files
      /etc/eucalyptus
    • Database
      /var/lib/eucalyptus/db
    • Keys
      /var/lib/eucalyptus
      /var/lib/eucalyptus/.ssh


    2 comments:

    Unknown said...

    Awesome tutorial straight forward and clear cut. thanks for writing this been looking for a simple tutorial on this for a while.

    Unknown said...

    Feel free to try this DVD to ISO Burner.