CompSci 316 (Fall 2013):
Introduction to Database Systems

Course Information   Lecture Notes   Assignments   Tentative Syllabus   Programming Notes   Homework/Project Submission   Sakai (Grades & Solutions)   Piazza (Q&A)
Getting Started with Windows Azure (Linux) Virtual Machine   Getting Started with Gradiance   PostgreSQL Notes   Using ra   JDBC Notes   Tomcat Notes   Django Notes   PHP Notes   XML Notes

Getting Started with Windows Azure (Linux) Virtual Machine


Index


Getting Windows Azure

Thanks to a grant from Microsoft, you will have 6-month free access to Windows Azure, which allows you to run a virtual machine in the cloud for the assignments and project in this class.

At the beginning of the semester, you will receive an email from the instructor with a Windows Azure "passcode." Visit http://www.windowsazurepass.com/ to redeem your passcode. You will be prompted to create a Microsoft account if you do not already have one.

You will be notified via email when your free access is granted in a couple of days. Because of this delay, do NOT wait until the last minute to get Windows Azure for your assignment!


Setting up the virtual machine

Creating the virtual machine

Go to https://manage.windowsazure.com/ and sign in with your Microsoft account.

  • Click on the "+" icon at the bottom of the page.
  • Select "COMPUTE", "VIRTUAL MACHINE", and then "QUICK CREATE"
  • For DNS NAME, pick a name for your machine. I suggest dukedb-NETID, where NETID is your Duke net id---this naming scheme makes it easier to track things. The fully qualified host name for your machine would then be dukedb-NETID.cloudapp.net.
  • For IMAGE, select Ubutun Server 12.04 LTS.
  • For SIZE, it is enough to select Small (1 core).
  • For USER NAME, pick a user name (e.g., azureuser) for logging into the virtual machine.
  • For PASSWORD, pick a strong password, because your virtual machine can be accessible by anybody over the Internet.
  • For REGION/AFFINITY GROUP, try to pick one that is closest to you, though the choice will not matter much.
It will take a while for Azure to create your virtual machine. Once the virtual machine is running, the next step is to configure it further for Web access:
  • Select "VIRTUAL MACHINES" from the left side bar, and then click on the right arrow next to your virtual machine.
  • Find and click on "ENDPOINTS" across the top of the page. Here you should see SSH listed as an existing endpoint, which allows you log into the machine remotely via ssh. Leave this endpoint alone.
  • Click on the "+" icon on the bottom of the page. Select "ADD ENDPOINT" to add the following endpoint, which allows your machine to act as a web server:
    • NAME: HTTP
    • PROTOCOL: TCP
    • PUBLIC PORT: 80
    • PRIVATE PORT: 80
    It will take a while for Azure to apply this change.
  • Add another endpoint to allow your machine to act as a Tomcat server (you may skip this step if you do not plan to use Tomcat for your project, but it does not hurt to add it anyway):
    • NAME: HTTP Tomcat
    • PROTOCOL: TCP
    • PUBLIC PORT: 8080
    • PRIVATE PORT: 8080

Setting up after logging into the virtual machine

Use your favorite SSH client to log into the machine you created (if you are unfamiliar with SSH and shell, read below for tips first). The first time you log in, run the command "sudo apt-get upgrade" to update the operating system. When finished, run "sudo shutdown -r now" to reboot the machine. You will have wait for a while before it is ready again to accept remote login.

  • Note: The first time you update, you will likely update a program called grub-pc and you will be asked to configure it via an awkward terminal-based interface (with a magenta background). Use uparrow and downarrow to scroll the text/selections, use the tab key to highlight different fields/buttons, use the space key to toggle a selection, and use the return/enter key to "press" a button. On the first screen, tab to "ok" and hit return; on the second screen, hit space to select /dev/sda and then hit return. The update will then continue.

After updating the operating system, SSH into the machine again---this time to set it up for the course. Issue the following commands in order:

  • wget http://www.cs.duke.edu/courses/fall13/compsci316/vm/sync.sh
    • If you have trouble downloading the file because of DNS issues, try replacing www.cs.duke.edu in the URL above with its IP address, which is 152.3.140.5.
  • bash sync.sh
    • If you have trouble downloading because of DNS issues, do the following instead: "bash sync.sh http://152.3.140.5/courses/fall13/compsci316/vm/dbcourse.tgz".
  • /opt/dbcourse/install/install.sh
