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

In this article, we will describe the minimum set of steps required for the optimal installation of Firebird DBMS version 3.0 on new Linux distributions. CentOS 8 and Ubuntu 19 are selected for examples.

To "deliver" the Firebird distribution to the target system, in this guide, the option of downloading the tar.gz archive from the link from the official website of the project (firebirdsql.org).

For the most impatient - immediately into battle:

Quick install

Editing 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 ССЫЛКА и КАТАЛОГ denote a link from the official website of the Firebird project for downloading the distribution and the directory into which the distribution will be unpacked during the download.
At the moment (March 2020), the Firebird 3.0.5 release is relevant (Here is the link for the 64-bit version).

8 CentOS

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

The actual installation of the Firebird DBMS:

cd /tmp/КАТАЛОГ
sudo ./install.sh

If you want to better understand what these actions serve, 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 a basic knowledge of Linux and the Firebird DBMS.

Planning

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

Temporary include lock-files, sorting files, "materialization" files of global temporary tables (GTT) and monitoring tables. Sort and global temporary table files are located in /tmp, mon$-table files and lock-files - in /tmp/firebird.

Sort files are "deleted" (unlink) immediately after creation, so they cannot be "seen" in the directory listing - only in the list of process handles (labeled as deleted):

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

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

sudo stat -L /proc/`pgrep firebird`/fd/НОМЕР

where НОМЕР – 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, so for /tmp it is recommended to allocate at least 20-30 GB. Keep in mind that the size of the sort 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 must contain files of all databases. plus at least a copy of the largest database file. It is necessary to take into account the growth of database files in the future for several years ahead.

The local backup section must contain at least one backup archive of all databases plus a backup of the largest database. It is desirable that this section also has a place to restore the largest database. The growth of backups and archives of backups in the future for several years should be taken into account.

Savant Providence

The Firebird 3.0 DBMS server dynamically allocates and frees system memory, which can lead to its fragmentation. For example, after a large number of users are disconnected from the superserver at the same time, errors may occur during new connections.

Memory fragmentation is controlled by a system parameter vm.max_map_count, default is 64K. It is recommended to quadruple its value:

sudo sysctl vm.max_map_count=256000

To set the new value when the system is rebooted, add to the file /etc/sysctl.conf line:

vm.max_map_count = 256000

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

sudo sysctl -p /etc/sysctl.conf

Installing required packages

Firebird 3.0 Linux DBMS executables depend on the ncurses libraries (libncurses.so.5), ICU (without reference to the version and without display in the output ldd) and tommath (libtommath.so.0). Utilities are required to download and unpack the assembly archive gzip, tar и curl or wget. ICU versions, gzip, tar и curl/wget - are insignificant.

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

8 CentOS

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

Update the metadata cache: sudo yum makecache

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

yum -C repolist

Cache only option (-C or --cache-only) is used to eliminate unnecessary checks and downloads, making yum run faster. 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 requests, if necessary, checking the values ​​of pgp keys with those already known from a trusted source.

If there are problems when loading repository meta-information from https-resources, then edit the file /etc/yum.repos.d/epel.repo, replacing https:// on http:// and repeat the cache update command.

Check the status of the required packages (the command is complex, in the example output a 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, gzip и ncurses placed in the installer pseudo-repository (anaconda), and tar – Excluded from the minimum system installation. Major versions libncurses и libtommath more than required: 6 and 1 instead of 5 and 0, respectively. If the same package is both installed and available, an update has been released for it. Install the missing packages:

sudo yum install 
libicu libtommath tar

Ubuntu 19

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

Check the status of the required packages (the command is folded, the sample output is shortened and 32-bit packages 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 with square brackets installed/upgradable – installed. Available but not installed ncurses5, instead of curl set wget. Install the missing packages:

sudo apt‑get install 
libncurses5 libtommath1

Creating symlinks

Since libtommath.so.1 и libncurses.so.6 backward compatible with libtommath.so.0 и libncurses.so.5, then for Firebird it is enough to create symlinks to the available versions of the libraries.

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

We 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

We check the result (the command is complex, the 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

Loading the distribution kit of Firebird DBMS.

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

Official releases for Linux are available as archives (tar.gz) and deb/rpm packages, while builds are available only as archives. We will consider the "general 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, URL denotes a link to the downloaded archive.

curl:

curl -L URL | tar -zxC /tmp

wget:

wget -O– URL | tar -zxC /tmp

By default curl sends the downloaded data to stdout, but doesn't handle redirects, so we add "‑L", a wget, on the contrary: handles redirects, but writes data to a file and we put "‑O‑". For tar indicate the use gzip-filter and the directory to which the unpacking will be performed. Upon completion of the process, a directory of the form will appear Firebird‑3.0.5.33220‑0.amd64 with three files: install.sh, buildroot.tar.gz и manifest.txt.

Installing Firebird

In the course of preliminary preparation, we adjusted the value of the system parameter vm.max_map_count, checked for and installed the ICU, ncurses and tommath libraries. Verify that the ncurses and tommath versions are correct (libncures.so.5 и libtommath.so.0) and created the necessary symlinks.

The actual installation is very simple. Go to the directory where the Firebird distribution archive 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 start of the installation, and upon receipt of the request, we enter the sysdba password.

The installation script automatically runs systemd-unit firebird-superserver (default Firebird 3.0 architecture). The Firebird service will run with the default settings for the superserver: 2048 page cache (per database), 64 MB sort buffer (shared), and connection only for version XNUMX clients. View settings firebird.conf:

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

Note that the new values ​​from firebird.conf will be activated only after restarting the Firebird service.

When selecting parameter values, it should be taken into account that there are three main "consumers": the page cache (for the database), the sort buffer (shared) and the memory allocated by the server for client connections. You can manage only 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. Memory estimation of client connections is done only empirically and may change when client applications and/or database objects change.

For a superserver 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 bases is not fixed and can change, the total amount of page cache memory should be divided by the maximum number of bases that can be on the server. The page cache size is specified in pages and must be converted to bytes separately.

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

Using the superclassic architecture in Firebird 3.0 doesn't make much sense: "reliability" is like a superserver and the same sort buffer. There is no common page cache and the “losses” for synchronizing different connections with each other are the same as in the 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 in databases.conf individually for each base. For a superserver, it is useful, for example, to set a small value DefaultDbCachePages в firebird.conf and install individual page caches for the required databases in databases.conf.

Ask questions about the article in the comments, or write letters to our support address [email protected].

Source: habr.com

Add a comment