Monday, August 10, 2009

Installing on a Clean OS

‹prev | My Chain | next›

After losing air conditioning, the main circuit breaker box and a microwave oven this month, I need to examine my finances a bit before signing up for a VPS. In the meantime, I can make a trial run on VirtualBox. I already have the open source edition installed from the Ubuntu repositories.

I download the network installer version of Debian. I opt for Debian rather than Ubuntu because it is best to set up a minimal server, only enabling services as they are needed. Ubuntu is servers made easy—maybe a little too easy as you end up with many services enabled that you do not really need.

In VirtualBox, I create a new Debian server:

On subsequent dialogs, I stick with the base memory size of 256MB, and create a new, dynamically sized disk:

Finally, I configure the VirtualBox machine to boot from the downloaded ISO installer:

The install of the OS is dirt easy. I accept every default presented to me by the Debian installer. At the very end of the install, I ensure that only the base system is installed.

After installing the OS, I boot into the server and install openssh-server. I then shut down the server and establish port-forwarding to the ssh server by issuing the following from the command line of my desktop:
VBoxManage setextradata "eee" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "eee" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "eee" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
The ssh server will be running on port 22 inside the virtual machine. I want to access it locally on port 2222 (to avoid conflicting with the ssh server on my desktop).

While I am at it, I set up port forwarding to the virtual machine's web server as well. I want to access it at http://localhost:8000, but expect the web server to be running on port 80 inside the virtual machine:
VBoxManage setextradata "eee" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestwww/Protocol" TCP
VBoxManage setextradata "eee" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestwww/GuestPort" 80
VBoxManage setextradata "eee" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestwww/HostPort" 8000
I reboot and can now login via ssh:
cstrom@jaynestown:~$ ssh -p2222 localhost
The authenticity of host '[localhost]:2222 ([]:2222)' can't be established.
RSA key fingerprint is 11:5f:38:10:32:18:ea:6d:54:54:d0:4a:1a:5e:36:37.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:2222' (RSA) to the list of known hosts.
cstrom@localhost's password:
Linux debian 2.6.26-2-686 #1 SMP Sun Jul 26 21:25:33 UTC 2009 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Aug 10 20:58:16 2009
Now I can begin installing packages. First up, sudo—I am spoiled by Ubuntu and almost habitually type this command when doing sysadmin work. I configure it for my user by editing the sudoers file via visudo and making the following change:
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
Then I add myself to the sudo group with the vigr command, making sure to add this line:
I save that, logout, log back in as myself and now have sudo privileges.

First up is CouchDB, of course:
cstrom@debian:~$ sudo apt-get install couchdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
erlang-base-hipe erlang-nox libicu38 libltdl3 libmozjs1d libnspr4-0d libsctp1 lksctp-tools odbcinst1debian1 unixodbc
Suggested packages:
erlang-x11 erlang erlang-manpages erlang-doc-html libmyodbc odbc-postgresql libct1
The following NEW packages will be installed:
couchdb erlang-base-hipe erlang-nox libicu38 libltdl3 libmozjs1d libnspr4-0d libsctp1 lksctp-tools odbcinst1debian1 unixodbc
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 36.1MB of archives.
After this operation, 64.1MB of additional disk space will be used.
Do you want to continue [Y/n]?
Nice. I was a little worried that Debian might not have it. Unfortunately, I note:
Setting up couchdb (0.8.0-2) ...
I think that the 0.9 version in Debian testing will work, so I add the testing repositories to /etc/apt/sources.list:
deb testing main contrib non-free
deb testing/non-US main contrib non-free
deb testing/updates main contrib non-free
And the re-apt-get couchdb.

While that is installing, I tar up my seed data and scp into my VirtualBox:
cstrom@jaynestown:~/repos/eee-code/couch$ tar czf seed.tar.gz seed/
cstrom@jaynestown:~/repos/eee-code/couch$ scp -P 2222 seed.tar.gz localhost:
cstrom@localhost's password:
seed.tar.gz 100% 33MB 33.0MB/s 00:01
To load my CouchDB docs using my couch_docs gem, I need to install ruby, ruby-dev, rubygems, make, curl, and git via apt-get. I then add Github gems to my gem sources:
cstrom@debian:~$ gem sources -a
I can then install the necessary gem:
cstrom@debian:~$ gem install eee-c-couch_docs
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/var/lib/gems/1.8/bin aren't both writable.
WARNING: You don't have /home/cstrom/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Building native extensions. This could take a while...
Successfully installed json-1.1.7
Successfully installed rest-client-1.0.3
Successfully installed eee-c-couch_docs-1.0.0
3 gems installed
Installing ri documentation for json-1.1.7...
Installing ri documentation for rest-client-1.0.3...
Installing ri documentation for eee-c-couch_docs-1.0.0...
Installing RDoc documentation for json-1.1.7...
Installing RDoc documentation for rest-client-1.0.3...
Installing RDoc documentation for eee-c-couch_docs-1.0.0...
Next, install curl via apt-get so that I can create a CouchDB database:
cstrom@debian:~$ curl -X PUT http://localhost:5984/test
My first attempt at uploading my docs results in a missing SSL error so I apt-get install libopenssl-ruby. Finally:
cstrom@debian:~/seed$ ~/.gem/ruby/1.8/bin/couch-docs load . http://localhost:5984/test
This returns no errors (I really ought to add a progress bar). To verify that the documents were loaded correctly:
cstrom@debian:~/seed$ curl http://localhost:5984/test/_all_docs 
Nice! Less than two hours to get a new server up and running with a populated CouchDB server. I will spend a little time tomorrow getting Sinatra running.

1 comment:

  1. The VirtualBox NAT is what keeps me from using it. I want full access to my VMs without running some configuration tool.