You will be prompted to pick a database password at some point, so keep an eye on the installation screen.

ADVANCED USERS ONLY

Instead of using Windows Azure, you are welcome to use your own server for assignments and project. In this case, just download the file dbcourse.tgz (see above for its URL). Once you download that file, untar it and explore the directory install/ to see what needs to be installed on your own server.


Tips on using (Ubuntu) Linux

In the following, HOSTNAME refers to the fully qualified host name of the virtual machine (e.g., dukedb-junyang.cloudapp.net), and USER refers to your user name (e.g., azureuser).

Logging in using SSH

You can use an SSH (secure shell) client to access HOSTNAME. Depending on the computer from which you work, the choice of SSH client varies:

  • For Windows, you can use F-Secure SSH Client (free from Duke OIT).
  • For Mac OS or Linux, there is no need to install anything. Just open up a terminal, and type "ssh USER@HOSTNAME".

Once you login, you will be inside a "shell" with a command-line interface. See below for more tips on how to work in the shell.

Shell basics

A lot of your work will be done from within a "shell" (more precisely, a bash shell) on HOSTNAME. The shell has a command-line interface. When it is ready for your commands, it displays a shell prompt. On our virtual machine, it has the form USER@HOSTNAME:current_path$, where current_path tells you where you currently are in the directory (folder) hierarchy. For example, the prompt may be azureuser@dukedb-junyang:~$; here, ~ stands for your home directory. You type in a command, hit return, and the command will execute. When the command finishes, the shell gives your another prompt. If a command hangs and you want to stop it, ctrl-c will usually do the trick.

If you are new to shell, please check out this tutorial (link) for beginners. At least go through the sections "Navigation," "Looking Around," and "Manipulating Files." We highly recommend going through the entire tutorial; it is not that long.

A useful (but potentially damaging) command is sudo, which gives you the power of the root user (a.k.a. the superuser). "sudo command..." will execute "command..." as root. Normally you shouldn't need to use sudo often, but it is often required when you need to install something or access some protected files from the shell. For example, to look at the protected file /etc/tomcat6/tomcat-users.xml (which contains Tomcat manager account passwords), you will need to run "sudo less /etc/tomcat6/tomcat-users.xml". For security, sudo will verify your password every now and then.

To edit text files and code, you can use nano. In a shell, use the command "nano filename" to edit a file. More powerful editors include vim (also preinstalled on our virtual machine) and emacs. Read the section on maintenance and software installation below for instructions on how to get alternative editors on your virtual machine.

Working with remote files on your local computer

You can use FileZilla (free from Duke OIT) to transfer files between HOSTNAME and your local computer. For example, to submit files on HOSTNAME for grading, you can first use FileZilla to download them to your local computer, and then use a browser on your local computer to submit them via the course website.

If you hate using editors on HOSTNAME inside an SSH client window, then with FileZilla (or other similar programs), an alternative workflow is to create/edit code or input files on your local computer (using whatever your favorite editor is), use FileZilla to upload them to HOSTNAME, use the SSH client to work with these files on HOSTNAME, and then use FileZilla to download any output files from HOSTNAME to your local computer. You will need to remember to synchronize the files constantly and appropriately, however.

Yet another possibility with FileZilla is to use its built-in file editing future. You will need to enable it explicitly under settings; make sure you choose to "watch locally edited files and prompt to upload modification." Once enabled, this feature allows you to select a remote file in the FileZilla interface and view/edit it in-place.

Maintenance and software installation

You may need to periodically update the operating system and software on your virtual machine to keep it safe from attacks. When you login, you may see a message informing you that some number of "packages can be updated." If that is the case, issue these commands:

  • sudo apt-get update
  • sudo apt-get upgrade

Looking for a particular software? Visit http://packages.ubuntu.com/ to browse/search for it. Once you find the "package name" for the software that you wish to install (say emacs), go into the shell and issue the command "sudo apt-get install emacs".

Last updated Wed Sep 11 10:18:07 EDT 2013