Archive for linux

Setting up VirtualBox Guest VM Server Networking via NAT

I recently took Atlassian up on their Starter Pak deal to help manage some personal projects I’m hoping to kick off. I’m a big fan of their work, and their entire suite has performed extremely well for us at work for the last 3 years.

While I could run the software directly off of my iMac, my preference (and the environment I’m ultimately most comfortable in) is to run them under Linux. To accomplish this, I downloaded the latest version of Xubuntu and installed it within VirtualBox for OS X. Being the lazy man that I am, I did a plain-vanilla VirtualBox install.

After a quick apt-get to install OpenSSHd (and trying to connect via the host OS back to the guest), I realized that the default network settings would not allow me to see back into the guest OS (Xubuntu) from the host (OS X) (The other way around works fine, btw).

The VirtualBox documentation presents a few different ways to resolve this (NAT, Bridged and Host-Only). Once again, I decided to take the path of least resistance…which is to do simple port-forwarding from the host OS to the guest OS. The result is that when a resource is requested on host OS port, it just forwards the request to the mapped guest OS port.

I have 3 primary services that I’m looking to forward: SSHd (22), Apache (80) and Tomcat (8080)….so my mappings look like this:

Host OS Port 2222 –> Guest OS Port 22 (SSHd)
Host OS Port 10080 –> Guest OS Port 80 (Apache)
Host OS Port 18080 00> Guest OS Port 8080 (Tomcat)

When VirtualBox is installed, it places a few command line utilities on the host OS. The command that is needed to setup port-forwarding is VBoxManage. There are 3 values that must be set for port-forwarding to work: Protocol, HostPort and GuestPort. Below are the commands I executed to setup SSH port-forwarding:

VBoxManage setextradata "Xubuntu"
  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP

VBoxManage setextradata "Xubuntu"
  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22

VBoxManage setextradata "Xubuntu"
  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222

The value “guestssh” is somewhat arbitrary…it just needs to be the same for all 3 values. The other difference you might have is if you have chosen a different virtual network adapter (pcnet) when you setup your VM. When in doubt, check the VirtualBox documentation.

That’s basically it…just rinse and repeat for any other services that you want to run on the guest OS and have visible from the host.


Cheap backups with Dreamhost + rsync

In my last post (I know, it’s been a while), I was gushing about how my hosting provider (dreamhost.com) was allowing 50GB of disk space for personal backups included with basic hosting plans.

The excitement was a bit premature at the time, because they only allowed backups via FTP. It instantly became problematic to regularly backup anything of significant size (i.e. 30 GB of MP3s) due to my lack of knowledge of doing incremental backups over FTP. If only they would allow rsync over ssh.

Apparently I was not the only person thinking this because the dorks of the internet united, Dreamhost listened, and today I got the monthly newsletter letting me know that rsync, scp and sftp were enabled….Sweet!

So I got crackin’ tonight on my new solution, which is thus:

1. Super-simple backup script (offsiteRsync.sh)

#!/bin/bash

# Sync the local directory to the remote server, limiting the
# upload bandwidth to 10KBps
# Sync via ssh and compress the files over the wire
rsync -avz -e ssh --delete --bwlimit=10 /Users/eric b159xxx@backup.dreamhost.com:~

2. Setup ssh keys so I can run the above script via cron..

lenny:~ eric$ ssh-keygen -t rsa

After typing the above in, I hit enter twice to accept the default directory for the keys and to choose a password-less key

Then I just copied the last (or possibly only) line from .ssh/id_rsa.pub on my local machine (lenny) to the .ssh/authorized_keys file on the remote machine (backup.dreamhost.com)

3. Test!

4. Setup the whole mess via cron, as noted in my previous post.

OSCON 2008 – Day 2

Morning Keynotes

Two of the presenters (Tim O’Reilly and some dude from Intel) talked alot about Linux on mobile devices and cloud computing.  A couple of terms that I think we’ll be hearing more soon are: MID’s = Mobile Internet Devices (think iPod Touch) and Netbooks = small-ish laptops like the Asus EEE PC.

Sessions

OpenJDK
Pretty much just talked about the timeline of pushing for an opensource version of Java and how it all started back with GNU Classpath and gjc.  The OpenJDK is still currently running a bit behind Sun’s commercial releases, but hopefully they can catch-up around Java 7.

One nice effect of OpenJDK is now Java is started to be included by default on many Linux distro’s (Debian, Fedora, etc).

