Commit d15e704e authored by Stan Hu's avatar Stan Hu

Merge branch 'jramsay-4116-geo-trust-docs' into 'master'

Simplify db IP address documentation

Closes #4116

See merge request gitlab-org/gitlab-ee!3520
parents 2b416da2 28778a62
...@@ -26,7 +26,7 @@ connect to secondary database servers (which are read-only too). ...@@ -26,7 +26,7 @@ connect to secondary database servers (which are read-only too).
In many databases documentation you will see "primary" being referenced as "master" In many databases documentation you will see "primary" being referenced as "master"
and "secondary" as either "slave" or "standby" server (read-only). and "secondary" as either "slave" or "standby" server (read-only).
Since GitLab 9.4: We recommend using [PostgreSQL replication We recommend using [PostgreSQL replication
slots](https://medium.com/@tk512/replication-slots-in-postgresql-b4b03d277c75) slots](https://medium.com/@tk512/replication-slots-in-postgresql-b4b03d277c75)
to ensure the primary retains all the data necessary for the secondaries to to ensure the primary retains all the data necessary for the secondaries to
recover. See below for more details. recover. See below for more details.
...@@ -80,6 +80,7 @@ will not be able to perform all necessary configuration steps. Refer to ...@@ -80,6 +80,7 @@ will not be able to perform all necessary configuration steps. Refer to
else. else.
1. Set up TLS support for the PostgreSQL primary server 1. Set up TLS support for the PostgreSQL primary server
> **Warning**: Only skip this step if you **know** that PostgreSQL traffic > **Warning**: Only skip this step if you **know** that PostgreSQL traffic
> between the primary and secondary will be secured through some other > between the primary and secondary will be secured through some other
> means, e.g., a known-safe physical network path or a site-to-site VPN that > means, e.g., a known-safe physical network path or a site-to-site VPN that
...@@ -146,81 +147,85 @@ will not be able to perform all necessary configuration steps. Refer to ...@@ -146,81 +147,85 @@ will not be able to perform all necessary configuration steps. Refer to
postgresql['ssl'] = 'on' postgresql['ssl'] = 'on'
``` ```
1. Configure PostgreSQL to listen on an external network interface 1. Configure PostgreSQL to listen on network interfaces
Edit `/etc/gitlab/gitlab.rb` and add the following. Note that GitLab 9.1 added For security reasons, PostgreSQL does not listen on any network interfaces
the `geo_primary_role` configuration variable: by default. However, GitLab Geo requires the secondary to be able to
connect to the primary's database. For this reason, we need the address of
each node.
```ruby If you are using a cloud provider, you can lookup the addresses for each
geo_primary_role['enable'] = true Geo node through their management console. A table of terminology is
postgresql['listen_address'] = '1.2.3.4' provided below because terminology varies between vendors.
postgresql['trust_auth_cidr_addresses'] = ['127.0.0.1/32','1.2.3.4/32']
postgresql['md5_auth_cidr_addresses'] = ['5.6.7.8/32']
# New for 9.4: Set this to be the number of Geo secondary nodes you have
postgresql['max_replication_slots'] = 1
# postgresql['max_wal_senders'] = 10
# postgresql['wal_keep_segments'] = 10
```
For external PostgreSQL instances, [see additional instructions][external postgresql]. | GitLab Terminology | Amazon Web Services | Google Cloud Platform |
|-----|-----|-----|-----|
| Interface address | Private address | Internal address |
| Public address | Public address | External address |
Where `1.2.3.4` is the IP address of the primary server, and `5.6.7.8` To lookup the address of a Geo node, on the Geo node execute:
is the IP address of the secondary one.
For security reasons, PostgreSQL by default only listens on the local ```bash
interface (e.g. 127.0.0.1). However, GitLab Geo needs to communicate # Interface address
between the primary and secondary nodes over a common network, such as a ip route get 255.255.255.255 | awk '{print $NF; exit}'
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 # Public address
with the interface corresponding to the given IP. See [the PostgreSQL curl ipinfo.io/ip
documentation](https://www.postgresql.org/docs/9.6/static/runtime-config-connection.html) ```
for more details.
Note that if you are running GitLab Geo with a cloud provider (e.g. Amazon In most cases, the following addresses will be used to configure GitLab
Web Services), the internal interface IP (as provided by `ifconfig`) may Geo:
be different from the public IP address. For example, suppose you have a
nodes with the following configuration:
|Node Type|Internal IP|External IP| | Configuration | Address |
|---------|-----------|-----------| |-----|-----|
|Primary|10.1.5.3|54.193.124.100| | `postgresql['listen_address']` | Primary's interface address |
|Secondary|10.1.10.5|54.193.100.155| | `postgresql['trust_auth_cidr_addresses']` | Primary's interface address |
| `postgresql['md5_auth_cidr_addresses']` | Secondary's public addresses |
If you are running two nodes in different cloud availability zones, you The `listen_address` option opens PostgreSQL up to network connections
may need to double check that the nodes can communicate over the internal with the interface corresponding to the given address. See [the PostgreSQL
IP addresses. For example, servers on Amazon Web Services in the same documentation](https://www.postgresql.org/docs/9.6/static/runtime-config-connection.html)
[Virtual Private Cloud (VPC)](https://aws.amazon.com/vpc/) can do for more details.
this. Google Compute Engine also offers an [internal network]
(https://cloud.google.com/compute/docs/networking) that supports
cross-availability zone networking.
For the above example, the following configuration uses the internal IPs Depending on your network configuration, the suggested addresses may not
to replicate the database from the primary to the secondary: be correct. If your primary and secondary connect over a local
area network, or a virtual network connecting availability zones like
Amazon's [VPC](https://aws.amazon.com/vpc/) of Google's [VPC](https://cloud.google.com/vpc/)
you should use the secondary's interface address for `postgresql['md5_auth_cidr_addresses']`.
Edit `/etc/gitlab/gitlab.rb` and add the following, replacing the IP
addresses with addresses appropriate to your network configuration:
```ruby ```ruby
# Example configuration using internal IPs for a cloud configuration
geo_primary_role['enable'] = true geo_primary_role['enable'] = true
postgresql['listen_address'] = '10.1.5.3'
postgresql['trust_auth_cidr_addresses'] = ['127.0.0.1/32','10.1.5.3/32'] # Primary address
postgresql['md5_auth_cidr_addresses'] = ['10.1.10.5/32'] # - replace '1.2.3.4' with the primary interface address
postgresql['max_replication_slots'] = 1 # Number of Geo secondary nodes postgresql['listen_address'] = '1.2.3.4'
postgresql['trust_auth_cidr_addresses'] = ['127.0.0.1/32','1.2.3.4/32']
# Secondary addresses
# - replace '5.6.7.8' with the secondary public address
postgresql['md5_auth_cidr_addresses'] = ['5.6.7.8/32']
# Replication settings
# - set this to be the number of Geo secondary nodes you have
postgresql['max_replication_slots'] = 1
# postgresql['max_wal_senders'] = 10 # postgresql['max_wal_senders'] = 10
# postgresql['wal_keep_segments'] = 10 # postgresql['wal_keep_segments'] = 10
``` ```
If you prefer that your nodes communicate over the public Internet, you For external PostgreSQL instances, [see additional instructions][external postgresql].
may choose the IP addresses from the "External IP" column above.
1. Optional: If you want to add another secondary, the relevant setting would look like: 1. Optional: If you want to add another secondary, the relevant setting would look like:
```ruby ```ruby
postgresql['md5_auth_cidr_addresses'] = ['5.6.7.8/32','11.22.33.44/32'] postgresql['md5_auth_cidr_addresses'] = ['5.6.7.8/32','9.10.11.12/32']
``` ```
You may also want to edit the `wal_keep_segments` and `max_wal_senders` to You may also want to edit the `wal_keep_segments` and `max_wal_senders` to
match your database replication requirements. Consult the [PostgreSQL - Replication documentation](https://www.postgresql.org/docs/9.6/static/runtime-config-replication.html) match your database replication requirements. Consult the [PostgreSQL -
Replication documentation](https://www.postgresql.org/docs/9.6/static/runtime-config-replication.html)
for more information. for more information.
1. Save the file and [reconfigure GitLab][] for the database listen changes to 1. Save the file and [reconfigure GitLab][] for the database listen changes to
...@@ -237,9 +242,9 @@ will not be able to perform all necessary configuration steps. Refer to ...@@ -237,9 +242,9 @@ will not be able to perform all necessary configuration steps. Refer to
[Reconfigure GitLab][reconfigure GitLab] again. It should complete cleanly. [Reconfigure GitLab][reconfigure GitLab] again. It should complete cleanly.
1. New for 9.4: Restart your primary PostgreSQL server to ensure the 1. Restart your primary PostgreSQL server to ensure the replication slot
replication slot changes take effect (`sudo gitlab-ctl restart postgresql` changes take effect (`sudo gitlab-ctl restart postgresql` for
for Omnibus-provided PostgreSQL). Omnibus-provided PostgreSQL).
1. Now that the PostgreSQL server is set up to accept remote connections, run 1. Now that the PostgreSQL server is set up to accept remote connections, run
`netstat -plnt` to make sure that PostgreSQL is listening on port `5432` to `netstat -plnt` to make sure that PostgreSQL is listening on port `5432` to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment