Library

Installing Firebird 3 on modern Linux versions: CentOS 8 and Ubuntu 19

(C) Basil Sidorov, IBSurgeon, 22-May-2020

This article is devoted to the fast installation of Firebird 3.0 on the new Linux distributions: CentOS 8 and Ubuntu 19 (also works for 18).

The first section is a quick installation guide to install Firebird 3.0 as fast as possible, without details. The second part describes the details.

Fast Installation of Firebird 3 on CentOS 8 and Ubuntu 19

1. Add to the file /etc/sysctl.conf the following line:
vm.max_map_count = 256000
2. Save sysctl.conf and apply new settings:
sudo sysctl -p /etc/sysctl.conf

​The next instructions are slightly different for CentOS 8 and Ubuntu 19. 

Please note, that we have used the explicit link to the latest release distribution of Firebird 3.0 from the FirebirdSQL.org, currently (May 2020), it is 3.0.5, and here is the link for the 64-bit version:
https://github.com/FirebirdSQL/firebird/releases/download/R3_0_5/Firebird-3.0.5.33220-0.amd64.tar.gz
In the future, when 3.0.6, etc will appear, you will need to use the correct link to the new release – it will be published on www.firebirdsql.org.

3. Install packages

CentOS8
sudo yum -y install epel-release
sudo yum -y makecache
sudo yum -y install libicu libtommath tar
sudo ln -s libncurses.so.6 /usr/lib64/libncurses.so.5
sudo ln -s libtommath.so.1 /usr/lib64/libtommath.so.0

sudo ln -s ln -s libncurses.so.5 /usr/lib64/libncurses.so.5
curl -L https://github.com/FirebirdSQL/firebird/releases/download/R3_0_5/Firebird-3.0.5.33220-0.amd64.tar.gz|tar -zxC /tmp

Ubuntu 19
sudo apt-get -y install libncurses5 libtommath1
sudo ln -s libtommath.so.1 /usr/lib/x86_64-linux-gnu/libtommath.so.0
wget -O- https://github.com/FirebirdSQL/firebird/releases/download/R3_0_5/Firebird-3.0.5.33220-0.amd64.tar.gz|tar -zxC /tmp


As a result, you will have all Firebird installation files ready in /tmp/firebird:
/tmp/Firebird-3.0.5.33220-0.amd64# ll
total 8484
drwxr-xr-x  2 root root    4096 Jan  9 13:13 ./
drwxrwxrwt 28 root root    4096 May 22 17:20 ../
-rw-r--r--  1 root root 8615663 Jan  9 13:13 buildroot.tar.gz
-rwxr-xr-x  1 root root   44096 Jan  9 13:13 install.sh*
-rw-r--r--  1 root root   14967 Jan  9 13:13 manifest.txt
4. And then, install Firebird:

cd /tmp/Firebird-3.0.5.33220-0.amd64
​sudo ./install.sh


then, check that Firebird is running - the command below will show all processes related with Firebird or running under user firebird:
ps aux | grep firebird

That’s all if you just need to install Firebird 3.0.
If you would like to know what the above commands mean, please read on!

Main part: details of installation Firebird 3 on Linux

In this article, we assume that the operating system was installed in the minimal version, and you already have access to the public repositories or their local copies.

Planning space allocation

On the server intended to serve Firebird databases, we recommend allocating separate volumes for temporary files (/tmp), database files, and local backups.

Volume for temp files

Firebird temporary files include lock-files, sorting files, files to “materialize” global temporary tables (GTT), and monitoring tables. Sorting files and GTT files are located in /tmp, mon$- and lock-files are in /tmp/firebird.
Sorting files are being unlinked immediately after creation, that’s why you cannot see them in the folder (unlike Windows) with ls command.
To see these files, you need to request file handles of Firebird process (and they are marked as deleted):
sudo ls -lhF /proc/`pgrep firebird`/fd
To get details about a specific sorting file, run the command
sudo stat -L /proc/`pgrep firebird`/fd/NUMBER
where NUMBER is a file descriptor of the file.
Temporary files can be large, so it is recommended to allocated 20-30Gb for /tmp.

Please note that sorting size does not depend on the database size: some erroneous queries with the direct product can easily produce a 100Gb sorting file of the 3Mb database.

Volume for database files

Volume for database files should be big enough to keep all database files plus, as a minimum, the size of the biggest database, for possible in-place manipulations.
Also, remember that databases grow over time, and reserve some free space for them too.
It is highly recommended to put volume for the database files to the fastest drive/SAN/hardware you have, with the highest random IO capabilities.

Volume for local backup files

Volume for local backup files should be big enough to have backups for all databases plus the size for the biggest database file (not backup – it is for possible test restore). Of course, remember about the growth of database backups. Volume for Local backup files can be situated on relatively slow drives. Firebird backup files have a linear structure, so for a backup drive it is enough to have high sequential speed.

Preparation

Firebird engine dynamically allocates and deallocates memory, it may lead to memory fragmentation.
For example, it can happen after disconnecting many users from Firebird SuperServer instance. Memory fragmentation is controlled by the system parameter vm.max_map_count, which has default value 65K. It is recommended to increase it at least 4x times, and make this setting permanent.
Add the following line to /etc/sysctl.conf:
vm.max_map_count = 256000
and apply it
sudo sysctl -p /etc/sysctl.conf