Leveraging XMPP for Cloud Computing
Wish I could tell you more, but the talk was at capacity and they wouldn’t let anyone else in.  Reminded me of Thursday nights at Harpo’s in Columbia, MO during college and their “1 in, 1 out” policy.

Groovy -vs- JRuby…which one should you use?
I basically took away from the talk that it’s pretty much a wash as far as features go.  Groovy is going to be a bit easier for normal Java dudes.  Supposedly Sun has put a lot of nice features in Netbeans for JRuby support…so I might have to give it a spin.

JavaFX
There was a lot to like about this talk…especially since my group at work is heavily invested in JavaFX.  I’ll list out some of the new goodness in bullet form:

  • Java 6 update 10 is due out late summer, is a consumer-focused release focusing on improving the Java user-experience
  • Applets will now run out-of-process.  This means a couple of things: A hung applet will not crash the browser and now you can have “draggable” applets that you can pull onto the desktop.
  • Applets will now share a lot of the same features as Java WebStart apps.
  • crossdomain.xml files will be available to allow for “mashups”
  • Hardware graphics acceleration is now on by default.
  • Moving toward a more modular JRE (Java Kernel)
  • Working on video support.  Java will just wrap whatever video codecs are present on the local system.  Sun is also working on a native Java video codec.
  • Check out more about 6u10 here.

New JavaFX Stuff:

  • JavaFX Script meant to resemble Javascript (more comfortable for web designers)…but you can still call normal Java code.
  • New “javadocs” format for JavaFX
  • Netbeans plugin for JavaFX – syntax highlighting, code completion, preview
  • Photoshop and Illustrator plugins that can export to “FXD” files.  Also a tool that will convert SVG’s to FXD’s

XMPP for Cloud Services
Yet another cloud computing session that was completely jam-packed.  People seem to be bonkers about anything and everything “cloud”.

Talked mostly about how the REST polling method used in most web2.0 apps today scales horribly.  Using a PubSub methodolgy scales much better.  XMPP is built from the ground up for this type of scenario.  I’m still trying to figure out how in the Java world this would be better than just using a JMS provider like ActiveMQ.  Sounds like this might be problem that is being solved by these guys.

BONUS

Unbeknownst to me, I sat down for lunch at a table with Steve Souders.  He literally wrote the book on high performance web sites and is the creator of the YSlow! plugin for Firefox/Firebug.  He was an unbelievably nice guy and we had a good conversation about all things web, Yahoo! and Google (his current employer).

OSCON 2008 – Day 1

Technically, it’s day 2…but it’s day 1-ish for me.

I got into Portland around 2PM local time.  Checked-in to the hotel, then ran over to the convention center to check-in for the conference.  Probably the worst conference bag I’ve ever got.  That said, I think I have 5 computer backpacks lying around by now…so I’m definitely on overload.  Tech conferences need to move on to something else.

Not being familiar with the area and having not eaten in about 10 hrs, I went the path of least resistance and stopped by the mexican restuarant in the hotel (come to find out later it’s named “Eduardo’s Cantina”…if I’d known that, I probably would have just moved along).  I ended up chatting for a good long while with Josh Marinacci from the JavaFX team at Sun…which was cool because we’ve been working with JavaFX for well over a year now at work (I don’t think many people can say that…and even less could say they have an app in production using JavaFX).

Later in the night, they had an “Extravaganza” back over at the convention center.  There where 3 main parts (that I stayed for):

Mark Shuttleworth: Founder of the Ubuntu project, as well as the commercial company supporting Ubuntu, Canonical.

He spoke about the economics of open source, software development methodologies (specifically Agile/Scrum/XP) and building software that encourages others to extend.  I’m sure my synopsis doesn’t do it justice, but overall a good talk.

Next, O’Reilly/Google gave out some Open Source awards.  I’m sure you can check out their site for the low-down

Finally (for me), Robert Lefkowitz gave a talk about software development methodologies.  The theme of Agile/XP came up yet again.  It definitely feels like (at least from attending conventions) that we’re at a tipping point on Agile methodoligy acceptance.  One thought I hadn’t had until tonite is that this is closely tied to the rise of open source.  In most open source projects, there aren’t a lot of requirements made up front..people either use (and by extension, like) what you’ve built, or they don’t and go elsewhere.  If they do like your product, instead of creating “requirements” for new features, they just submit bug reports…which get triaged appropriately.  Sounds pretty efficient.

Quick Ubuntu Server Setup

I’m amazed at how easy it is to get a server up and running these days. From a fresh HD (or VM image if that’s your thing) to a fully functional LAMP+ server in just under an hour (depending on the size of your pipe).

Here’s a good HOWTO.