Installing Firebird 3 on Modern Linux Versions: CentOS8 and Ubuntu 19

In this article, we describe the minimum set of steps required to optimally install Firebird version 3.0 on new Linux distributions. For examples, CentOS 8 and Ubuntu 19 were selected.

For the "delivery" of the Firebird distribution to the target system, in this guide, the option to download the tar.gz archive from the link from the project’s official website ( firebirdsql.org ) was selected .

For the most impatient - immediately into battle:

Quick installation


Edit the file /etc/sysctl.confby adding the line:

vm.max_map_count = 256000

Save the file and apply the setting:

sudo sysctl -p /etc/sysctl.conf

Further instructions differ for CentOS 8 and Ubuntu 19, but they also indicate the link from the official Firebird project website for downloading the distribution package and the directory into which the distribution package will be unpacked during the boot process.
Currently (March 2020) Firebird 3.0.5 release is relevant ( here is a link to the 64-bit version).

CentOS 8

sudo yum -y install epel-release
sudo yum -y makecache
sudo yum -y install libicu libtommath tar
ln -s libncurses.so.5 \
/usr/lib64/libncurses.so.5
ln -s libtommath.so.1 \
/usr/lib64/libtommath.so.0
curl -L |tar -zxC /tmp

Ubuntu 19

sudo apt-get -y install libncurses5 libtommath1
ln -s libtommath.so.1 \
/usr/lib/x86_64-linux-gnu/libtommath.so.0
wget -O- |tar -zxC /tmp

Actually installing the Firebird DBMS:

cd /tmp/
sudo ./install.sh

If you want to better understand what these actions are for, read on.

Main part

Small preamble

It is assumed that the OS is already installed in the minimum version and access to public repositories or to their local copies is configured.

It is assumed that the reader has basic knowledge of Linux and the Firebird DBMS.

Planning It is

recommended to allocate separate sections for temporary files ( /tmp), database files, and local backups on the DBMS server .

Temporary include lock files, sort files, “materialization” files of global temporary tables (GTTs) and monitoring tables. Sort files and global temporary tables are located in /tmp, mon $ table files and lock files are located in /tmp/firebird.

Sort files are “deleted” ( unlink) immediately after creation, therefore they cannot be “seen” in the directory listing - only in the list of process handles (marked as deleted):

sudo ls -lhF /proc/`pgrep firebird`/fd

In the pseudo- /proc/…/fd/directory listing, symlinks are displayed, and the actual information about the file is given by:

sudo stat -L /proc/`pgrep firebird`/fd/

where is the descriptor (descriptor) of the file of interest.

Instead of calling " pgrep -", you can immediately substitute the identifier of the process of interest.

Temporary files can be very large, therefore it is /tmprecommended to allocate at least 20-30 GB for. Keep in mind that the size of sorting files depends only on the amount of data that is explicitly or implicitly sorted in the request and a single user can “create” gigabytes of temporary files.

The section for database files should contain all database files. plus at least a copy of the largest database file. It should take into account the growth of database files in the future for several years in advance.

The local backups section must contain at least one backup archive of all the bases plus the backup of the largest base. It is advisable that this section also has a place to restore the largest base. It should take into account the growth of backups and backup archives in the future for several years ahead.

Preliminary preparation

Firebird 3.0 DBMS server dynamically allocates and frees up system memory, which can lead to fragmentation. For example, after a large number of users disconnect from the super server at one time, errors may occur with new connections.

Memory fragmentation is controlled by the system parameter vm.max_map_count, by default - 64K. It is recommended to increase its value four times:

sudo sysctl vm.max_map_count=256000

To set the new value when the system reboots, add the /etc/sysctl.confline to the file :

vm.max_map_count = 256000

It is advisable to make a comment so that the reason for changing this parameter is understood. You can first edit the file, and then apply the settings saved in it:

sudo sysctl -p /etc/sysctl.conf

Installing the required packages

Firebird 3.0 Linux DBMS executables depend on the ncurses ( libncurses.so.5), ICU (no version bindings, and no output ldd) libraries and tommath ( libtommath.so.0) libraries . To download and unpack the assembly archive, utilities are required gzip, tarand curlor wget. Version of the ICU, gzip, tarand curl/ wget- are insignificant.

Work with packages depends on the system and on the package manager used in the system, therefore, we will consider them one by one.

CentOS 8

CentOS 8 uses the new package manager - dnfand it is "transparently" called on command yum. Since there is no difference between them for our purposes, there will be examples yum.

Updating the metadata cache:sudo yum makecache

The libtomath package is located in a separate E (xtra) P (ackages for) E (nterprise) L (inux) repositories, so we check that it is already connected:

yum -C repolist

The "only from the cache" ( -Cor --cache-only) option is used to eliminate unnecessary checks and downloads, speeding up yum. If there is no epel repository in the list, install it and update the metadata cache:

sudo yum install epel-release &&
sudo yum makecache

We confirm the requests, if necessary, checking the values ​​of pgp-keys with those already known from a trusted source.

If you have problems downloading repository meta-information from https resources, then edit the file /etc/yum.repos.d/epel.repo, replacing it https://with http://and repeat the cache update command.

Check the status of the necessary packages (the command is folded, in the output example, the 32-bit package is filtered):

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

