Library

How to install Firebird 3.0 and 4.0 on Linux

by Vasily Sidorov, Aug-24, 2022

In this article we describe installation of Firebird versions 3 and 4 on the popular Linux versions: CentOS 7, Oracle Linux 7/8, Debian 9/10, Ubuntu18/20 and OpenSUSE15.0.

In order to get Firebird distribution for Linux, please use tar archive from the official Firebird web site:

We assume that installation is done either with root or with sudoer, and that Linux computer has Internet access.

Please note that some commands require input from the user. Please note that lines with semicolon (;) at the end mean that command can be run as a single-line command.

Also, we recommend reading of Release Notes for the version of Firebird which you intend to install.

Prerequisites

System libraries requirements for 4.0.1 and 3.0 became the same: static linking for ncurses5 and tommath0 and dynamic for ICU.

Depending on the distribution, ncurses5 will be system library (RH7/Debian) or available as a package for backward compatibility (RH8/Debian).

Library tommath will be with version 0 or version 1 (they are binary compatible). If there is no tommath0, we will create symlink.

Other necessary system tools are tar and curl.

We install these packages explicitly so package manager will mark them as manually controlled and did not uninstall them automatically.

Quick installation

1. Specify max maps count.

This step is optional, but highly recommended for production systems:
Open file /etc/sysctl.conf and add the following line:
vm.max_map_count = 256000
then apply
sysctl -p /etc/sysctl.conf

2. Install necessary repository for libtommath

For CentOS 7
yum install epel-release;

For CentOS 8

dnf install epel-release;

For Oracle Linux 7

yum install oracle-epel-release-el7;

For Oracle Linux 8

dnf install oracle-epel-release-el8;

For other distributions the necessary packages should be available in the main repositories.

3. Install packages and tools

CentOS 7 / Oracle Linux 7

yum makecache;
yum install ncurses libicu libtommath;
yum install curl tar;

CentOS 8 / Oracle Linux 8

dnf makecache;
dnf install ncurses-compat-libs libicu libtommath;
dnf install curl tar;

Debian 9/10, Ubuntu 18/20

apt-get install libncurses5 libtommath1;
apt-get install curl tar;

Open SUSE 15

zypper install libncurses5 libtommath1;
zypper install curl tar;

Version of ICU can vary:

Debian 9

apt-get install libicu57

Debian 10

apt-get install libicu63

Ubuntu 18

apt-get install libicu60

Ubuntu 20

apt-get install libicu66

OpenSUSE 15.0

zypper install libicu60_2

In the distributions which have libtommath1 (all above except CentOS7 and Oracle Linux 7) it is necessary to create symlink libtommath.so.0:

TM=libtommath.so;
for LIB in `find /lib* /usr/lib* -name ${TM}.1`;
do ln -s ${TM}.1 `dirname ${LIB}`/${TM}.0;
done;
unset TM;

Installation script of Firebird 4.0.1 and upper can create symlink automatically, but for Firebird 3 it should be created manually.

4. Download and install Firebird

After the installation of necessary tools and libraries we can proceed with download, unpack and run installation package.

We assume that DOWNLOADLINK is a link from www.firebirdsql.org to download necessary Firebird.

curl -L DOWNLOADLINK | tar -zxC /tmp
cd /tmp/FIREBIRD_folder
sudo ./install.sh
Here DOWNLOADLINK - link to tar.gz, and FIREBIRD_folder - Firebird-version.build-0.architecture

where distribution will be unpack by the command tar -zxC /tmp

That’s all needed for the quick installation of Firebird 3 or 4 on Linux.

Optionally, you can generate the optimal configuration files (firebird.conf and databases.conf) with Firebird Configuration Calculator.

More details about Firebird installation

For those who would like to better configure Firebird installation we provide detailed explanation of above steps.

Configuration of vm.max_map_count

Firebird from version 3 effectively uses architecture SuperServer with intensive dynamic allocation of memory. In case of a high load and high frequency of connections and disconnections, engine can hit the memory fragmentation limits on Linux, it will be shown as error 11 (ENOMEM) or error 12 ( munmap) in firebird.log.

Memory fragmentation limit is controlled by the parameter vm.max_map_count, which by default has value 65536.

In order to keep this setting after the reboot of the server, add the following line to /etc/sysctl.conf