Installation of necessary packages

Firebird 3 depends on the several Linux packages: ncurses, ICU, tommath. Also, we need utilities gzip, tar, and curl or wget.

CentOS 8

CentOS uses a new package manager dnf, which is transparently invoked by yum. We like yum, so let’s use yum. First, renew metadata cache:
sudo yum makecache
Package libtommath is situated in the separate repository EPEL (E(xtra)P(ackages for)E(nterprise)L(inux)), so we need to check it is enabled:
yum -C repolist
Option -C (--cache-only) makes yum to use only cache.
If you don’t see epel-repository in the result of yum -C repolist, install it:
sudo yum install epel-release && sudo yum makecache

​In a case of problems, edit file /etc/yum.repos.d/epel.repo and replace https:// to http://, and try yum makecache again.

Then, let’s check that we have all the necessary packages (64-bit in the example):

yum -C list ncurses libicu libtommath gzip tar curl wget | grep -v i686
Installed Packages
curl.x86_64 7.61.1-11.el8 @anaconda
gzip.x86_64 1.9-9.el8 @anaconda
ncurses.x86_64 6.1-7.20180224.el8 @anaconda
Available Packages
libicu.x86_64 60.3-1.el8 BaseOS
libtommath.x86_64 1.1.0-1.el8 epel
tar.x86_64 2:1.30-4.el8 BaseOS
wget.x86_64 1.19.5-8.el8_1.1 AppStream
Installing missed packages on CentOS 8
sudo yum install libicu libtommath tar

Ubuntu 19

apt list libncurses? libicu?? libtommath? gzip tar curl wget | grep -v i386
curl 7.65.3-1
gzip 1.10-0 [upgradable…]
libicu63 63.2-2 [installed]
libncurses5 6.1
libncurses6 6.1 [installed,automatic]
libtommath1 1.1.0
tar 1.30 [installed]
wget 1.20.3 [installed]
Installing missed packages on Ubuntu 19:

sudo apt‑get install libncurses5 libtommath1

Creating symlinks

Libtommath.so.1 and libncurses.so.6 are compatible with libtommath.so.0 and libncurses.so.5, it will be enough for Firebird to create symlinks to the existing libraries versions.
First, let’s find libtommath.so.1 (libncurses.so.? Is in the same folder):
find /usr -name libtommath.so.1
On CentOS8 it is located in:
/usr/lib64/libtommath.so.1
On Ubuntu 19:
/usr/lib/x86_64-linux-gnu/libtommath.so.1 

​Let's create symlinks
CentOS8
sudo ln -s libtommath.so.1 /usr/lib64/libtommath.so.0
sudo ln -s libncurses.so.6 /usr/lib64/libncurses.so.5

Ubuntu 19
sudo ln -s libtommath.so.1 /usr/lib/x86_64-linux-gnu/libtommath.so.0

to check results:
ls -lhF  $(dirname `find /usr -name libtommath.so.1`) | grep "lib\(ncurses\|tommath\)\.so\."

on CentOS8 it gives:
libncurses.so.5 -> libncurses.so.6*
libncurses.so.6 -> libncurses.so.6.1*
libncurses.so.6.1*
libtommath.so.0 -> libtommath.so.1*
libtommath.so.1 -> libtommath.so.1.1.0*
libtommath.so.1.1.0*
On Ubuntu it gives:
libncurses.so.5 -> libncurses.so.5.9
libncurses.so.5.9
libncurses.so.6 -> libncurses.so.6.1
libncurses.so.6.1
libtommath.so.0 -> libtommath.so.1
libtommath.so.1 -> libtommath.so.1.1.0
libtommath.so.1.1.0 

Getting Firebird 3.0 release distribution

Firebird Linux releases are available on www.firebirdsql.org as tar.gz archives. Let’s assume that URL is the download link to Firebird release tar.gz archive. We need to download and unpack the archive, for this we can use curl or wget.
curl
curl -L URL | tar -zxC /tmp

wget
wget -O– URL | tar -zxC /tmp

As a result, there will be created folder /tmp/Firebird‑3.0.5.33220‑0.amd64 with 3 files: install.sh, buildroot.tar.gz, and manifest.txt.

Installing Firebird

As prerequisites, we have set vm.max_map_count, checked and installed ICU, ncurses and tommath, and created symlinks.
After that, the final step is easy – run
sudo ./install.sh
This script starts system-unit firebird-superserver and Firebird is ready to work.
 

​Configuration file and its optimization

Please note, that the default Firebird configuration file firebird.conf is configured in a very modest way. You can check contents of firebird.conf (non-commented lines) with the command:
grep -v ^# firebird.conf | grep -v ^$

For the default firebird.conf, the above command will return nothing, it means all values are default.

If you are configuring production system, consider using optimized Firebird configuration files: https://ib-aid.com/en/optimized-firebird-configuration/

Frequently Asked Question #1

The frequent question is "why simply not use the repository and install Firebird using yum or apt?". Of course, it is is possible, but there are 2 big reasons:
1) repository can contain the old version (i.e., previous minor release),
2) we like to control the environment to ensure that everything is installed and configured correctly.
Also, we prefer the installation to the /opt, it is easier for cross-platform scripts and good administration practice.

Contacts

Please feel free to send questions, suggestions, and possible mistakes to support@ib-aid.com