< Service
Revision as of 16:20, 27 September 2009 by Dfarning (talk | contribs) (fix command)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Team Home   ·   Join   ·   Contacts   ·   Resources   ·   FAQ   ·   Roadmap   ·   To Do   ·   Meetings


A content delivery network or content distribution network (CDN) is a system of computers containing copies of data, placed at various points in a network so as to maximize bandwidth for access to the data from clients throughout the network. A client accesses a copy of the data near to the client, as opposed to all clients accessing the same central server, thereby causing a bottleneck near that server.

Mirrorbrain, Bouncer, Fedora Mirror Manager, and Cacheboy are four possible choices for scaling up the Sugar Labs content delivery net work. Long term, Cacheboy looks like it might be the best fit for Sugar Labs, but the project must become more stable before becoming Sugar Labs primary CDN. Bouncer is currently being used as successfully by Mozilla. But development ended at the end of 2008. Mozilla is currently investigating Mirrorbrain. Mirrorbrain looks promising.


  • Reduce bandwith at primary download server.
  • Improve quality of service for users.
  • Move content closer to users.


Mirrrorbrain is used by several major project including opensuse and openoffice. It is quite stable, under activate development, and well documented,


The following Recipe for installing mirrorbrain on ubuntu 9.04 is based on information at .

Install LAMP Server

Install a standard Ubuntu LAMP server

Download mirrorbrain

tar xzf mirrorbrain-2.10.0.tar.gz

Install python dependencies

sudo apt-get install python-sqlobject python-psycopg2

The python cmdln module is not prepackaged for Ubutnu so it must be installed manually.

cd cmdln-1.1.2
sudo python install

Install perl dependencies for scanner

The mirrorbrain scanner is written in perl and requires several dependencies.

sudo apt-get install libconfig-inifiles-perl libwww-perl libdbd-pg-perl libdatetime-perl libdigest-md4-perl

Build, Install, and Configure Apache2 modules

Mirrorbrain requires several Apache modules, several of which must be built manually. Apache modules are built and installed using apxs2. (APache eXtenSion tool) Apxs2 is in the apache2-threaded-dev package.

sudo apt-get install apache2-threaded-dev

Install and Configure mod_geoip

Mod_geoip is available as a prebuilt package.

sudo apt-get install libapache2-mod-geoip

Mod_geoip must be configured to find the the GeoIP data set.

sudo sh -c "cat > /etc/apache2/mods-available/geoip.conf << EOF
<IfModule mod_geoip.c>
 GeoIPEnable On
 GeoIPOutput Env
 GeoIPDBFile /var/lib/GeoIP/GeoIP.dat MMapCache

Download GeoIP data set

sudo apt-get install gzip
gunzip GeoIP.dat.gz
sudo mkdir /var/lib/GeoIP
sudo cp GeoIP.dat /var/lib/GeoIP/GeoIP.dat

Enable module.

sudo a2enmod geoip

Restart Apache

sudo /etc/init.d/apache2 restart

Install and Configure mod_form

Mod_from must be build from sctatch.

FIXME correct directory Download source


build mod_form

sudo apxs2 -cia mod_form.c

create loader

sudo sh -c "cat > /etc/apache2/mods-available/form.load << EOF
LoadModule form_module /usr/lib/apache2/modules/

Enable module.

sudo a2enmod form

Restart Apache

sudo /etc/init.d/apache2 restart

Install and configure mod_mirrorbrain

Build mod_mirrorbrain

sudo apxs2 -cia mod_mirrorbrain.c

create module loader sudo sh -c "cat > /etc/apache2/mods-available/mirrorbrain.load << EOF

LoadModule mirror_module /usr/lib/apache2/modules/

Enable module.

sudo a2enmod mirrorbrain

Restart Apache

sudo /etc/init.d/apache2 restart

Build and Install helper programs

build and install geoiplookup

gcc -Wall -lGeoIP -o geoiplookup_continent geoiplookup_continent.c
sudo cp geoiplookup_contintent/usr/bin/geoiplookup_continent

Install scanner

sudo cp ../tools/ /usr/bin/scanner

Install postgres

sudo apt-get install postgresql-8.4

Install mod_dsd


sudo apt-get install libaprutil1-dbd-pgsql

configure mod_dsd

sudo cat > /etc/apache2/mods-available/dbd.conf << EOF
 <IfModule mod_dbd.c>
    DBDriver pgsql
    # note that the connection string (which is passed straight through to
    # PGconnectdb in this case) looks slightly different - pass vs. password
    DBDParams "host=localhost user=mb password=12345 dbname=mb_sugar connect_timeout=15"

Create the postgresql user account and database

Switch to user postgress

sudo su - postgres

Create user

createuser -P mb
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n

Create database

createdb -O mb mb_sugar
createlang plpgsql mb_sugar

Exit user postrges


Edit host-based authentication

add line 'local mb_sugar mb trust' to the end of pg_hba.conf

FIXME should not be trust on production machine

sudo vim /etc/postgresql/8.4/pg_hba.conf

Start the potgres server

sudo /etc/init.d/postgresql-8.4 restart

Import intial mirrorbrain Data

Import table structure, and initial data

psql -U mb -f sql/schema-postgresql.sql mb_sugar
psql -U mb -f sql/initialdata-postgresql.sql mb_sugar

Create mirrorbrain user and group

sudo groupadd -r mirrorbrain
sudo useradd -r -g mirrorbrain -s /bin/bash -c "MirrorBrain user" -d /home/mirrorbrain mirrorbrain

Create mirrorbrain.conf

sudo cat > /etc/mirrorbrain.conf << EOF
instances = samba
dbuser = mb
dbpass = 12345
dbdriver = postgresql
dbhost =
# optional: dbport = ...
dbname = mb_sugar
mailto =

Set permission and priviglies

sudo chmod 0604 /etc/mirrorbrain.conf 
sudo chown root:mirrorbrain /etc/mirrorbrain.conf

Test mirrorbrain


Create VirtualHost

sudo cat > /etc/apache2/sites-available/mirror << EOF
   DocumentRoot /srv/samba/pub/projects
   ErrorLog     /var/log/apache/
   CustomLog    /var/log/apache/ combined
   <Directory /srv/samba/pub/projects>
     MirrorBrainEngine On
     MirrorBrainDebug Off
     FormGET On
     MirrorBrainHandleHEADRequestLocally Off
     MirrorBrainMinSize 2048
     MirrorBrainHandleDirectoryIndexLocally On
     MirrorBrainExcludeUserAgent rpm/4.4.2*
     MirrorBrainExcludeUserAgent *APT-HTTP*
     MirrorBrainExcludeMimeType application/pgp-keys
     Options FollowSymLinks Indexes
     AllowOverride None
     Order allow,deny
     Allow from all