vm.max_map_count = 256000
To apply it, either reboot server or run command:
sudo sysctl -p /etc/sysctl.conf

Planning disk space

In general, we recommend to allocate 3 separate partitions on the server with Firebird database: for temp files, for databases and for local backups.

Partition for temp files

The main temporary files are lock-files, sorting files, files for global temporary tables and blobs, files with monitoring data.

By default, on Linux sorting files and files with data for global temporary tables are situated in /tmp, files for mon$ data and lock tables are in /tmp/firebird.

How to determine the proper size for the partition with temp files?

Potentially, sorting and blob files can be rather large, so practical recommendation to have partition for temp files for the production system with decent number of users around 30-40Gb. To determine the proper size more precisely, we recommend to watch for the actual sizes of temp files.

The small problem for such monitoring that sorting files are unlinked immediately after the creation, so it is not possible to see them with usual “ls” command. To view them, we need to check handles for the process (and they will be marked as deleted) with the following command:

sudo ls -lhF /proc/`pgrep firebird`/fd
As a result of this command, we will see contents of pseuvdo-folder /proc/.../fd/

To see the information about the specific file in this folder, need to use command:

sudo stat -L /proc/`pgrep firebird`/fd/NNNNN
where NNNNN is the descriptor of the file.

You can use this command for SuperServer and SuperClassic architectures, when engine runs as a single process. Of course, instead of pgrep firebird it is possible to specify handle number of Firebird process.

Partition for databases files

The partition for databases files should be enough to store all databases files plus free space equal to the size of the biggest database, plus reserve to growth for the next 2-3 years.

Partition for local backups

As a minimum, the partition for local backup should be enough to store all local backups plus the backup of the largest database.

Also, in order to perform restores, on the partition with backups we recommend to have additional free space, equal to the largest database size.

More reading on the backups

Create user firebird (optional)

The installation script creates, if not exists, user and group named “firebird” in order to perform all activity of Firebird using this user (this is a best practice for Linux systems).

It also means that database files and folders where databases and backups are located should have ownership or permissions for this user.

Sometimes it makes sense to create user and group “firebird” before the installation:

groupadd firebird &&
useradd -M -b /opt -s /sbin/nologin \
 -g firebird -u UID firebird
For user firebird we do’t create home folder (switch -M), specify only base folder ( -b).

Shell nologin with switch -s prevents standard login to the server.

Install necessary packages

Firebird 3.0 and 4.0 depends on libraries ncurses (libncurses.so.5), ICU (without link to the version, and they are not shown in ldd output), and tommath (libtommath.so.0).

Depending on Linux distribution, we need to use library names with or without versions. The practical copy-paste commands are shown above, and below we describe them.

CentOS and Oracle Linux

Version 7 contains the necessary packages by default, version 8 requires installation of ncurses-compat-libs and creation of symlink libtommath.so.0.

Debian, Ubuntu and OpenSUSE

In version Debian 9 and 10, Ubuntu 18 and 20, OpenSUSE 15 we have to install libncurses5 and libtommath1, and to identify the version of ICU we can use search for the incomplete name:

in Ubuntu

apt-cache search libicu5
in OpenSUSE 15
zypper search libicu6

Firebird installation details

Before the installation we have increased system parameter vm.max_map_count, installed libraries ICU, ncurses and tommath. Then we checked that we have correct versions of ncurses and tommath (libncures.so.5 and libtommath.so.0)or created necessary symlinks.

Optionally, we could create user and group firebird.

After that we can install Firebird, for this we go to the folder where installation package was unpacked and start the installation:

./install.sh
hit Enter to confirm the installation, and when prompted, specify the password for SYSDBA.

Initially Firebird will be installed with the configuration file by default. Default configuration runs as architecture SuperServer with the modest values: cache (DefaultDbCachePages, also called Page buffers) per database is set to 2048, buffer for sortings (TempCacheLimit) is 64M (for the server in v3 and per database in v4).

To view non-commented parameters of firebird.conf, you can use the following command:

grep -v ^# firebird.conf | grep -v ^$
If you will generate optimal configuration file with Firebird Configuration Calculator or manually change parameters, please note, that changes will be applied after the restart of Firebird service (in case of SuperServer and SuperClassic, in case of Classic need restart of all Firebird processes).

Please note that since Firebird 3 there are separate systemd units for SuperServer, SuperClassic and Classic.