This document describes the minimal steps you have to take in order to replicate your GitLab database into another server. You may have to change some values according to your database setup, how big it is, etc.

The GitLab primary node where the write operations happen will connect to primary database server, and the secondary ones which are read-only will connect to secondary database servers (which are read-only too).

Note: In many databases documentation you will see primary being references as master and secondary as either slave or standby server (read-only).

You are using PostgreSQL 9.2 or later which includes the pg_basebackup tool. If you are using Omnibus it includes the required PostgreSQL version for Geo.

You have a primary server already set up (the GitLab server you are replicating from), running Omnibus' PostgreSQL (or equivalent version), and you have a new secondary server set up on the same OS and PostgreSQL version. If you are using Omnibus, make sure the GitLab version is the same on all nodes.

The IP of the primary server for our examples will be 1.2.3.4, whereas the secondary's IP will be 5.6.7.8.

Where 1.2.3.4 is the public IP address of the primary server, and 5.6.7.8 the public IP address of the secondary one.

For security reasons, PostgreSQL by default only listens on the local interface (e.g. 127.0.0.1). However, GitLab Geo needs to communicate between the primary and secondary nodes over a common network, such as a corporate LAN or the public Internet. For this reason, we need to configure PostgreSQL to listen on more interfaces.

The listen_address option opens PostgreSQL up to external connections with the interface corresponding to the given IP. See the PostgreSQL documentation for more details.

Note that if you are running GitLab Geo with a cloud provider (e.g. Amazon Web Services), the internal interface IP (as provided by ifconfig) may be different from the public IP address. For example, suppose you have a nodes with the following configuration:

Node Type

Internal IP

External IP

Primary

10.1.5.3

54.193.124.100

Secondary

10.1.10.5

54.193.100.155

In this case, for 1.2.3.4 use the internal IP of the primary node: 10.1.5.3. For 5.6.7.8, use the external of the secondary node: 54.193.100.155.

If you want to add another secondary, the relevant setting would look like:

Set the access control on the primary to allow TCP connections using the server's public IP and set the connection from the secondary to require a password. Edit pg_hba.conf (for Debian/Ubuntu that would be /etc/postgresql/9.x/main/pg_hba.conf):

Where 1.2.3.4 is the public IP address of the primary server, and 5.6.7.8 the public IP address of the secondary one. If you want to add another secondary, add one more row like the replication one and change the IP address: