Monday, January 25, 2010

Howto: two Firebirds on one Linux box

Don't know if anyone ever needs such a crazy setup, but here it goes. I needed to run a software that requires Firebird 2.x. Nothing special, it's available in my distribution (Ubuntu). I also had to run another app that needs Firebird 1.5. That's where it started to get complicated:

- Firebird 1.5 is not available in Ubuntu - I can use vendor-provided binaries, but...

- They're only 32-bit, my box is amd-64

- There's no official support for running two versions of Firebird on one machine.

One solution would be to use a virtual machine. That way I would be compliant with a title of this blog. But I only needed these RDBMSes occasionally, maybe once a month, never both versions simultaneously. Also this machine is short on disk space. I didn't want to waste few GB on another copy of an operating system with all the necessary tools and libraries. After half an hour of meddling, I managed to get both versions on the same system.

I. Prerequisites

1. aptitude install ia32-libs
Required for Firebird 1.5, if you're on a 64-bit system and you haven't already installed 32-bit libraries


2. Install old version of libstdc++
Required for Firebird 2. Karmic doesn't have it anymore, get one from Jaunty and install with
sudo dpkg -i libstdc++5*deb

3. Create a file /etc/ld.so.conf.d/firebird.conf with the following contents:
/opt/firebird-1.5/lib
/opt/firebird-2/lib
/opt/firebird/lib
These directories don't exist yet, but they will be created soon.


II. Firebird 2

1. Get Firebird 2.1 from firebirdsql.org
You'll need the right version for your architecture (64 or 32 bit), superserver, compressed tarball.

2. Unpack it somewhere and run install.sh
If at any point you get an error starting like this:
ld: Unable to load shared library
stop the installation with Ctrl-C, run 'sudo ldconfig' and try installing again.

3. Firebird asks for a password for sysdba (admin) user.
Old versions used a default password 'masterkey' and some poorly written software relies on it. Don't use it if your application is exposed to the internet.

4. The software is now installed in /opt/firebird. Subsequent installation of Firebird 1.5 would overwrite it. We need to rename it:
sudo mv /opt/firebird /opt/firebird-2
sudo mv /etc/init.d/firebird /etc/init.d/firebird-2
Sometimes Firebird installer doesn't put the init.d script in the right place. You can find the script in /opt/firebird-2/misc/firebird.init.d.debian. Copy it to /etc/init.d and rename to firebird-2.

5. Use your favourite text editor on /etc/init.d/firebird-2 and replace the line
FIREBIRD=/opt/firebird
with
FIREBIRD=/opt/firebird-2

6. Run 'sudo ldconfig' again.

7. Test the init script
/etc/init.d/firebird-2 stop
should stop the database, 'ps aux | grep firebird' would return nothing (or just the grep itself).
/etc/init.d/firebird-2 start
should start it, the command would return two processes, fbguard and fbserver



III. Firebird 1.5

1. Stop Firebird 2 if it's running at the moment.

2. Get Firebird 1.5 from firebirdsql.org
You'll need the version called Superserver for Linux (NPTL threading model), compressed tarball.

3. Unpack it somewhere and run install.sh
If at any point you get an error starting like this:
ld: Unable to load shared library
stop the installation with Ctrl-C, run 'sudo ldconfig' and try installing again.

4. Like with version 2, Firebird asks for a password for sysdba (admin) user.
An application bad enough to require such and old RDBMS probably also uses a default password. Mine does.

5. The software is now installed in /opt/firebird. Since we're not going to install any more versions, we could leave it here, but then an upgrade to Firebird 2 would overwrite it. Better rename it too. Steps are the same.
sudo mv /opt/firebird /opt/firebird-1.5
sudo mv /etc/init.d/firebird /etc/init.d/firebird-1.5
Replace /opt/firebird with /opt/firebird-1.5 in /etc/init.d/firebird-1.5

6. Run 'sudo ldconfig' and test the init script.

0 komentarze:

Post a Comment