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

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

For delivering the Firebird distribution to the target system, this guide opts for the method of downloading the tar.gz archive via a link from the official project website (firebirdsql.org).

For the impatient—let's get started:

Quick installation

Editing the file /etc/sysctl.conf, adding the line:

vm.max_map_count = 256000

Save the file and apply the setting:

sudo sysctl -p /etc/sysctl.conf

Further instructions vary for CentOS 8 and Ubuntu 19, but LINK and DIRECTORY refer to the link from the official Firebird project site for downloading the distribution and the directory where the distribution will be unpacked during the download process.
As of now (March 2020), the current release is Firebird 3.0.5 (here's the 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 LINK|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- LINK|tar -zxC /tmp

Installation of the Firebird DBMS itself:

cd /tmp/DIRECTORY
sudo ./install.sh

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

Main Section

A brief preamble

It is assumed that the OS has already been installed in a minimal variant and access to public repositories or their local copies has been configured.

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

Planning

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

Temporary files include lock files, sort files, and files for 'materializing' global temporary tables (GTT) and monitoring tables. Sort files and global temporary tables are located in /tmp, mon$-table files and lock files are in /tmp/firebird.

Sort files are 'removed' (unlink) immediately after creation, so they cannot be 'seen' in the directory listing—only in the list of process descriptors (handles) marked as deleted):

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

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

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

where NUMBER is the descriptor of the file of interest.

Instead of calling 'pgrep executable-file', one can directly substitute the identifier of the process of interest.

Temporary files can be very large, so it is recommended to allocate at least 20-30 GB. Note that the size of the sort files depends solely on the amount of data being explicitly or implicitly sorted in the query, and a single user can 'generate' gigabytes of temporary files. /tmp The section for database files should accommodate files for all databases plus, at a minimum, a copy of the largest database file. The growth of database files should be taken into account for several years ahead.

The local backup section should contain at least one archive backup for all databases plus a backup of the largest database. Ideally, there should also be space in this section for restoring the largest database. The growth of backups and backup archives should be considered for several years ahead.

The Firebird 3.0 DBMS server dynamically allocates and frees system memory, which can lead to its fragmentation. For instance, after a significant number of users disconnect from the super server at once, connection errors may occur upon new connections.

Preliminary Preparation

Memory fragmentation is controlled by the system parameter

vm.max_map_count , with a default of 64K. It is recommended to increase its value fourfold:sudo sysctl vm.max_map_count=256000

To ensure the new value is set upon system reboot, we add the following line in the file

: /etc/sysctl.conf It is advisable to include a comment to clarify the reason for changing this parameter. You can first edit the file and then apply the saved settings:

vm.max_map_count = 256000

Installing the necessary packages

sudo sysctl -p /etc/sysctl.conf

The executable files for Firebird 3.0 Linux depend on the ncurses libraries (

libncurses.so.5), ICU (without version binding and without display in output) and tommath ( lddlibtommath.so.0). Utilities will be required for downloading and unpacking the archive build.The versions of ICU are not critical. gzip, tar and curl or wgetWorking with packages depends on the system and the package manager used in the system, so we will consider them sequentially. gzip, tar and curl/wget CentOS 8 uses a new package manager -

dnf

CentOS 8

, which is also 'transparently' called by the command yum . Since there is no difference between them for our purposes - the examples will use Updating the metadata cache:sudo yum makecache Updating the metadata cache:.

The libtomath package is located in a separate E(xtra)P(ackages for)E(nterprise)L(inux) repository, so we need to check that it is already enabled: yum -C repolist

The 'cache-only' option (

--cache-only

)-C or .) is used to exclude unnecessary checks and downloads, speeding up yum operations. If the epel repository is not in the list, we install it and update the metadata cache:

sudo yum install epel-release &&
sudo yum makecache

We confirm requests, verifying PGP key values against those known from a trusted source, if necessary.

If there are issues loading repository metadata from https resources, we edit the file /etc/yum.repos.d/epel.repo, replacing https:// to http:// and repeat the cache update command.

