Click. Connect. Learn.

All posts in Ubuntu

Do not rename your VirtualBox .ova file

The other day I built a VirtualBox image that contains a close approximation of the server environment of one of our customers. The image contains Ubuntu 10.04 LTS server along with apache, PHP, MySQL, and everything else needed to run their Drupal site. Since VirtualBox 4, it's possible to export appliances in .ova format, so that's what I did, and I stuck it up on our network drive for everyone to use. Of course, I tested it first and it imported fine.

The problems started when other people tried to import the appliance and they got the fun message "Failed to import appliance ... Could not read OVF file 'basebox.ovf' (VERR_TAR_END_OF_FILE)." Oh, the one thing I forgot to mention is that I renamed the .ova file when I put it up on the network drive (sorry about that, Bill).

Could not read OVF file (VERR_TAR_END_OF_FILE)

Do not rename your .ova files if you plan to import them with VirtualBox. What exactly is an .ova file? Read OVF? OVA? WTF? to find out. It's got a good explanation and links to some other resources. The interesting tidbit for us, as VirtualBox users, is that we can't rename our .ova files and expect them to import because (apparently, and I probably just didn't read the fine print) the base name of the .ova file is also used in the names of the files (or at least the important ones) contained in the .ova archive.

Having trouble importing an .ova file and seeing VERR_TAR_END_OF_FILE? Run "tar tvf virtualboximage.ova" (where virtualboximage.ova is the name of your .ova file) and check out the names of the internal files. If the base names don't match, then rename your .ova to have the same base name as the internal .ovf file and try again.

Installing geoserver on ubuntu 10.04

geoserver logo

Following the below steps should get the binary release of geoserver running on your 10.04 ubuntu install. This should also work generically for other versions of ubuntu. This process does not step you through securing or completely preparing the geoserver for production use, these details are outside the scope of this tutorial; please review the appropriate sections on security and running in a production environment via the geoserver documentation. Also if you are intending to run this geoserver in a production environment you should review any firewall and/or system settings that may be appropriate for your use case.

Install necessary supporting libraries and applications.

I think this is complete, but it may not be. If you run into any missing packages please indicate which packages also need to be installed in the comments so that others may benefit from your effort.


sudo apt-get update
sudo apt-get install gdal-bin openjdk-6-jdk openjdk-6-jre python-gdal unzip

Download the latest stable or latest release of geoserver.

In my case I grabbed Geoserver 2.1-RC4. These instructions should apply generically to the 2.0.3 release and hopefully others.


cd ~
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-bin.zip

Extract the release into your directory of choice.

In my case I chose '/opt' if you choose a different directory and release please substitute accordingly.


cd /opt
sudo unzip ~/geoserver-2.1-RC4-bin.zip 

Setup system for running geoserver.

Create a symlink

We want '/opt/geoserver' to point to '/opt/geoserver-RELEASE' so that we can easily upgrade geoserver at a later date.


sudo ln -s /opt/geoserver-2.1-RC4 /opt/geoserver

Download geoserver extensions.

Follow the extension download link for whichever version you downloaded in the previous step here. Grab any extensions you want to install. I grabbed the following;

  1. MySQL Data Store
  2. GDAL Coverage Store
  3. OGR output format

After downloading the extensions extract them to '/opt/geoserver/webapps/geoserver/WEB-INF/lib'.


cd ~
mkdir geoserver_extensions
cd geoserver_extensions
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-mysql-plugi...
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-gdal-plugin...
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-ogr-plugin.zip
find . -name \*.zip -exec unzip -o {} \;
sudo cp -rp *.jar /opt/geoserver/webapps/geoserver/WEB-INF/lib/

Add a geoserver user and group

Next we create a group and user that geoserver will run as:


sudo addgroup --system geoserver
sudo adduser --system --ingroup geoserver --no-create-home --disabled-password geoserver

Setup startup script

In order to start geoserver automatically at startup we need an init script. I grabbed the Debian/Ubuntu script located here.


cd /opt/geoserver/bin
sudo wget -O initd.sh http://docs.geoserver.org/latest/en/user/_downloads/geoserver_deb
sudo ln -s /opt/geoserver/bin/initd.sh /etc/init.d/geoserver
sudo chmod +x ./initd.sh

This script needs one slight modification to be better suited to ubuntu. Change the following line


# Default-Stop:      S 0 1 6

to


# Default-Stop:      0 1 6

This should be line 7 of the file.

Change ownership of the geoserver directory

The geoserver install directory should be owned by the geoserver user and group we just created.


sudo chown -R geoserver:geoserver /opt/geoserver-2.1-RC4/

Set the default startup parameters

Use your editor of choice and create a new file '/etc/default/geoserver'. The commented lines, starting with '#', indicate the default as provided in the startup script.


#USER=geoserver
#GEOSERVER_DATA_DIR=/home/$USER/data_dir
GEOSERVER_DATA_DIR=/opt/geoserver/data_dir

#GEOSERVER_HOME=/home/$USER/geoserver
GEOSERVER_HOME=/opt/geoserver

#PATH=/usr/sbin:/usr/bin:/sbin:/bin

#DESC="GeoServer daemon"

#NAME=geoserver

#JAVA_HOME=/usr/lib/jvm/java-6-sun
#DAEMON="$JAVA_HOME/bin/java"
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
DAEMON="$JAVA_HOME/bin/java"

#JAVA_OPTS="-Xms128m -Xmx512m"
JAVA_OPTS="-Xms128m -Xmx512m -server"

#PIDFILE=/var/run/$NAME.pid

#SCRIPTNAME=/etc/init.d/$NAME

Set the geoserver to launch on startup


sudo update-rc.d geoserver defaults

Setup log directories


sudo mkdir /opt/geoserver/webapps/geoserver/data/logs
sudo chown geoserver:geoserver /opt/geoserver/webapps/geoserver/data/logs/

Configure OGR based WFS output format

This allows geoserver to export a bunch of formats that geoserver does not handle natively. The conversion is done through the ogr library see OGR Simple Feature Library for more information on the capabilities of the gdal/ogr library. The following XML lets geoserver know where to find the ogr2ogr binary and the GDAL_DATA directory. Add the following XML to '/opt/geoserver/data_dir/ogr2ogr.xml'


<OgrConfiguration>
  <ogr2ogrLocation>/usr/bin/ogr2ogr</ogr2ogrLocation>
  <gdalData>/usr/share/gdal16</gdalData>
  <formats>
    <Format>
      <ogrFormat>MapInfo File</ogrFormat>
      <formatName>OGR-TAB</formatName>
      <fileExtension>.tab</fileExtension>
    </Format>
    <Format>
      <ogrFormat>MapInfo File</ogrFormat>
      <formatName>OGR-MIF</formatName>
      <fileExtension>.mif</fileExtension>
      <option>-dsco</option>
      <option>FORMAT=MIF</option>
    </Format>
    <Format>
      <ogrFormat>CSV</ogrFormat>
      <formatName>OGR-CSV</formatName>
      <fileExtension>.csv</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>text/csv</mimeType>
    </Format>
    <Format>
      <ogrFormat>KML</ogrFormat>
      <formatName>OGR-KML</formatName>
      <fileExtension>.kml</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>application/vnd.google-earth.kml</mimeType>
    </Format>
  </formats>
</OgrConfiguration>

Start the geoserver


sudo /etc/init.d/geoserver start

Test the geoserver

Now if everything has gone according to plan the geoserver should be running and accessible on port 8080. The default username and password are admin and geoserver respectively. You should review the security documentation for geoserver to properly secure the login and points of access.

Troubleshooting

Note that it can take geoserver quite a bit of time to actually bind to port 8080 and start responding. If you attempt to access geoserver on port 8080 and get an error message then wait a few minutes and try again. You can check to see if the geoserver is running by doing the following

  

ps aux | grep java

This should show something like the following indicating that the geoserver process is running.

  

5487 ?        Sl     0:21 /usr/lib/jvm/java-1.6.0-openjdk/bin/java -Xms128m -Xmx512m -server -DGEOSERVER_DATA_DIR=/opt/geoserver/data_dir -Djava.awt.headless=true -jar start.jar

If you see the geoserver process is running you can check to see if it has opened port 8080 and is listening for requests with the following


sudo lsof | grep TCP | grep geoserver

You should expect to see something like the following;


java      5487 geoserver  237u     IPv6      20420      0t0        TCP *:46378 (LISTEN)
java      5487 geoserver  249u     IPv6      20435      0t0        TCP *:http-alt (LISTEN)  

If you do not see the above but the java process is running just wait a few minutes as it can sometimes take a while for the geoserver to bind to port 8080.

The Other Wes Moore

The Other Wes Moore

I first heard about The Other Wes Moore on OPB's Think Out Loud. It was this year's book selection for Everybody Reads at our awesome Multnomah County public library.

There are plenty of book reviews out there, but the book is such a quick read that it'd be better to just read it for yourself. Something in there will resonate with you. For me, more than just about anything, it was this:

Even a legacy as ugly as that of Cecil Rhodes -- a nineteenth-century imperialist, white supremacist, and rapacious businessman -- could be turned around and used by a person like me, someone Cecil Rhodes would've undoubtedly despised, to change the world that Rhodes and people like him had left for us.

Oh, and if you're an Ubuntu fan you won't be disappointed either.

How to get an iPad running in 12 hours

Here's how I got an iPad up and running in roughly 12 hours:

11:00 am - Arrive at the Apple Store at Pioneer Place. First time I've been in the mall since we moved to Portland 7 years ago.

11:45 am - Depart Apple Store with iPad, a case and a small box full of extended warranty. Not much packaging, so it all fits easily into a single Ortlieb front-roller classic pannier. Get me outta here!

12:00 noon - Boot up the iPad in the office. Can't get started because it needs to be connected to either a Mac or PC running iTunes.

I don't have a PC or Mac in the office any more because a few months ago I converted all my machines over to Ubuntu (and have been a happy camper ever since). I've never owned a Mac, but my dad bought an Apple IIe in 1983 when I was in 11th grade. I'm not sure where that machine is now, and I suspect iTune$ wouldn't run on it anyway.

The only PC left in our house is my wife's laptop that she uses for work. She had iTunes on her laptop at one time for a few days but got rid of it. Instead, she uses the software that came with her SanDisk Sansa for transferring music and podcasts. I'm not going to put iTunes back on her laptop.

This will have to wait until tonight after the kids are in bed. I'm sure I've got a few Windows XP discs at home that came with the many Dells that have come and gone (and still survive) over the years. I guess it's time to re-install Windows on the old 486. Maybe I should have taken the Apple Store folks up on their offer of a 20 minute appointment to set up the iPad.

8:00 pm - Kids are in bed. Time to get the iPad going! Heading down to the basement to look for a Windows XP disc. Can't find one, but I found a whole bunch of MSDN and Visual C++ discs -- please let me know soon if you'd like some (or all) of them or they're gonna end up at Free Geek along with three boxes full of computer cables, cards, input devices, output devices, gizmos and other doodads.

Might as well recycle some boxes and clean out the basement a bit while I'm down here.

9:00 pm - Finally found an XP disc in the basement. Instead of trying it out on the 486, though, I'm going to create an XP VirtualBox image -- been meaning to do that for a while anyway. There's really nothing left that I need to run on Windows any more (now that I've got QuickBook$ Online working in Firefox via Wine on Ubuntu), so it'd be a shame to waste a whole computer just to run iTunes.

The VirtualBox image works like a charm! I gave it 768M of RAM and a 10GB variable size disk. The network is configured for bridged ethernet so it can grab a dynamic IP address from the server in the basement that's running dnsmasq. Installation of XP seems to require a few more clicks (and time) than I remember -- guess I'm just used to Ubuntu now.

9:45 pm - Now that XP is running in a VirtualBox (yippee) I'd like to register my copy of Windows, because that's just what you are trained to do when you run Windows. Now, I've got no idea which one of the computers the XP disc came with, but hopefully that won't matter. All the computers came with Windows on them and they're all now running linux, so I'm hoping this'll go smoothly.

Well, the code on the bottom of my laptop didn't work so I've got to call Micro$oft to get a new product key -- good thing they've got support folks working 'round the clock to give out new product keys for the products that we've purchased (and purchased, and purchased). After typing the code into the phone, getting routed to a real live person, repeating the code verbally to the technician, getting a new code to try (and a few other steps I can't remember), the key on the bottom of the laptop now works! I've got a VirtualBox image with a registered copy of XP where iTune$ is going to live.

10:15 pm - Before installing anything on a VirtualBox image, it's a good idea to create a snapshot of the image in case a rollback is required. Since the mouse isn't getting captured seamlessly by the XP instance and I can't maximize the screen, it's going to be painful running XP in VirtualBox without installing the Guest Additions, so I'd better do that before getting to the iPad setup.

10:30 pm - The Guest Additions work great, and hey, it actually seems like XP is nice and snappy -- probably because there's no virus scanner installed (which Windows is happy to keep reminding me). We're still paying for the annual subscription to a 3-pack of anti-virus licenses for one of the commercial virus scanners, and we're only using 1 license right now (since, remember, Ubuntu's on the other machines), but finding an open source one for Windows goes on the TODO list.

Let's see -- oh yeah, the iPad. Where did that thing go, anyway? XP doesn't recognize the iPad right away, but after fiddling with the VirtualBox USB settings, it looks like we're going to get registered! All that's left to be done is to decide which credit card to let iTunes keep on file because, in order to use an iPad, remember, you need a credit card. And a PC or Mac.

11:15 pm - Wow, that was a lot of work to get the iPad up and running. And now for the big payoff -- watching a replay of the Italy v. Germany friendly on e$pn3.com on the brand new iPad via work's Comca$t Remote Acce$$ (because we've got Speakeasy DSL at home).

Never mind -- e$pn3.com uses Flash to deliver its content, so I guess I can't watch it on the iPad. Guess I'm gonna have to figure out the "App Store" but that will have to wait for another day. Good night.

Syndicate content