HQbird Cluster: cluster and replication
Cluster and replication HQbird Cluster
The master writes changes to segments and sends them to replicas over a secure channel. The node makes the database copy for a new replica itself, through nbackup, while users keep working. The cluster manager (RCM) shows the lag, queues and errors of all nodes. It also moves the master to another host: as a planned move, without data loss, or as an emergency move, when the master host is lost.
- Firebird 2.5 · 3 · 4 · 5
- nbackup copy without stopping the master
- switchover without data loss
- failover manual or by a rule
- router the connection string does not change
- mTLS on all channels
Nodes · RCM · layouts
How the cluster works
A node runs next to each Firebird. A node has one role: master or replica. The master node sends segments, the replica node receives them, and the replica's Firebird applies them to its copy of the database.
There is one RCM per cluster. It runs on any host that can reach all nodes. Nodes send it statistics, and it passes operator commands to them. RCM links a master and a replica by the database GUID, not by the node name.
RCM is not installed by itself. You turn it on on one host when you need a cluster. You can put a router in front of the applications: it always sends them to the current master.
| Component | How many | What it does |
|---|---|---|
| Firebird (HQbird) | on each database server | Stores databases and writes replication segments. |
| fbagent | one per Firebird instance | Stops and starts Firebird when the node asks. |
| hqclusternode | one per instance and role | Sets up replication, sends segments, makes the database copy for a replica. |
| hqbirdrcm (RCM) | one per cluster | Web interface, commands, alerts, statistics. Runs switchover and failover. |
| Router (hqclusternode router) | optional, on the application host, Linux | Keeps HAProxy pointed at the master of each service. Applications connect to the router. |
- Same major version5.0 on the master, 5.0 on the replica. Otherwise the replica refuses before any data transfer.
- HQbird 2.5 and 3.0Replication through the replconf plugin. Filters define the set of tables.
- Own folder for each masterThe replica puts the database in a folder named after the master node. Databases with the same name from different masters do not conflict.
- No fbagent, no changesIf fbagent is not available, the node refuses any action that changes the configuration. It does not work “partly”.
- Node without RCMA node can work on its own. RCM is needed for the overview and commands.
- Channel compressionFor a slow network: zstd per peer, takes effect at once.
- Up to 3 hosts without HQCenterEach host with a master or a replica takes a place in the cluster. RCM does not accept a fourth host.
RCM · pairing window · Link hosts · slots
How to build a cluster
HQbird setup puts the cluster programs on each server, but does not turn them on. RCM and the pairing window are off by default. You build a cluster in three steps: turn on RCM on one host, open the pairing window on the other hosts, link the hosts with one button.
- 1Turn on RCMon one host: in HQ Monitor or with
fbagent --cluster-init - 2Open the pairing windowon the other hosts, for 24 hours
- 3Link hostsRCM finds the agents, issues certificates and starts the nodes
Step 1. RCM on one host
In HQ Monitor, open the “Cluster on this server” section and turn on RCM. A command on the host does the same. The agent creates the cluster CA, the RCM certificate and the first user. Ports 7443 and 7444 open in the firewall.
fbagent --cluster-init <id>
During setup, the switch --rcm on (Linux) or /RCM (Windows) does the same.
Step 2. Pairing window
On each host that will join the cluster, the agent opens the pairing port for 24 hours. The port closes by itself when the window ends or when the agent has joined the cluster.
fbagent --cluster-pairing on
A button in HQ Monitor does the same. During setup: --cluster-pairing on or /DISCOVERY.
Step 3. Link hosts
In RCM, open Settings → Link hosts and enter the hosts, one per line. The Check hosts button reads ports 7450–7459 of each host. Each agent that answered is one row of the table.
- A row shows: port, instance, Firebird version and port, node port, certificate fingerprint.
- Select the rows with check boxes and choose the master. A row with an error does not block the other rows.
- Link issues a certificate to each agent, creates the members and the master → replica links.
- RCM waits up to 10 minutes for the agent certificate and up to 20 minutes for the nodes to start.
hqbirdrcm cluster link -hosts db1,db2,db3 -master db1
Compare the fingerprint in the row with the one that the agent showed on its host. This way you know that you link the correct server.
- Several agents on one hostEach agent has its own slot from 0 to 9. Pairing port 7450 + slot, node ports 7051 + slot and 7061 + slot. Setup chooses the slot; the switch
--pairing-portsets it explicitly. - Add memberThe Cluster page suggests a free node port and refuses a port that another member of this host uses.
- Member names
<host name>-masterand<host name>-replica. RCM does not rename a member: a new name is a new member. - Without the pairing windowRCM issues a token for one agent, for 24 hours. On the new host:
fbagent --cluster-joinwith this token and the CA hash.
- RCM ownerThe agent that turned on RCM on the host. A second agent on this host gets a refusal. If the owner is removed,
fbagent --cluster-init --rcm-takeovermoves RCM to another agent. The cluster gets a new CA, and you must link the members again. - Leaving the cluster
fbagent --cluster-leavestops the nodes, closes their ports and deletes the cluster certificates. The node folders stay;--remove-datadeletes them. The agent leaves by itself if RCM revoked it or removed its last member. - FirewallThe agent opens and closes its cluster ports itself. It does not close a port that was open before it.
- Removing HQbirdThe RCM owner is not removed while other agents use its RCM. The setup wizard asks; silent mode needs
--forceor/FORCE.
The Clusters page in the local HQ Monitor works through the agent on the RCM host. It does not need the RCM password. Only an administrator sees the “Cluster on this server” section.
Initialization · reinit
New replica without stopping the master
A replica gets the database only from the master. The master node freezes the file with nbackup -L, sends it in parts and removes the lock at once. Master users keep working the whole time: their changes go to .delta and later return to the database.
gbak and a manual file copy do not work here. gbak changes the database GUID and breaks the master–replica link. A file copy of a running database is not consistent.
Master users
Files
- Connection lossThe transfer continues from the last received part. An unfinished copy stays on the replica for 24 hours.
- ErrorThe node removes the lock, deletes the unfinished file and sets the database to FAILED. The next attempt starts from a known state.
- Transactions during the lockThey are not lost. Firebird 4 and 5: the node finds the transactions open at the moment of
nbackup -L, and the replica repeats them from the segments. HQbird 2.5 and 3.0: the node waits for such transactions to end (about a minute), otherwise the copy does not start.
- One database at a timeBy default the master node copies one database. The others wait in a queue.
- Other replicas of this databaseWhile the copy runs, they do not get segments of this database. Later they catch up.
- Automatic reinitializationRCM can copy a database in the NEEDS_REINIT state again by itself, only in a set window. Off by default.
The gentle mode waits for long transactions
Before the lock, the node looks for write transactions that started before the oldest segment in the master's archive. If the archive is empty (first copy), the limit is the moment when the node turned on publication. The replica cannot repeat such transactions and would stop. So the copy does not start while such transactions are open.
RCM shows the five connections with the oldest transactions: user, client, age, current query. You can disconnect them and repeat the copy at once. While the copy waits, the master's archive is not cleaned, but for no more than 1000 segments. Then cleanup continues, and RCM raises an alert.
The normal mode locks the database at once, without the check.
Space and speed
| Where | What is needed |
|---|---|
| Master, database volume | At least 105 % of the database size free. .delta grows during the copy. |
| Replica, database volume | 105 % plus the volume reserve free_space_floor_gb (1 GB by default). The node reserves the full size in advance; no second copy is needed. On a repeated copy, the old file stays until the end. If there is no space for both files, the “Remove the old replica” check box deletes the old file before the transfer. |
| Night speed | In the transfer window (23:00–05:00 by default) it is constant, 100 MB/s by default. |
| Day speed | A share of the measured disk speed, half by default. A copy started in the day speeds up at night by itself. |
Space is checked twice and only before the lock: first by RCM from statistics, then by the nodes with a live measurement on both sides. The node check cannot be skipped: it protects the disk from filling up in the middle of the copy.
Firebird 4 and 5 · HQbird 2.5 and 3.0
Publication: which tables go to the replica
Firebird 4 and 5 write to segments only changes of published tables, and only when publication is on. Without it, changes do not reach the replica. The node notices this and raises an alert. The “Sync publication” button turns it on and builds the correct table list.
What the sync does
- turns publication on, unless the operator turned it off on purpose;
- adds all tables with a primary key or a unique index;
- removes tables without a key and tables that the operator excluded;
- turns off automatic adding of new tables.
Without a key, the replica cannot find the row for UPDATE and DELETE. So such a table cannot be published: add a key and sync again.
- Hourly checkIf publication is off, the node checks it every 2 minutes. For a database with a replica, this is an alert.
- Exclusion listStored on the master node. When a replica is promoted to master, the list moves to the new master.
- New tableDoes not join the publication by itself. Create a key and click “Sync publication”.
- Copy without publicationThe master node refuses to copy the database if publication is off or has no tables (
publication_off). The initialization window offers “Sync publication and initialize”. - HQbird 2.5 and 3.0No publications. Include and exclude filters in the replication settings define the set of tables.
Changes made while publication is off or a table is excluded do not reach the replica, even after you turn it on. “Verify” compares only row counts; it does not find lost UPDATEs. If the database got writes while publication was off, copy the database again.
Lag · archive · alerts · data check
Monitoring: the replica does not fall behind silently
Nodes send statistics to RCM every 30 seconds. For each master–replica pair you see: the last segment, how many were sent, confirmed and applied, the queue and the lag in seconds.
| Database state | Group in RCM | Meaning |
|---|---|---|
IN_SYNC | Ok | The replica got all segments. |
LAGGING | Pending | The replica lags behind, segments are in the queue. |
SEEDING | Pending | The database is being copied to the replica. |
NEEDS_REINIT | Error | The replica must be copied again. |
FAILED | Error | The last copy failed. |
The master's archive is cleaned in stages
The master keeps sent segments so that a replica can ask for them again. If space is low, it first deletes what is surely not needed.
- 1Applied by all, older than the limitdefault limit is 2 days
- 2Applied, but newer than the limitif less than 1 GB is free; alert
- 3Not applied yetas the last step; the replica needs a new copy
Alerts with instructions
RCM knows more than 20 alert types, and each has an instruction on what to do. You can acknowledge an alert, mute it for 60 minutes or delete it. If the cause remains, the alert appears again.
There is no e-mail or webhook: watch the “Alerts” page or poll the RCM API.
| Code | What happened |
|---|---|
backlog_warn / backlog_critical | The master has 32 / 48 unarchived segments. |
apply_error, replication_stopped | The replica cannot apply a segment. |
replication_guid_mismatch | The master database GUID changed: restore or file replacement. |
segment_missing, sequence_gap | The segment sequence is broken. |
firebird_down, firebird_log_error | Firebird is down or writes errors. |
firebird_not_answering | The Firebird port is open, but a connection to the database has failed for a minute. |
master_publication_off | Publication is off for a database with a replica. |
data_mismatch | The periodic data check found a difference. The data check is turned on separately. |
Master and replica comparison
Verify counts the rows of the selected tables on the master and on the replica and compares them. It does not compare row contents: it will not find changed rows. Run it at a quiet time: under active writes the counts can differ.
The periodic check is off by default: COUNT(*) reads the whole table. Turn it on with the node parameter data_check_enabled; it runs once every 2 hours. New check settings take effect at once, without a node restart. The check compares data when the master and the replica are at the same segment. A difference raises an alert. A table excluded from publication shows as “not published”, not as an error.
- Pause shippingFor one or many databases. After “Resume”, shipping continues from the last segment, without a new copy. The archive grows meanwhile.
- Remote node logsreplication.log, firebird.log and the node log right in RCM, without logging in to the server.
- No licenseThe master stops shipping; Firebird and the databases keep working. After you install a license, shipping resumes by itself within a minute.
- Command logEach RCM command is recorded with its author and result. Cluster report in one JSON file.
Service · epoch · where the master is
Services: one database on several hosts
A service is one logical database on several hosts. The master can move from host to host, but the service name and the database alias do not change. Applications and routers ask RCM where the master of the service is now.
Each master change gets the next number: the epoch. RCM keeps the epoch history: when the master changed and why. RCM finds a service by the node and the file path, not by the GUID: at switchover the database GUID changes, but the path stays the same.
What a service describes
- alias: the database name in
databases.conf. The new master writes it itself. - members: one entry per host: master node, replica node, file path, priority.
- router_port: the port on which routers accept the applications of this service.
- policy: the rules of automatic failover and the mode that closes the old master.
Each host of a service runs two nodes on one Firebird: a master node and a replica node. This is the same “Two nodes per host” layout as in the diagram above.
The master node needs the Firebird address for clients: the advertise_addr parameter. Without it, RCM cannot tell an application where to connect.
Where the master is now
hqbirdrcm services put -id shop -file shop.json hqbirdrcm services hqbirdrcm where -service shop hqbirdrcm where -db shop
where answers with: the master host and address, the epoch number, the replicas and the problems found. Through the API, an application can wait for a new epoch without polling RCM every second.
The Services page in RCM shows the same for each service: the state, the epoch, the master, the Firebird address, the replicas and the problems. The Find field finds a database by alias, service name, GUID or path.
Services in the browser
All that the hqbirdrcm commands do for services is also in the RCM web interface. You do not need the command line for this.
- Service pageThe state and its reason, the master, the replicas with their lag, the hosts and their roles, the routers, the old masters that wait to be closed, the automatic failover rule, the running operation step by step and the history of masters.
- Action buttonsSwitchover, Failover, Rejoin, Resume. Each button first runs a check and shows the problems. The action starts only after you confirm it. A second click does not start a second operation.
- Service formThe New service button creates a service: name, alias, router port and one line for each host. The form offers the nodes and the databases that they see. Check checks the form, Save first shows the list of changes.
- OperationsA page with all switchovers, failovers and rejoins, newest first. While an operation runs, the header of each page has a label with a link to it.
- Deleting a serviceOnly the record in RCM is deleted. The dialog tells what stays (databases, replication, node roles, alias) and what is lost (history, rule, port on the routers), and asks you to type the service name.
- Viewer roleA user with this role sees all pages and runs checks, but has no action buttons.
| Service state | Meaning | What to do |
|---|---|---|
ok | The master works, the replica on another host follows it. | Nothing. |
rejoining | The old master is coming back as a replica. | Wait: the database is being copied. |
degraded_no_replica | The master works, there is no replica. This happens after a failover or after a rejoin error. | hqbirdrcm rejoin |
failed | RCM cannot find out the state, or the master's Firebird does not answer. | hqbirdrcm resume after a check |
A service in the failed state starts neither a switchover nor an automatic failover. Only the operator can take it out of this state: with the resume command, with a rejoin or with a manual failover.
Planned move of the master · without data loss
Switchover: the master moves to another host
Switchover moves the master of a service to another host without data loss. RCM itself stops writes on the old master, waits until the replica applies the last segment, and makes it the master. Then the old master comes back to the cluster as a replica of the new one, at the same path.
You need it for planned work: OS update, disk replacement, moving the load to another server. First the check, then the start:
hqbirdrcm switchover -service shop -check # check only, changes nothing hqbirdrcm switchover -service shop -to db2 # move the master to db2
The command runs the operation to the end and prints each step. Exit code 0 means success. The Switchover button on the service page in RCM does the same: first the check, then the confirmation, then the steps of the operation on the screen.
Applications
Hosts and service
What RCM checks before the start
- The service is in the
okstate, the master is known. - The target replica is in the
IN_SYNCstate. - All four nodes of the two hosts answer.
- The target replica is not paused because of the license.
- No database copy or promotion runs on these nodes.
If something is wrong, RCM refuses and gives the reason as a code. Up to this point, nothing has changed.
If something goes wrong
- Before the point of no return. An error, a timeout or a cancel brings the old master back online. The service stays
okon the old host. If the old master does not come back online, the service getsfailed: bring the database online withgfix -online normaland runresume. - After the point of no return. You cannot cancel. An error sets the service to
failed. - Error during rejoin. The new master works, there is no replica:
degraded_no_replica. Runhqbirdrcm rejoin -service shop.
hqbirdrcm operations show -id <id> hqbirdrcm operations cancel -id <id>
In the browser, this is the Operations page and the Cancel button on the service page.
- Stopping writesThe old master goes to full shutdown. The node waits until the connections end: 120 seconds by default, 900 at most. The switch
-force Nbreaks the connections after N seconds. - Catching upEvery second, RCM asks the replica if it has applied the last segment. The default limit is 300 seconds.
- One Firebird restartOn the new master, without waiting for the window. During rejoin, the old host's Firebird restarts only if the replica node needs it.
- Rejoin is a database copyThe new master copies the database to the old host through nbackup. For a large database this takes long, so the command waits for the operation up to 2 hours.
- RCM restartedEach step is written to disk before the node call. After a restart, RCM continues the operation from the current step.
- Service lockWhile a switchover or a rejoin runs, RCM refuses other changes on these nodes: settings, Firebird restart, copy, shipping pause.
Connections to the old master close at the stop-writes step. The application must connect again. With a router, the connection string stays the same. Without a router, the application goes to the address of the new master: hqbirdrcm where -service shop gives it.
HAProxy · Linux · one connection string
Routers: applications keep the same address
A router runs on the application host and keeps HAProxy pointed at the master of each service. Applications connect to <router host>:<service port>. After a switchover or a failover, the connection string stays the same.
How the router chooses a host
- It gets the service table from RCM: epoch, master host, Firebird addresses.
- Every 2 seconds it asks the master node: “are you the master of this epoch, and is the database online?”
- Answer “yes”: the host accepts connections.
- Answer “no”: no new connections, open connections stay.
- New epoch: the sessions of the old master close at once.
If RCM is not available, the router works with the last table. The router keeps it on its disk.
How to add a router
A router is a cluster member with the router role. Add it on the Cluster page, like a master or a replica. The fbagent on this host gets a certificate, writes the configuration and registers the service. HAProxy must be installed on the host.
The router_port in the service description sets the service port. You can have several routers: one on each application host.
The Settings → Routers page in RCM shows the routers and their reports: which epoch the router applied and to which host it leads.
- Connections breakWhen the master changes, open connections close. The application must connect again, to the same address.
- Client addressFirebird sees the HAProxy address, not the application address. Access rules by client IP do not work behind a router.
- Linux onlyThe router works on Linux. Database servers can be on Windows and Linux.
- WitnessesRouters tell RCM if they can reach the master's Firebird port. Automatic failover does not turn on without them.
Master host lost · manual or by a rule
Failover: the replica takes the master role
You need failover when the master host does not answer. The replica becomes the master with the segments that it has received. What the master did not send is lost. So the operator must accept the loss explicitly.
hqbirdrcm failover -service shop -check # what will be lost hqbirdrcm failover -service shop -to db2 -accept-data-loss # start
Without the -accept-data-loss switch, the command only checks and shows the loss estimate: the last segment of the master, how many segments the replica received and applied, and how many segments are lost at least.
In the browser, this is the Failover button on the service page. It starts the operation only when the operator has checked the data loss box and typed the service name.
- 1Checkthe master does not answer, the replica has a usable copy
- 2Catching upthe replica applies all that it received; limit 60 s
- 3Promotionpoint of no return: new GUID, Firebird restart
- 4New epochthe replica is the master; the old master waits to be closed
- The master still answersRCM refuses:
master_reachable. Run a switchover, or first stop the master node. - Lagging replicaThe
LAGGINGstate is accepted. A replica that needs a new copy is not suitable. - Several replicasBy default, RCM takes the one that applied more segments, then the one with the higher priority.
- After failoverThe service is in the
degraded_no_replicastate: the master works, there is no replica. There is no rejoin until the old host is up again. - Service in the failed stateA manual failover works for it too. This is the way out when the master's Firebird hangs and you cannot restart it quickly.
- Excluded tablesRCM takes their list from the replica or from the last statistics of the old master. If there is no list, set the tables on the publication page of the new master.
- Catch-up limitThe
-apply-timeoutswitch, 60 seconds by default, 3600 at most.
Automatic failover optional
RCM can start a failover itself. This is off by default. You turn on the rule for each service separately: on the service page in the browser or with a command.
hqbirdrcm policy -service shop # show the rule
hqbirdrcm policy -service shop -auto-failover on -max-data-loss 30
RCM checks the conditions every 10 seconds and starts a failover only when all of them are true.
| Condition | Why |
|---|---|
| The master node is silent for 90 seconds | The master does not send statistics. |
| A direct call from RCM to the master node fails (5 seconds) | This is not only late statistics. |
| More than half of the routers cannot reach the master's Firebird port | Applications cannot connect either. |
| The replica node has not seen the master for 90 seconds | Third witness. |
| The replica lag is 30 seconds or less | Data loss limit. |
| One hour has passed since the last automatic failover | The master does not jump between hosts. |
| RCM has been running for more than 90 seconds | After a restart, RCM has no fresh data. |
Service is ok, no copy or promotion runs on the nodes | No conflict with running work. |
- Routers are neededThe rule needs both routers and a service port. If one of them is missing, the rule does not turn on:
no_witnesses. Place the routers so that most of them are not on the master host. - OnceAfter an automatic failover, the rule turns itself off. Only the operator turns it on again.
- Why it did not startRCM keeps the reason for waiting together with the service rule, and writes each new reason to its log once.
- LogThe operation runs as
system:autofailover. The first entry says what the witnesses saw.
The 30-second limit covers only the queue that the replica received and has not applied yet. Segments that the master wrote but did not send are not in it. The operation report shows their number.
Fence · rejoin · hung master · resume
Rejoin and recovery
After a failover, the cluster has two files that were the master. You must close the old one so that it does not accept writes, and bring it back as a replica. RCM does the first itself, the second on an operator command.
Closing the old master (fence)
RCM tries to close the old master every 10 seconds. When its node answers, it gets the “closed” role and stops sending segments. Each fence is written to the audit log.
- Mode
route(default). The old master database stays online. Routers no longer use it. - Mode
shutdown. RCM first stops the database. Connections close after 5 seconds.
hqbirdrcm policy -service shop -fence-mode shutdown
Bringing back the old master (rejoin)
When the old host works again, start the rejoin. RCM first closes the old master, if this is not done yet. Then the new master copies its database to the old host, at the same path.
hqbirdrcm rejoin -service shop
The old file is not deleted. It stays next to the new one as <name>.pre-reinit-<time>.fdb. This file and the old master's archive hold changes that the new master does not have.
In route mode, applications that connect to the old host directly, not through a router, can still write to the old database. These changes do not reach the new master. If some applications work without a router, turn on shutdown mode.
Hung master
Firebird can hang so that the port is open, but you cannot connect to the database. A port check does not see this. So the node itself connects to the database every minute, with a 10-second limit.
- One minute without an answer: the serious alert
firebird_not_answering. - RCM sets the service to
failedand writes the reason: node, host, time. - Automatic failover does not start in this state.
What to do: save the Firebird thread stacks and firebird.log, restart Firebird on the master host, then run resume. If you cannot restart quickly, stop the master node and start a failover.
Leaving the failed state
hqbirdrcm resume -service shop -check hqbirdrcm resume -service shop
RCM asks the master node directly and checks:
- no operation runs on the service;
- the master node answers;
- its Firebird accepts connections;
- the host is the master of the current epoch, the database is online.
The service goes to ok if a replica on another host follows the master. Otherwise it goes to degraded_no_replica: then run rejoin.
Turn to normal · promote to master
Manual replica promotion: step by step
For a database that is part of a service, use switchover and failover: they do all the steps below themselves. The manual path stays for databases without a service. “Turn to normal” makes the replica a separate working database: for reports, tests or a failure. “Promote to master” makes the replica the new master.
Promotion works for a pair of companion nodes: a replica node and a master node on the same Firebird instance. The database file stays in place; control moves to the companion. Each step is visible in the database row. If a step was interrupted, click the button again: completed steps are not repeated.
Connections
What RCM shows
Why a new GUID
Without it, the new master would write segments under the old master's GUID, and its replicas would refuse them. The node gives the database a new GUID in place, through nbackup, without a Firebird restart. This works on 2.5, 3.0, 4.0 and 5.0.
After a new GUID, the old nbackup chain no longer fits. Make a new level 0 copy.
Manual switchover without a service
- Stop application writes to the old master.
- Wait for
IN_SYNCand an empty queue. - Click “Verify”: the row counts match. This checks only the row counts.
- “Promote to master”, wait for the FINALIZE step.
- Switch the applications to the new master.
- Make a level 0 nbackup copy and connect a new replica.
Manual promotion does not check whether applications write to the old master, and does not bring the old master back as a replica. Stop the writes yourself first. Switchover does both steps for you: it stops the writes and brings the old master back.
Restart · parameters · certificates
Settings and security
Firebird reads replication settings only at startup. So it matters who restarts it and when. The rule is simple: the master's Firebird is never restarted automatically. There is one exception: switchover and failover. There, the restart is part of an operation that the operator started, or that a rule turned on by the operator started.
| Node | Who restarts Firebird |
|---|---|
| Master | Only you. The master node does not restart Firebird by itself. |
| Replica, the same Firebird has master databases | You. The permission in the copy window lets the node only stop Firebird to replace or delete the old replica file. |
| Replica, auto restart not allowed | You. |
| Other replicas | The node, in its restart window. Once after a series of copies, not after each database. |
Replication parameters for many databases
Select databases: RCM groups them by Firebird version and role. For each parameter, choose an action: keep, set, reset to the level above or do not write. You see where the current value comes from: the database, the node or Firebird.
Preview checks the values on the nodes and changes nothing. It also shows who will restart Firebird and how many databases this affects.
- Time windowsA master restart that you requested: 22:00–05:00. Replica: any time. Manual promotion to master restarts both Firebird servers at once, without a window. Switchover restarts one Firebird: on the new master. Full copy speed: 23:00–05:00.
- Segment speed50 MB/s by default, short peak 200 MB. Changes at once, without a restart.
- Moving the replica fileTo another subfolder without a new copy; rollback on error.
- Manually configured replicaYou can take it under management without a new copy. RCM matches the files by GUID.
- Command lineCopy, check, pause, promotion and other RCM commands are also in
hqbirdrcm. Switchover, failover and the service rule are available in three ways: in the browser, with a command and through the API. - Viewer roleAn RCM user with the viewer role sees everything and runs checks. Any change is forbidden to this user.
- 6 languagesRCM interface. Alert instructions are in English.
One document describes the cluster
Members, their roles and master → replica links are set on the Clusters page in HQ Monitor or in RCM. The fbagent on each host gets the description and installs and configures the nodes itself. Without HQCenter, RCM manages one cluster of up to 3 hosts.
mTLS and certificates
All cluster channels are protected by mTLS with a shared CA. The key is created on the member host and never leaves it: only the certificate request goes out. A certificate is valid for 90 days and renews itself 30 days before it expires. A new key and a new CA are issued on an administrator command.
The RCM web interface works over HTTPS on port 7444. The agent opens this port in the firewall when RCM is turned on on the host. Login is with a user name and password; you must change the first password. It is in the rcm-initial-password file on the RCM host and is not shown on screen. After the password change, the agent deletes this file. The login page shows the cluster CA hash: compare it with the “CA hash” line in the setup summary on the RCM host. Each change and login is written to the audit log.
Commands · timeouts · ports · refusal codes
Reference
Commands
| Task | Command |
|---|---|
| Turn on RCM on a host | fbagent --cluster-init <id> |
| Open or close the pairing window | fbagent --cluster-pairing on|off |
| Link hosts | hqbirdrcm cluster link -hosts db1,db2 -master db1 |
| Token for a host without the pairing window | hqbirdrcm cluster join-token -note db2 |
| Leave the cluster | fbagent --cluster-leave |
| Describe a service | hqbirdrcm services put -id shop -file shop.json |
| Where the master is | hqbirdrcm where -service shop |
| Planned move of the master | hqbirdrcm switchover -service shop [-to db2] [-check] |
| Emergency move | hqbirdrcm failover -service shop -accept-data-loss |
| Bring the old master back as a replica | hqbirdrcm rejoin -service shop |
| Leave the failed state | hqbirdrcm resume -service shop [-check] |
| Automatic failover rule | hqbirdrcm policy -service shop -auto-failover on|off |
| Progress and cancel of an operation | hqbirdrcm operations show|cancel -id <id> |
Timeouts and intervals
| What | Default | How to change |
|---|---|---|
| Switchover: wait for connections to end | 120 s, 900 s at most | -quiesce-timeout |
| Switchover: replica applies the last segment | 300 s | -apply-timeout |
| Switchover: command waits for the end of the operation | 2 hours | -timeout |
| Failover: replica applies what it received | 60 s, 3600 s at most | -apply-timeout |
| Automatic failover: master is silent | 90 s | -failover-delay |
| Automatic failover: lag limit | 30 s | -max-data-loss |
| Automatic failover: pause between two | 1 hour | -min-interval |
| Check of failover conditions and of old master fence | every 10 s | cannot be changed |
| Hung Firebird: connection probe | once a minute, limit 10 s | cannot be changed |
| Router: master node poll | every 2 s | cannot be changed |
| Pairing window, join token | 24 hours | window: number of hours in the request |
| Link hosts: agent certificate, node start | up to 10 minutes, up to 20 minutes | cannot be changed |
Ports
| Port | Purpose |
|---|---|
7443 | RCM: nodes, agents and routers, mTLS. |
7444 | RCM: web interface and operator commands, HTTPS. |
7450–7459 | Agent pairing window: 7450 + slot. |
7051–7060 | First node of the agent: 7051 + slot. |
7061–7070 | Second node of the agent: 7061 + slot. |
router_port | Service port on the router, for example 3051. |
Refusal codes
| Code | Meaning |
|---|---|
not_in_sync | The target replica lags behind: switchover does not start. |
busy | A database copy or promotion runs on the nodes. |
service_busy | An operation already runs on the service. |
master_reachable | The master answers: failover is not needed. |
replica_unusable | The replica has no usable database copy. |
data_loss_not_accepted | Failover without the -accept-data-loss switch. |
past_no_return | Cancel after the point of no return. |
no_witnesses | Automatic failover without routers. |
node_port_clash | Another member of the host uses the node port. |
seats_exceeded | The cluster already has 3 hosts. |
The main points in short
Frequent questions
What is the difference between switchover and failover?
Switchover is planned: both hosts work, no data is lost, the old master comes back as a replica by itself. Failover is an emergency: the master host is lost, what the master did not send is lost, and you bring the old master back with a separate command.
What does the application see during a switchover?
Connections to the old master close when RCM stops writes. Until the replica becomes the master, there is nowhere to write. After the new epoch, the application connects again: to the same router address or to the address of the new master.
How long does a switchover take?
The write pause has three parts: waiting for connections to end (up to 120 seconds by default), catching up on the last segment, and one Firebird restart on the new master. The rejoin of the old master runs after this, in the background. Its time is the time of the database copy.
Can I work without a router?
Yes. Switchover and manual failover work without routers. The application then gets the master address from RCM itself. Automatic failover does not turn on without routers: routers are its witnesses.
How much data can an automatic failover lose?
The rule does not start if the replica lags by more than 30 seconds. But segments that the master wrote and did not send are lost. The operation report shows their number. The old database file is kept: these changes stay in it and in the old master's archive.
The service is in the failed state. What do I do?
See the reason on the Services page. If the master's Firebird hung, restart it. Then hqbirdrcm resume -service <id> -check shows what blocks the service, and resume without the switch brings the service back to work.
How much space does the rejoin of the old master need?
Rejoin is a new database copy. The same rules apply as for any copy: 105 % of the database size. After a failover, the old file stays next to the new one, so the old host needs space for both files.
Does it work on Windows?
Nodes and RCM work on Windows and Linux. The router works only on Linux.