CPS 116 (Fall 2011):
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
PHP Notes
XML Notes
Homework/Project Submission
Blackboard (Grades)

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, also download and install the Oracle VM VirtualBox Extension Pack.

VirtualBox is free, open-source, and works on all common operating systems. 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 operating systems that are different from your host operating system; you can run them simultaneously and switch back and forth. 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:\cps116\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.

  • NOTE: The ZIP file posted earlier incorrectly clears all permission bits for its content files. Thus, you might have run into problems when starting the virtual machine (VERR_VD_IMAGE_READ_ONLY). To resolve these problems, you need to manually change the the permissions of the unzipped files in your host operating system; you should at least give yourself read and write (or full control) permissions. Alternatively, you can download the TGZ file above, which does not have any permissions problems.
  • 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-ubuntu-11-04.vbox. If all goes well, you should see "dbcourse Ubuntu 11.04" appearing as a virtual machine inside the VirtualBox manager. Select it and click on "Start" to fire up the machine!

  • NOTE: If you get the error "Implementation of the USB 2.0 controller not found" when trying to start your virtual machine, you probably forgot to install the Oracle VM VirtualBox Extension Pack. (For more details, see this discussion.)

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 upper-right corner of your virtual machine desktop, and select "Auto eth0"). Once you are sure that you have an Internet connection, open a terminal 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 panel across the top of the desktop; you can also find it under Applications:Accessories.

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.

Our default text and code editor is nano. In a shell, use the command "nano filename" to edit a file. Another powerful editor (which runs in its own window and also supports a point-and-click interface) is emacs; we have created a shortcut for you on the panel across the top of the desktop. Of course, you are welcome to use other editors (such as vim) or development environments (such as eclipse). Read further to see how to install them on your virtual machine.

A useful (but potentially damaging) command is sudo, which gives you the power of the root user (or 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".

Software installation and maintenance

Under System:Administration, 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 the operating system and software. You should install these updates when prompted.


Tips on using VirtualBox

When working with a virtual machine, if you find that it's grabbing all your mouse and keyboard events but you want to get to your host machine instead, press (and release) the right Ctrl key.

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.

You might find VirtualBox Guest Additions extremely useful. 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.

The default screen size of our virtual machine is small. You might want to change its size and resolution to match your physical display. Installing Guest Additions mentioned above will help you do that automatically.

Last updated Sun Sep 11 21:40:15 EDT 2011