CompSci 316 (Fall 2012):
Introduction to Database Systems

Course Information
Lecture Notes
Assignments
Tentative Syllabus
Programming Notes
Getting Started with the dbcourse Virtual Machine
Getting Started with Gradiance
PostgreSQL Notes
Using ra
JDBC Notes
Tomcat Notes
Django Notes
PHP Notes
XML Notes
Homework/Project Submission
Sakai (Grades/Project Discussion)

Getting Started with the dbcourse Virtual Machine


Index


Installing VirtualBox

Download and install the latest version of VirtualBox on your personal computer (with at least 1GB of memory and 5GB of free disk space). In addition to the VirtualBox platform packages for your personal computer's operating system (OS), also download and install the Oracle VM VirtualBox Extension Pack (which can also be found under VirutalBox's Preferences/Extensions/AddPackage). You must have this extension pack installed before running our virtual machine image.

VirtualBox is free, open-source, and works on all common OSs. It is a virtualization software that allows you to run "virtual machines" on top of a physical machine (called the host). These virtual machines can use OSs that are different from your host OS; you can run them simultaneously, and switch between them instantaneously. For example, while using your Windows host, you can also run a Linux virtual machine in a window. The state of the virtual machine is stored as a file on the host's hard drive; other than that, what you do on the virtual machine does not interfere with the host.


Setting up the dbcourse virtual machine

We have created a virtual machine image to be used for coursework. All programming tasks in this course can be completed within this virtual machine. First, download this compressed file (TGZ) and decompress it somewhere easy to find (e.g., C:\dbcourse-vbox\) on your personal computer. The file is pretty large, so don't attempt to download it on a slow Internet connection or with a limited data plan! Besides, the link is Duke-only, so use the Duke network to download.

  • ADVANCED USERS ONLY: If you want to roll your own virtual machine image or want to work within your own Linux environment, you will find the file dbcourse-readme.txt useful. In particular, it explains how to set up the /home/dbcourse/ directory containing data and programs relevant to the course.

Start the VirtualBox program. From its menu, choose Machine:Add. Browse to the location where you have decompressed the downloaded file, and open dbcourse-lubuntu-12-04.vbox. If all goes well, you should see "dbcourse Lubuntu 12.04 32-bit" appearing as a virtual machine inside the VirtualBox manager. Select it and click on "Start" to fire up the machine!

After the virtual machine boots up, you will be presented with a login screen. Your user name is "ubuntu" and your password is "reverse". WARNING: Our virtual machine was not set up with tight security in mind. Although it is shielded by your host machine from the outside world, use your common sense, and don't use this virtual machine for conducting sensitive transactions or storing personal information.

The first time you login, make sure the virtual machine has a fast, working Internet connection that is not on a limited data plan. (Usually, as long as your host machine has a working connection, your virtual machine will have one too. If for some reason it does not work, click on the network icon located near the lower-right corner of your virtual machine desktop, and select "Wired connection 1"). Once you are sure that you have an Internet connection, open a terminal (an icon located near the lower-left corner of your desktop) and issue the following commands at the shell prompt (if you are completely new to shell, you may want to first read about the shell basics below):

/home/dbcourse/sync.sh
/home/dbcourse/install/install.sh
These scripts will automatically download and install a bunch of stuff on your virtual machine, and reboot it.

  • ADVANCED USERS ONLY: You can stop after running sync.sh, and explore the directory /home/dbcourse/install/ to see what install.sh does. Also pay attention to the directory /home/dbcourse/etc/, which contains some configuration-related files required for some programming tasks in the course.

Tips on using (Ubuntu) Linux

Shell basics

A lot of your work will be done from within a "shell" (more precisely, a bash shell). The "terminal" program gives you a shell in a window. We have created a shortcut for you on the left of the bottom panel of the desktop; you can also find it from the start menu under Accessories as "LXTerminal".

The shell is command-line interface. When it is ready for your commands, it displays a shell prompt. On our virtual machine, it has the form username@machine:dir$ and may look like ubuntu@ubuntu-VirtualBox:~$. Here, the user name is ubuntu, the machine name is ubuntu-VirtualBox, and ~ 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.

On our virtual machine, the default "pager" (which lets you view the contents of text files) is less. Use the command "less filename" to view a file. Page up/down and up/down arrow keys behave just as expected. When you finish reading, press q to quit.

The default text and code editor is 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. You can also try development environments such as eclipse. Read the section on software installation and maintenance below for instructions on how to get them on your virtual machine.

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".

Shortcuts to the default web browser (Chromium) and file manager are located at the lower-left corner of your desktop, right next to the start menu.

Software installation and maintenance

Under your desktop's start menu's System Tools, you will find a tool called "Synaptic Package Manager", which offers a huge catalog of software programs (packages) that you can install and manage. You can either browse the packages by category, or simply search by command or package name. The GUI is pretty self-explanatory.

  • ADVANCED USERS ONLY: If you prefer command-line, you can instead use apt-get and related commands for package management. In fact, the script /home/dbcourse/install/install.sh uses apt-get extensively.

Ubuntu automatically checks for critical updates to its OS and software. You should install these updates when prompted.


Tips on using VirtualBox

Your virtual machine can either run inside a window on your host machine's desktop, or take the entire screen of your host computer. In the latter case, it will appear as if the virtual machine has exclusive control of your hardware. To switch back to your host OS, press (and release) the right Ctrl key; then you can switch to other applications in your host OS using Alt-Tab (if your host OS is Windows) or Ctrl- or Cmd-Tab (if it is Mac OS).

When you are done working with your virtual machine, instead of shutting it down, you can press RightCtrl-Q to close the virtual machine, but remember to select "Save the machine state" so you don't lose any work. Closing and reopening the virtual machine this way work just like a laptop's suspend function.

VirtualBox Guest Additions are extremely useful, and they are already installed on your virtual machine. Among many of its features, you will be able to access your host machine's files from the virtual machine, copy and paste text between the virtual and host machines, automatically resize the virtual machine's display, etc. (After OS kernel or VirtualBox software updates, guest additions may stop working; in that case you will need to reinstall the guest additions by following instructions in the URL above.)

Setting up File Sharing

While using VirtualBox, you can set up a folder shared between your host OS and guest OS, such that you any files in that folder can be accessed from both:

  1. After starting your dbcourse VM go in the VirtualBox menu at Devices/SharedFolders.
  2. Click the "Add Shared Folder" button (the one with a plus sign) and select from your host OS file system the folder you want to share (e.g., ~/Documents/classes/CPS316 on your Mac). Mark the "Auto-mount" and the "Make Permanent" options (but NOT "Read-only").
  3. In the dbcourse VM go to Menu/System Tools/User Settings. Click Manage Groups and then select from the list the user 'vboxsf'. Click properties and check the box for the user 'ubuntu' (or if you are an advanced user and set up another username on the VM, check that one). You will need to enter your password to make the change.
  4. After rebooting the VM you can find your shared folder in /media with the name preceded by 'sf_' (e.g., /media/sf_CPS316).
Last updated Thu Sep 20 23:16:07 EDT 2012