Berkeley DB library: private installation / ACIS documentation

# Berkeley DB library: private installation

### Table of contents

## Intro

Berkeley DB is a very common industrial-strength open source embedded database library. It is used in a huge number of applications and appliances. ACIS uses Berkeley DB for its update daemon.

The library is common and most Unix/Linux computers already have it installed.

## The problem

There is one problem with this library. It requires special attention in case you are really doing a production-level installation of ACIS, not just playing with it. The problem is that later versions of the Berkeley library usually do not support previous version’s database formats or at least do not support it out of the box. So if you had some data in a database and then you update your system, and with this update comes an upgrade for the library — you’ve got a problem.

In case of such problem you either have to manually convert database files to a newer format or erase your database and recreate it. Anyway, you’ll have to shutdown your update daemon for a while and do manual work. This is no big deal, but for a good service you’d prefer not to do this.

That’s why I suggest that you build a private copy of the library. Then build and install a copy of the BerkeleyDB perl module, linked to that particular copy of the library. This way you’ll be independent of the system-wide upgrades and save yourself from some headache.

## Installing the library

Here is a little description of how I did this. Your configuration will be different, but the general algorithm will be the same.

At the time the latest published Berkeley DB library was version 4.3.27 and it had three patches coming with it…

    $ cd install
    $ tar xzvf ~/software/BerkeleyDB/db-4.3.27.NC.tar.gz
    $ cd db-4.3.27.NC
    $ patch -p0 < ~/software/BerkeleyDB/patch.4.3.27.1
    $ patch -p0 < ~/software/BerkeleyDB/patch.4.3.27.2
    $ patch -p0 < ~/software/BerkeleyDB/patch.4.3.27.3
    $ cd ../
    $ mv db-4.3.27.NC db-4.3.27.NC.patched-1-2-3
    $ cd db-4.3.27.NC.patched-1-2-3

(The latest version at the time of writing, on July 13, 2005 is 4.3.28 and has no patches with it, so it is a little bit simplier.)

When the package was unpacked and patched appropriately, I started the installation process per Berkeley DB instructions.

    $ cd build_unix
    $ ../dist/configure --prefix=/home/ivan/lib/bdb-4.3.27
    $ make
    $ make install

The special thing here is the `--prefix` parameter that I gave to the configure script.

After that I had a private copy of the library installed in `/home/ivan/lib/bdb-4.3.27` directory. Thinking about the future, I decided to create a link to use a simplier pathname.

    $ cd /home/ivan/lib
    $ ln -s bdb-4.3.27 bdb

So after that I could refer to the library directory as `/home/ivan/lib/bdb`. And I had:

library utilities | in /home/ivan/lib/bdb/bin
C header files | in /home/ivan/lib/bdb/include
library files | in /home/ivan/lib/bdb/lib

## Installing the BerkeleyDB perl module

Next step was to install the perl module BerkeleyDB.

First I ensured that I do not have a system-wide installed version of this module. This is to avoid confusion and nasty potential problems of differently compiled & linked versions of it.

Then, I got source package from CPAN (see link above) and went on:

    $ cd ~/install
    $ tar xzvf ~/software/BerkeleyDB/BerkeleyDB-0.26.tar.gz
    $ cd BerkeleyDB-0.26

This module is configured via `config.in` file. Before you start changing it, you may want to save its original version (although its not critical). When I was doing it, I simply renamed the provided file to a backup and created a new file in its place.

    $ mv config.in config.in.orig
    $ vi config.in

I’ve put the following lines in it:

    INCLUDE = /home/ivan/lib/bdb/include
    LIB     = /home/ivan/lib/bdb/lib
    DBNAME = -ldb

After that I went on with the standard installation procedure:

    $ make
    $ make test
    $ su

Entered root password and, finally…

    # make install

That’s it. The library and the module at this stage is installed. Unless something went wrong on one of the previous stages, you are now ready to fire up the update daemon.