How to access Firebird / Interbase using LOCAL, REMOTE and EMBEDDED way? And what the differences between it?
First, let's understand the concept behind the word "localhost" often used when we talk about computer networks.
Once and for all, we should know that "localhost", is nothing more than a simple way to remember the address used by the network service to refer to the "own computer" where the network is being used. That is, when we refer to "localhost", in fact, we are referring to the network address "127.0.0.1", which is the address of the device itself that connects to a network (even if there are no other devices on this network ).
Knowing this, you should realize that "there is" a network address, not anything else for this use!
Therefore, it is a big mistake to understand that "localhost" means to "local". Well, indeed, it is not!
It should be understood by "local", something that is accessed locally, however, without subterfuge such as those used by some protocol, for example.
Remembering here, that a protocol is, in fact, an algorithm (code), which, through a specific programming, performs a specific task. For example, an encryption protocol, encrypts. An information transport protocol transports information. etc...
Thus, a protocol is an algorithm that, through business rules, enables or disables certain actions within its scope of use.
As you can see, in view of the above, "localhost" does not mean "that something is in the place where everything originated", but rather, "that something originated in this place will be undergoing an analysis of the local network protocol", in this case by the protocol TCPIP.
Now, let's understand what the differences between these 3 ways used by Firebird / Interbase or any similar (the Firebird have anothers flavors)?
LOCAL ACCESS: the access do file from database DOES NOT PASS through the TCP IP protocol stack! it needs that Server be running! REMOTE ACCESS: the access do file from database DOES PASS through the TCP IP protocol stack! it needs that Server be running! EMBEDDED ACCESS: the access do file from database DOES NOT USE the TCP IP protocol stack! it DONTneeds that Server be running! preferably, it is desirable that the server is not running, at least not on the default port used by Firebird!
To avoid any attempt to use it, do not run Firebird server on the target computer!
Here, it is worth a caveat: Firebird is smart enough to try to access the database using the server in use, so, specifically in this case, do not enter the username/password when trying to access the database. (as the database normally has a username and password, trying to access it using a server will cause an access error!).
So, how to identify whether or not we need local or remote access to a Database?
Could you answer simple questions like?
Do you need your Database to be accessed by multiple clients (users or applications)? If the answer is "YES", then your Database must use one of the modes: REMOTE or LOCAL. If the answer is "NOT", then your Database must use the mode: EMBEDDED.
Do you need exclusive access to the Database file? If the answer is "YES", then your Database must use the mode: EMBEDDED. If the answer is "NOT", then your Database must use one of the modes: REMOTE or LOCAL.
And, how to know if we are accessing a Database in "LOCAL", "REMOTE" or "EMBEDDED" mode?
In fact, it will only be possible if we look at the "connection string" used, otherwise it will be difficult to know for sure.
An example is using the "ISQL" tool, which accompanies the Firebird installation in all its editions.
Even using "ISQL", which is a simple shell to work with Database Firebird, we can be wrong about the type of access performed to the Database.
If, in the command line of opening the Database, you do not explicitly indicate the type of access to the Database, we may be surprised by the effects of multiple accesses to the same database. All this will be closely linked to whether or not the Firebird Server is running, and the "connection string" used.
Whether on MSWindows or Posix systems (Linux, macOS, Android, etc...), the 3 modes above have the same meaning. Therefore, there should be no differences in your understanding.
To simplify, we can understand the following:
REMOTE ACCESS: we need the Firebird server to be running; we need to indicate the network address and the communication port with the Firebird service; we need to indicate the username and password to access the Database; We/Service Firebird needs to have access to the location where the Database file is hosted;
LOCAL ACCESS: similar to the REMOTE ACCESS, however, we do not use the TCPIP protocol, but the "XNET" (MSWindows) or "INET" (Posix) protocol. Such protocols work as if they are accessing shared data in memory, and therefore accessing files (and consequently data) will be faster than accessing via TCPIP network.
EMBEDDED ACCESS: The Firebird Server/Firebird Service does not need to be running, and it is better not to! We must not indicate the network address and access port to the Firebird service! We don't need to indicate the user, that is, from the Database. Preferably, we should not indicate them! The Database must be in a location accessible to the user of the client application. Preferably, in the same directory as the application!
How would the representation of the "connection string" be in the 3 access modes to the Database?
Let's use the following address of the Database file : network address used by Firebird Server: 127.0.0.1 (may be any other acceptable) port used by Firebird Server at address: 3050 (default port of Firebird installation - any other acceptable) directory on Firebird Server disk: c:\MyDB Database file : mydatabase.fdb Database user: sysdba user password: masterkey user privileges in Database directory: read/write Client application to access: ISQL.exe (comes with Firebird installation)
Note: The "XNET" and "INET" protocols use two forward slashes ("//") after the colon, like this: XNET:// and INET://
in Linux, preferably, we will create our directory inside the directory "/var", and we must give reading and writing privileges to the user "firebird" so that he can manipulate the Database file, otherwise no other user who uses Firebird will be able to access the Database.
NOTE: EMBEDDED ignore "user" and "pass" used, or if "invalid"!!!
On MSWindows, all users also need access to the directory where the Database is located. The difference between MSWindows and Posix is the way privileges are given to files, as well as users and groups where each user is registered. In general, every user must be able to read and/or write to the Database file, as well as the Firebird Service itself.
In MSWindows, the Firebird user is defined as a "local account", and therefore they have some restrictions on accessing files and directories on the system. On Linux, the user "firebird" belongs to the group called "firebird", or anyone is restricted to full access (can do almost any action with files and sub-folders) in the folder called "/opt/firebird/".
In MSWindows, we can use the services tool ("services.msc") to run or stop the Firebird service. Of course, we can use a command line in the MSWindows console "prompt" to have the same effect, as well as some other working tools for that. To test, you can run MSWindos prompt (CMD or any other shell) and run the following command: start services.msc Now, look for the Firebird service and see the options for it.
On Linux, you use the "Terminal" and send the following command: ps aux | grep firebird --> see if Firebird service is installed and running sudo kill -9 <<service ID>> --> kill the service for the given "ID" sudo systemctl start firebird --> start the Firebird service if it is installed on the system.
Many newbies use old techniques to give access to the Database to users who don't actually have such privileges to access the Database file.)
An example is when the user wants to change the access password of the user "SYSDBA".
Usually it tries to give "read and write" access to the file, try to change the owner of the file, etc...
However, in fact, none of this is necessary.
In Firebird 3 or 4, many things have changed, and even on Posix systems, which are stricter than MSWindows, they allow you to use a less expensive way to access the Firebird Security Database, "security3.fdb or security4.fdb" .
First, you only have access to the directory where the file is located, it's basic!
Second, it must have "read and write" privilege on the file.
And thirdly, you can do "Embedded" access like any other Database Firebird files.
Of course, keep in mind that changing the password of the user "SYSDBA" is something of a lot of responsibility, because, once carried out, it will have consequences on all other actions in your data system on that Firebird Server.
Lastly, it doesn't matter what tool you use to create and maintain your Firebird Databases. All of them, practically, will give some kind of access to the 3 access modes to Databases. Be the "ISQL", "FlameRobin", "IBExpert", "IBConsole", etc...
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
in WeDelphi.com my article is more complete with screenshots...
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
complete article about Firebird (... it will be updated) https://wedelphi.com/t/422452/post-3471299
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
In Android the "case" it's more complicated... because that it's necessary create "Symbolic links" for main ".SO" file, and like the Firebird Embedded it's a "full server" packaged in one file, restrictions to load it, restrictions in files system, etc... etc... etc...
I'm testing my new setup to Firebird / Android, but not yet ended.
Phases to Firebird v4.0.2 Embedded and Android 11:
0) prepare and create a directory to Firebird = OK 1) deploy necessary files to Android = OK 2) create "symbolic links" to "xxxxxx.SO.n.n" (lib Server) on Android = OK 3) set the temp variables for Firebird usage = OK 3) prepare app to load files Firebird (using FireDAC) = OK 4) load and works = NOT OK >:)))))
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
Firebird Embedded mode in MSWindows environment: ----------
ALL DATABASE FILE WAS CREATED BY IBEXPERT v2015.12.xx USING EACH FIREBIRD VERSION IN EMBEDDED MODE!
NOTE 0: by default, the "default configuration" will be used! Else, you can needs the "conf" files, like "Firebird.conf", UDFs, Intl, etc...
NOTE 1: All other files it's necessary only in specific usage, like UDF libs, if using functions on UDF files!!! For that, just files below was used in my tests, and works!
NOTE 2: The "user name/password", in fact, it's not necessary for "Embedded" mode. But, if the database was created using a user/password not that "SYSDBA/masterkey", it can requires to internal actions! -- in Firebird 1.5.6 was necessary inform the user/password in "Embedded" mode!!! >:(
NOTE 3: same that it's not necessary user/password to access the database, you need have "privilegies" in "tables/view/stored procedures/triggers/etc..."!!! to avoid this, give for all database objects (tables, views, etc...) privilegies to "PUBLIC" user!!!
---------- ...Firebird v1.5.6 Embedded 32 on MSWindows...: (at general, in another v1 sub-editions it should be the same) ---------- NOTE 1: "security database" it's not used in "Embedded" mode, but the "user/password" on Database will be, as well as "internal permissions" to access! NOTE 2: for client-application 32bits, usage FB 32bits files. For 64bits DOES NOT EXITS!!!
<<my-dir-root-executable>>\<<My Executalbe-App>> ... <<my-dir-root-executable>>\<<my-fb-root>>\fbembed.dll <-- just 1 file!!! >:) ...
---------- ...Firebird v2.59 Embedded 32/64bits on MSWindows...: (at general, in another v2 sub-editions it should be the same) ---------- NOTE 1: when DB was opened, Firebird will create a "firebird.log" in its "<<my-dir-root-executable>>\<<my-fb-root>>\" NOTE 2: for client-application 32bits, usage FB 32bits files. For 64bits, FB 64bits files! Of course...
---------- ...Firebird v3.09 Embedded 32/64bits on MSWindows...: (at general, in another v3 sub-editions it should be the same) ---------- NOTE 1: when DB was opened, Firebird will create a "firebird.log" in its "<<my-dir-root-executable>>\<<my-fb-root>>\" NOTE 2: "security3.fdb" it's not used in "Embedded" mode, but the "user/password" on Database will be, as well as "internal permissions" to access! NOTE 3: for client-application 32bits, usage FB 32bits files. For 64bits, FB 64bits files! Of course...
<<my-dir-root-executable>>\<<My Executalbe-App>> ... <<my-dir-root-executable>>\<<my-fb-root>>\engine12.dll <--- it's mandatary have a "copy" in same place than "fbclient.dll" and "plugins" folder!!! <<my-dir-root-executable>>\<<my-fb-root>>\fbclient.dll <<my-dir-root-executable>>\<<my-fb-root>>\icudt52.dll <<my-dir-root-executable>>\<<my-fb-root>>\icudt52l.dat <--- this file is the same in 32/64bits! <<my-dir-root-executable>>\<<my-fb-root>>\icuin52.dll <<my-dir-root-executable>>\<<my-fb-root>>\icuuc52.dll <<my-dir-root-executable>>\<<my-fb-root>>\plugins\engine12.dll ...
Na versão 4 do Firebird, deve ser utilizada a seguinte estrutura de diretorios e arquivos: ---------- ...Firebird v4.02 Embedded 32/64bits on MSWindows...: (at general, in another v4 sub-editions it should be the same) ---------- NOTE 1: when DB was opened, Firebird will create a "firebird.log" in its "<<my-dir-root-executable>>\<<my-fb-root>>\" NOTE 2: "security3.fdb" it's not used in "Embedded" mode, but the "user/password" on Database will be, as well as "internal permissions" to access! NOTE 3: for client-application 32bits, usage FB 32bits files. For 64bits, FB 64bits files! Of course... NOTE 4: Firebird v4.02 does not needs "Engine13.dll" copy in "<<my-dir-root-executable>>\<<my-fb-root>>\".
<<my-dir-root-executable>>\<<My Executalbe-App>> ... <<my-dir-root-executable>>\<<my-fb-root>>\fbclient.dll <<my-dir-root-executable>>\<<my-fb-root>>\icudt63.dll <<my-dir-root-executable>>\<<my-fb-root>>\icudt63l.dat <--- this file is the same in 32/64bits! <<my-dir-root-executable>>\<<my-fb-root>>\icuin63.dll <<my-dir-root-executable>>\<<my-fb-root>>\icuuc63.dll <<my-dir-root-executable>>\<<my-fb-root>>\plugins\engine13.dll
Final Note: -- for Firebird v1.x.x and v2.x.x you needs the "FBEMBED.DLL"; -- "FBEMBED.DLL" is a "FULL" SuperServer model, or be, in one file you have a complete Firebird server, for that, you need download the Embedded version in FirebirdSQL site. -- For Firebird v3 and later, you can use the files in installed by Setup, or be, the "FBCLIENT.DLL" - there is not other file!!!
Firebird official downloads: https://firebirdsql.org/en/server-packages/
...
此帖子包含附件: 大小:220.5K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
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.
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
12 Common Mistakes While Backing Up Databases Firebird Gbak Tips and Tricks 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.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
http://bbs.2ccc.com/topic.asp?topicid=632614
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
NOTE: this test was done in 2014... using a Desktop base, not for Server... Imagine now with a high-end Server hardware and Firebird 4.
Firebird performance degradation: Database 30GB to 1.7TB... Tests, miths and truth ... done in 2014 by IBSurgeon!!!
Complete article with graphical and data performances!
A basic desktop PC, not a real server, to show the Firebird power!!! -- CPU AMD-FX8350 -- RAM 16GB -- SATA software RAID1 2x4Tb Seagate drives -- Operation System Windows Server 2008R2 (2008R2 is 64 bit).
Firebird performance degradation: tests, myths and truth: https://wedelphi.com/t/422467/
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
yes! Firebird always needs a DLL *(= Library to Embedded Server - or other extension in another O.S.)* to embedded server
basically 2 files -- 1 DLL "fbclient.dll" or simiilar -- 1 message file "firebird.msg"
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3