We see that curl, gzipand ncursesare located in the pseudo-repository of the installer ( anaconda), and tar- is excluded from the minimum installation of the system. Major versions libncursesand libtommathmore than required: 6 and 1 instead of 5 and 0, respectively. If the same package is installed and available, an update has been released for it. Install the missing packages:

sudo yum install \
libicu libtommath tar

Ubuntu 19

Utilities are designed for package management apt, apt‑getand apt‑cache. The first is designed for interactive work, and the last two - for use in scripts. Package names are slightly different and include a version.

We check the status of the necessary packages (the command is complex, the output example is reduced and 32-bit packets are filtered out):

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]

Packages for which installed/ upgradable- are installed in square brackets . Available, but not installed ncurses5, instead of curlinstalled wget. Install the missing packages:

sudo apt‑get install \
libncurses5 libtommath1

Creating symlinks

Since libtommath.so.1they are libncurses.so.6backward compatible with libtommath.so.0and libncurses.so.5, it is enough for Firebird to create symlinks to existing versions of libraries.

We find libtommath.so.1( libncurses.so.?located in the same directory):

find /usr -name libtommath.so.1

CentOS:

/usr/lib64/libtommath.so.1

Ubuntu:

/usr/lib/x86_64-linux-gnu/libtommath.so.1

Create symlinks.

CentOS:

sudo ln -s libtommath.so.1 \
/usr/lib64/libtommath.so.0
sudo ln -s libncurses.so.6 \
/usr/lib64/libncurses.so.5

Ubuntu:

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

Check the result (the command is folded, output examples are shortened):

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

CentOS:

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*

Ubuntu:

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

Downloading the Firebird DBMS distribution kit.

The official website of the Firebird project (firebirdsql.org) publishes links to distributions of the “official” releases (releases) and “daily” assemblies (snapshot build).

Official Linux releases are available as archives (tar.gz) and deb / rpm packages, and builds are available as archives only. We will look at the “generic installer” (generic installer from tar.gz).

The assembly archive needs to be downloaded and unpacked, but we will combine both of these processes. Unpacking is done in /tmp, the URL indicates a link to the downloadable archive.

curl:

curl -L URL | tar -zxC /tmp

wget:

wget -O– URL | tar -zxC /tmp

By default, it curlsends the loaded data to standard output, but does not handle redirects and we add " ‑L", but wget, on the contrary: it processes redirects, but writes data to a file and we put " ‑O‑". For tarindicate the use of the gzipfilter and the directory into which the unpacking will be performed. Upon completion of the process will be kind of directory Firebird‑3.0.5.33220‑0.amd64with three files: install.sh, buildroot.tar.gzand manifest.txt.

Installing Firebird

During the preliminary preparation, we adjusted the value of the system parameter vm.max_map_count, checked the availability and installed the ICU, ncurses and tommath libraries. We made sure that the versions of ncurses and tommath ( libncures.so.5and libtommath.so.0) were correct and created the necessary symlinks.

Actually installation is very simple. We go to the directory where the archive of the Firebird distribution kit was unpacked, check and, if necessary, set the “executable” flag for the script install.sh:

chmod +x install.sh

run the installation script:

sudo ./install.sh

by pressing the Enter key we confirm the beginning of the installation, and upon receipt of the request - enter the sysdba password.

The installation script automatically launches a systemdunit firebird-superserver(the default Firebird 3.0 architecture). The Firebird service will work with the default parameters for the super server: a page cache of 2048 pages (per base), a sorting buffer of 64 MB (shared) and connecting only third-version clients. View options firebird.conf:

grep -v ^# firebird.conf | grep -v ^$

Please note that new values ​​from firebird.confwill only be activated after the Firebird service is restarted.

When selecting parameter values, it should be taken into account that there are three main “consumers”: page cache (for the database), sorting buffer (shared), and memory allocated by the server for client connections. You can only manage the first two - the amount of memory for client connections depends on the number and text of cached requests, their plans, and the database objects involved in the requests. The memory evaluation of client connections is done only empirically and can change when client applications and / or database objects change.

For a super server on hosts with a small amount of memory (up to 12-16 GB), you should not allocate more than a third to a quarter of the total RAM for the page cache and sort buffer.

If the number of databases is not fixed and can change, the total memory of the page cache should be divided by the maximum number of databases that can be on the server. The size of the page cache is set in pages and it must be separately converted to bytes.

To switch to the classic architecture, you must at least explicitly specify ServerModein firebird.conf, reduce the page cache in the same place (no more than 2K), reduce the sort buffer (the total allowable amount of all sorts, divided by the maximum number of connections), disable and stop the unit firebird-superserver, enable and run unit firebird-classic.socket.

Using the superclassics architecture in Firebird 3.0 does not make much sense: “reliability” - like a superserver, has the same general sorting buffer. There is no general page cache and the “loss” to synchronize different connections between themselves is the same as that of a classic.

It should be remembered that in Firebird 3.0 some of the parameters (page cache, lock file sizes, hash tables, and some others) can be set databases.confindividually for each database. For a superserver it is useful, for example, to set a small value DefaultDbCachePagesin firebird.confand set individual page caches to the necessary databases in databases.conf.

Ask questions about the article in the comments, or write letters to our support address support@ibase.ru.

All Articles