www.destructor.de

About | Contact | Impressum


Home |  Code |  Articles |  Misc |  x
Firebird |  Talks |  Character Sets |  x
General |  1.0 |  1.5 |  2.0 |  2.1 |  2.5 |  3.0 |  x

Running several Firebird Instances per Server Machine

This article explains how to run more than one instance of Firebird on one machine, e.g. two different versions (like 1.5 and 2.0) of Firebird. This can be important when you want to test a new version of Firebird or when you have different applications using different server versions running and only want to use one server machine.

As my own experience with and knowledge of Linux is too weak, this article only covers Windows machines.

The Firebird Service

When you install Firebird using the self-contained Setup program or use the instsvc.exe tool, a service for the Firebird server (and, when you request it, a service for the Firebird Guardian) is installed.

The name of these services is the same for all versions of Firebird:

You can use the NET START and NET STOP commands to start and stop these services from a command line, e.g.:

    NET START "Firebird Guardian - DefaultInstance"
    NET STOP "Firebird Guardian - DefaultInstance"

To install a certain version of Firebird as a service, you can use the instsvc.exe tool that comes with Firebird and is located in Firebird's bin subdirectory.

instsvc i[nstall]   [ -s[uperserver]* | -c[lassic] ]
                    [ -a[uto]* | -d[emand] ]
                    [ -g[uardian] ]
                    [ -l[ogin] username [password] ]

        sta[rt]   [ -b[oostpriority] ]
        sto[p]
        q[uery]
        r[emove]

So you can use instsvc install -s to install Firebird as a SuperServer service. Or use instsvc remove to uninstall the service. You can also use the start and stop options to start and stop the service, like you would do it with NET START and NET STOP.

Note that as all versions of Firebird use the same default service name, you can install only one instance of Firebird as a service on one machine, using the Windows Installer for Firebird.

With the Windows installer, it is easy to install Firebird as a service.

Firebird 2.1, 2.5: Named Instances

Starting with Firebird 2.1 you can give your instance a name. The INSTSVC tool takes a -name parameter for that, so you can use

instsvc install -name FB21

To install the service with the name "Firebird Server - FB21".

Starting Firebird as an Application

You can also start the Firebird server as an application:

    fbserver -a

will start Firebird as an application, showing an icon in the taskbar notification area. You can right-click on this icon to shutdown this instance of Firebird.

Running Multiple Instances

You now have these general options to run multiple Firebirds at once:

Port Conflicts

The default TCP port for Firebird (and, BTW, InterBase) is 3050/tcp, the default service name is gds_db. When you run several instances of Firebird at the same time, they must listen on different ports. There are two ways to configure this:

    fbserver -a -p 3051

Connecting from the Client

The port number for the server can be specified in the database connection string, separated from the server name by a slash:

    dbserver/3051:D:\DB\MyDb.fdb
    elvis/3052:rocknroll

You can also use the service name:

    dbserver/gds_db:D:\DB\MyDb.fdb
    elvis/fb21:rocknroll

In this case you would have to define these service names in the services file of every client.

Using the correct Client Library

Connection from the client is done using the fbclient.dll client library. Every version of Firebird comes with a new version of fbclient.dll. However, these are backwards compatible, so you can use the newest one for connecting to all kinds of Firebird servers. It is no problem to use the Firebird 2.1 client library to connect to a Firebird 1.5, or even Firebird 1.0 server.

If you want to use the corresponding client library for every server, please take a look at my article about Minimum Client Installs. Installing a complete Firebird Client (with administration tools) is unnecessary for machines where only the application must be run.

A correctly coded Firebird application will look up the Firebird Client path in the Registry. The key is HKEY_LOCAL_MACHINE\SOFTWARE\Firebird Project\Firebird Server\Instances and there the string DefaultInstance will contain the path name of the Firebird installation.

You can use the instreg.exe tool from Firebird's bin subfolder to install the correct path to this Registry Key:

    instreg i[nstall]

will install the Registry Key, and

    instreg r[emove]

will uninstall it.

On a Production Server

When you set up a dedicated database server it is best to not install any of the Firebirds in the Registry at all (so run "instreg r" and just leave it that way). 

Messages File for Firebird's Utilities

The Firebird command-line utilities like ISQL, GBAK etc. obviously use the Registry to find out the Firebird base path. So when you have 1.5 and 2.0 installed, they will only read the old firebird.msg Messages file, which will lead to missing texts and messages (call HELP in ISQL to see that). 

So if you want to have complete messages you should call instreg i before using these tools.

Running InterBase and Firebird on one machine

I haven't done a lot of research on this, but at least it's running on my machine. 

The InterBase service name is:

It is best to run InterBase on port 3050 because the InterBase client library GDS32.dll does not understand the slash-portnumber syntax (it understands the slash-servicename syntax, but you don't want to rely on that).

To run InterBase as an application, you can use

    ibserver.exe -a

As InterBase uses different names for the service and client library, it's no problem to run it parallel to a Firebird 1.5 or 2.0 server.

Firebird 1.0 uses the same service, program and library names, so it's much more difficult, if not impossible, to run both InterBase and Firebird 1.0 at the same time. But as Firebird 1.0 is just a better (bug-fixed) version of InterBase 6.0, you shouldn't have problems to just replace an InterBase 6.0 service with a Firebird 1.0 engine.


Stefan Heymann. Last change 2009-09-27

This documentation is licensed under (choose your favorite): GPL, LGPL, CC, IDPL, GFDL, BSD, (did I forget one?)