Building Marketcetera Appliance

We built the Marketcetera Virtual Appliance using the VMWare Workstation and based it on Ubuntu 8.04 "Hardy Heron".
If you want to make custom modifications and redistribute the appliance, we highly recommend you make a copy of the downloaded appliance, make changes to that and redistribute the result.

Building the server from scratch is somewhat non-trivial and best done with automated scripts. If you are reading this to see how to setup a general Ubuntu box with Marketcetera Platform on it, then follow the instructions but ignore anything that deals with VMWare.
Here's the general list of what we did to build one:

  • Download and burn Ubuntu server install CD image
  • Start up VMWare Workstation and choose to create a new "Linux - Ubuntu" VM
  • Choose install to local hard drive
  • Set keyboard layout to American English
  • Set 384 MB memory
  • Set 8GB HD space
  • Chose not to allocate all drive space now
  • Chose to wipe whole drive
  • Set system clock to use local time
  • Added user "Marketcetera User" username:marketcetera password:marketcetera
  • Log in, sudo to root and run the following commands:
    sudo apt-get update
    sudo apt-get upgrade -qq
    sudo apt-get install -qq ruby openssh-server
    
  • edit /etc/apt/sources.list
    • uncomment "universe" lines
    • Add "multiverse" to the end of the "universe" lines
    • Comment out CDROM line
      sudo apt-get update
      sudo apt-get install ruby ri1.8 rdoc mysql-server libmysql-ruby libyaml-ruby libzlib-ruby ruby1.8-dev
      
  • Install rubygems http://rubygems.org/read/chapter/3#page13
    sudo gem install rails --include-dependencies -v 1.3
    sudo gem install mongrel
    
  • Install Java
    sudo apt-get install sun-java5-jre
    sudo apt-get install zip
    

Install Marketcetera Platform

  • Download the "ORS and OrderLoader" binary package from the download page
  • Extract that archive into /opt/marketcetera-platform-x.x.x-bin
  • Do a "sudo chown -R root:root" on that new directory
    • We did this on the appliance to make it easier to set ORS up as a cron job. If you are just building a server, then don't worry about it, our ORS doesn't have to run as root at all.
  • Symlink /opt/marketcetera/platform to the new directory using something like
    ln -s /opt/marketcetera-platform-x.x.x-bin /opt/marketcetera/platform"
    

Set up database

  • edit the file '/etc/mysql/my.cnf' and comment out the line
    bind-address           = 127.0.0.1
    
  • then do
    sudo /etc/init.d/mysql restart
    
  • Go into mysql prompt
    mysql --user=root mysql
    

Then inside mysql:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('marketcetera');

GRANT ALL PRIVILEGES ON *.* TO 'marketcetera'@'%'
     IDENTIFIED BY 'marketcetera';

CREATE DATABASE marketcetera;
CREATE DATABASE marketcetera_test;

Build Quickfix

The latest release of QuickFIX 1.12.4 doesn't yet support a few features that we needed to get Tradebase to work - they were added later.
As a result, you need to build a custom version of QuickFIX library directly from code:

  • Check out revision 1844 of QuickFIX into a temporary directory like quickfix-1844
    svn co -r 1844 https://svn.sourceforge.net/svnroot/quickfix/trunk/quickfix quickfix-1844
    
  • Make sure that '/tmp/quickfix-build exists', then
# if you are bulding off-appliance, and intend to copy files, add this to the next line: --prefix=/tmp/quickfix-build
./configure --with-ruby 
sudo make install

If you have built QuickFIX on another machine, tar up the contents of /tmp/quickfix-build, and /usr/local/site_ruby/*.rb and /usr/local/site_ruby/*.so. Extract the contents of /tmp/quickfix-build into /usr/local on the appliance. Extract the contents of /usr/local/site_ruby into /usr/local/site_ruby on the appliance.

Install Mongrel

Next, install the Mongrel web server. Since the gem installer for mongrel actually compiles the native C implementation as part of the installation process, a compatible C compiler is required, like GCC. Because in building the appliance we try to keep the size of the installed software low, we do not install GCC on the appliance, so we actually install the gem on a development machine and copy the resulting files to the appliance. However you may simply sudo apt-get install gcc to install gcc on your local machine, and then proceed with the rest of these instructions.

sudo gem install mongrel

If you are compiling mongrel on a different machine, you will then need to copy /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/http11.so onto the appliance.

  • try it out with:
    mongrel_rails start -d
    
  • and stop it with:
    mongrel_rails stop
    

Create /etc/init.d startup scripts

  1. Write the mongrel and ORS startup scripts and put them into /etc/init.d (or grab them from existing appliance or use our sample)
  2. Generate the appropriate scripts for all run-levels with command
    %> sudo update-rc.d mongrel defaults
    %> sudo update-rc.d ORS defaults
    

Clean Up

If the goal in cleaning up is to reduce the footprint of the zipped appliance you should really be using 'shred -z -v -n 0 <filename>; rm <filename>'

sudo rm /var/lib/apt/lists/*
sudo rm /var/cache/apt/*.bin
sudo rm -rf /var/log/installer/*
rm -rf ~marketcetera/*
sudo apt-get clean

VMWare and Networking

When you run the VMWare appliance in VMare (Player or Workstation) it sometimes tells you that the machine was moved and asks if you want to re-create the GUID.
Do not re-create the GUID. If you do, it'll hose the networking and you'll only have the 127.0.0.1
However, if you did, don't worry. Log in, and run the following script to fix it:

mac=`ifconfig -a | grep "HWaddr" | cut -d " " -f 11`
echo "eth0 mac $mac arp 1" > /etc/iftab 

Reboot, and you should be back to normal. Note that on a pre-built shipped appliance this script lives in the /usr/local/bin/fixmac file.