Lab 1
CPE 437
Overview
In this lab you’ll configure a basic Fedora 11 server installation to run a basic web server (Tomcat only) backed by a MySQL database. Systems administration skills are part and parcel of dynamic web development, and almost all Java-based dynamic websites run on Linux machines, typically RedHat Linux, of which Fedora is a variant. (Debian/Ubuntu users, I am one of you and do not want to get into a Linux version debate :).)
While some Linux sysadmin tasks can be done via Gnome or other GUI interfaces, the large majority are conducted via the commandline. If you are rusty on Linux commandline, this is your golden opportunity to bring yourself up to speed. Linux commandline is assumed background for the course. I won’t teach it directly; there is a good intro under the TLDP link I gave you in the required reading. Find that guide, and have it handy as a reference.
Another essential element of sysadmin work is puzzling things out with often geeky, badly-written documentation, or no documentation at all. Successful sysadmins are used to this, and I want you to have some experience with it as well. I have tried in the lab below, and in the supporting lecture, to give you enough information to make this doable without handholding you through it. (If you find this frustrating, rest assured that your instructor just spent about a half day doing all this himself, complete with the occasional upper-arm gesture to the monitor :), so I sympathize, but I survived it, and so can you.) Some general strategies:
1. Obviously, use the web. There was a time when much of this information could be obtained only from “the old men around the campfire”. They’re still useful, but Google puts them largely out of work on general-knowledge issues like Linux sysadmin.
2. Do not settle for one source of information if several are available. What one explains poorly or not at all, another will cover well, and vice versa.
3. EXPERIMENT. Anyone who says CSC is not an experimental science has never done sysadmin :). If the documentation isn’t clear, then form a hypothesis as to *how* things work, and test the hypothesis.
4. Be creative and find workarounds. As a concrete example, I could not for love or money find documentation on where-the-hell yum (see below) placed the jar files installed as part of various packages – kinda useful information for setting a Java classpath. Yum didn’t appear to have any “tell me what files you’re installing, dammit” option. (And it responded poorly to profanity, too.) I finally checked the older “rpm” package-management utility, and found an appropriate option there. (You may want to note that.)
5. Take notes as you go, so you know how to build a machine from scratch. The odds are nonzero that you’ll hork your machine at some time during the quarter. The fix will be to reimage it back to the basic configuration (easy to do) and then redo the web server setup (also easy if you have notes from the first time.)
Procedure
With that prolog, here’s what you need to do for the lab:
1. Log onto your F11 machine in the lab as “user” (unless you’re doing this remotely, in which case see below), using the root password I will distribute (all root accounts have the same one until step 2). Bring up a terminal window, so you can work in text mode. Su to root in that terminal window, so your commands will be run under root privilege. If you’re working remotely, get an SSH client (Putty is reasonable, and free) and connect via SSH. With SSH you can log in directly as root and skip the indirection.
2. Change your root password. Now! And please pick a good one. (If you don’t know how, see the passwd command.) Create a nonroot user for yourself. Relogin as your username, and then su to root. It’s a good security rule never to log in directly as root, and in fact some systems (e.g. Ubuntu) prevent this automatically. We’ll at least use good practice with our Fedora systems. (And for the Ubuntu fans, no, I don’t plan to force everyone to use “sudo”.)
3. Read up a little on the yum utility (this is specific to RH/Fedora, and not a general Linux command). You’ll be using yum to install various packages that aren’t on your vanilla F11 machine.
4. Read up on how to install MySQL on a Linux machine, and use yum to install MySQL. In particular, after installing the package:
a. Initialize the database.
b. Start up the mysqld daemon (by hand this time, though it should start on reboot in the future).
c. Set your root password.
d. Run the mysql client, and check the tables in the test database.
e. Configure an additional user with all privileges from root@<yourhost>.csc.calpoly.edu. This will enable tunnelling later. Give this user the same password as your root@localhost user.
g. Log and submit to me a paper copy of the user, host, and password entries from the user table. (I’ll use this to confirm you got set up OK and do not have security holes in your MySQL config.
4. Install Java 1.6 and related tools.
a. The OpenJDK implementation of Java is what is available on F11. Install this.
b. Be sure you get the utilities, such as jar, too.
c. install the J/Connector JDBC adapter for MySQL.
d. Write small Java program that queries your MySQL database via JDBC (example code to work from is in Murach) and dumps a list of all users. (This will ensure you’re getting classpaths, etc. right.)
5. Install Tomcat6
a. Check out the Tomcat configuration files server.xml and context.xml, and read the configuration documentation for Tomcat, to get a reasonable sense of what those files contain.
b. Start the Tomcat server, and use a web browser to hit port 8080 on localhost. You should get a placeholder page.
6. Install MusicStore and run it.
a. Download the full set of Murach files.
b. Unpack the musicStore.war file using jar, and edit the musicStore/META-INF/context.xml to reflect the correct root password. (All other values should be OK.) Repackage it into a war file again.
c. Create the “music” database, using the db/create_db.sql file from Murach.
d. Drop the musicStore.war file into the Tomcal webapps directory. Access the musicStore app at localhost (or at your machine name if you’re workiing remotely) port 8080, with the suffix “/musicStore”.
7. Arrange tunnelling from off campus.
a. From an offcampus machine, get an SSH client (see above), and configure it to tunnel from port 3306 (the standard MySQL port) on your local machine to port 3306 on your server.
b. Look up host commandline options for the mysql client, and connect to your server database from the offsite machine. Note that you’ll do this by connecting to “localhost” on the offsite machine, but that the SSH server on your will make the tunnelled connection using the server machine’s full hostname on its end, so the serverside MySQL database will see this as a connection with the server machine’s hostname.
8. Optionally, set up Eclipse
a. Install Eclipse on your server, if you like, and on your offcampus machine as well. I will only help with IDE questions on Eclipse; I cannot offer support for other IDEs such as NetBeans – you’re on your own if you use them.