We check the status of the required packages (the command is composed, the example output filtered out the 32-bit package):

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 and ncurses are located in the pseudo-repository of the installer (anaconda), and tar – excluded from the minimal system installation. Major versions libncurses and libtommath are greater than required: 6 and 1 instead of 5 and 0, respectively. If a package is both installed and available, an update has been released for it. We install the missing packages:

sudo yum install 
libicu libtommath tar

Ubuntu 19

Package management is handled by the utilities apt, apt-get and apt-cache. The first is intended for interactive use, while the last two are designed for script usage. The package names are slightly different and include the version.

We check the status of the required packages (the command is composed, the example output is shortened and the 32-bit packages 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 brackets indicate installed/upgradable – are installed. Available but not installed ncurses5, instead of curl is installed wget. We install the missing packages:

sudo apt-get install 
libncurses5 libtommath1

Creating symlinks

Since libtommath.so.1 and libncurses.so.6 are backward compatible with ). Utilities will be required for downloading and unpacking the archive build. and ), ICU (without version binding and without display in output, for Firebird it is enough to create symlinks to the existing versions of the libraries.

Let's find libtommath.so.1 (libncurses.so.? are 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 the 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 composed, examples of output 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.

On the official Firebird project website (firebirdsql.org), links to the distributions of 'official' releases and 'daily' builds are published.

Official releases for Linux are available as archives (tar.gz) and deb/rpm packages, while builds are only available as archives. We will consider the 'generic installer' (generic installer from tar.gz).

The build archive needs to be downloaded and unpacked, but we will combine both processes. Unpacking is done in /tmp, URL refers to the link for the downloaded archive.

curl:

curl -L URL | tar -zxC /tmp

wget:

wget -O- URL | tar -zxC /tmp

the net/http curl sends the downloaded data to standard output but does not handle redirects, so we add '-L', while wget, on the contrary: handles redirects but writes data to a file, so we use '-O-'. For tar we indicate the use gzip-filter and the directory where unpacking will occur. 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 and manifest.txt.

Installing Firebird

During the preliminary preparation, we adjusted the system parameter value , with a default of 64K. It is recommended to increase its value fourfold:, checked for the presence and installed the ICU, ncurses, and tommath libraries. We ensured the correctness of the versions of ncurses and tommath (libncurses.so.5 and ). Utilities will be required for downloading and unpacking the archive build.) and created the necessary symlinks.

The installation itself is very straightforward. We navigate 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

and run the installation script:

sudo ./install.sh

by pressing Enter, we confirm the start of the installation, and when prompted, we enter the sysdba password.

The installation script automatically starts the systemd-unit firebird-superserver (the default architecture for Firebird 3.0). The Firebird service will run with default parameters for the superserver: a page cache of 2048 pages (per database), a sort buffer of 64 MB (total), and connections only from third-version clients. View the parameters firebird.conf:

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

It should be noted that new values from firebird.conf will be activated only after restarting the Firebird service.

When selecting parameter values, it is important to consider 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 only manage the first two—the amount of memory for client connections depends on the quantity and text of cached queries, their plans, and the database objects involved in the queries. The estimation of memory for client connections is done empirically and may change with alterations to client applications and/or database objects.

For super servers on hosts with a small memory capacity (up to 12-16 GB), it is not advisable to 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 may change, the total amount of memory for 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 specified in pages, and it must be separately converted to bytes.

To switch to the classic architecture, it is necessary to explicitly specify at least ServerMode downward API support (simultaneously with this in firebird.conf, reduce the page cache there (no more than 2K), decrease the sort buffer (the total allowable volume of all sorts divided by the maximum number of connections), disallow and stop the unit firebird-superserver, allow and start the unit firebird-classic.socket.

Using the super classic architecture in Firebird 3.0 does not make much sense: the "reliability" is the same as for the super server and the same shared sort buffer. There is no shared page cache and "losses" for synchronizing different connections among themselves are the same as for classic.

It should be noted that in Firebird 3.0, some parameters (page cache, local file sizes, hash tables, and a few others) can be specified in databases.conf individually for each database. For the super server, it is useful, for example, to set a small value for DefaultDbCachePages downward API support (simultaneously with this in firebird.conf and to establish individual page caches for the required databases in databases.conf.

If you have questions about the article, please ask in the comments or write emails to our support address. support@ibase.ru.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster