> Note: GitLab HA requires Enterprise Edition Premium
> Note: GitLab HA requires a Enterprise Edition Premium license
**Warning**
**Warning**
This functionality should be considered beta, use with caution.
This functionality should be considered beta, use with caution.
**Warning**
**Warning**
## Overview
## Overview
GitLab supports multiple options for its database backend
GitLab supports multiple options for its database backend
* Using the Omnibus GitLab package to configure PG in HA setup (EEP only). This document contains directions for EEP users.
* Using the Omnibus GitLab package to configure PG in HA setup (EEP only). This document contains directions for EEP users.
* Using GitLab with an [externally managed PostgreSQL service](../external_database.md). This could be a cloud provider, or your own service.
* Using GitLab with an [externally managed PostgreSQL service](../external_database.md). This could be a cloud provider, or your own service.
...
@@ -18,6 +19,7 @@ or for a non-HA option
...
@@ -18,6 +19,7 @@ or for a non-HA option
### Preparation
### Preparation
The recommended configuration for a PostgreSQL HA setup requires:
The recommended configuration for a PostgreSQL HA setup requires:
* A minimum of two database nodes
* A minimum of two database nodes
* Each node will run the following services
* Each node will run the following services
...
@@ -26,14 +28,23 @@ The recommended configuration for a PostgreSQL HA setup requires:
...
@@ -26,14 +28,23 @@ The recommended configuration for a PostgreSQL HA setup requires:
* At least one separate node for running the `pgbouncer` service.
* At least one separate node for running the `pgbouncer` service.
* This is recommended to be on the same node as your `gitlab-rails` service(s)
* This is recommended to be on the same node as your `gitlab-rails` service(s)
#### Needed information
#### Required information
* Network information for all nodes, IP addresses, subnet masks, and DNS names if appropriate.
* Password and it's hash for pgbouncer to authenticate with the database.
* Network information for all nodes
* The hash can be generated with the following command:
* DNS names -- By default, `repmgr` and `pgbouncer` use DNS to locate nodes
```
* IP address -- PostgreSQL does not listen on any network interface by default. It needs to know which IP address to listen on in order to use the network interface. It can be set to `0.0.0.0` to listen on all interfaces.
$ echo -n 'PASSWORD+USERNAME' | md5sum
* Network Address -- PostgreSQL access is controlled based on the network source. This can be in subnet (i.e. 192.168.0.0/255.255.255.0) or CIDR (i.e. 192.168.0.0/24) form.
```
* Username for `pgbouncer` service
The default username is pgbouncer
* Default username is `pgbouncer`. In the rest of the documentation we will refer to this username as `PGBOUNCER_USERNAME`
* Password for `pgbouncer` service. In the rest of the documentation we will refer to this password as `PGBOUNCER_PASSWORD`
* Password hash for `pgbouncer` service
* This should be generated from `pgbouncer` username and password pair
* Generate the hash with:
``
$ echo -n 'PASSWORD+USERNAME' | md5sum
``
* In the rest of the documentation we will refer to this has as `PGBOUNCER_PASSWORD_HASH`
* The number of nodes in the cluster. When configuring PostgreSQL, we will set `max_wal_senders` to one more than this number. This is used to prevent replication from using up all of the available database connections.
### Installation
### Installation
...
@@ -43,7 +54,7 @@ The recommended configuration for a PostgreSQL HA setup requires:
...
@@ -43,7 +54,7 @@ The recommended configuration for a PostgreSQL HA setup requires:
steps on the download page.
steps on the download page.
#### On each database node
#### On each database node
1.Create/edit `/etc/gitlab/gitlab.rb` and use the following configuration.
1.Edit `/etc/gitlab/gitlab.rb` and use the following configuration.
If there is a directive listed below that you do not see in the configuration, be sure to add it.
If there is a directive listed below that you do not see in the configuration, be sure to add it.
```ruby
```ruby
# Disable all components except PostgreSQL
# Disable all components except PostgreSQL
...
@@ -67,8 +78,8 @@ The recommended configuration for a PostgreSQL HA setup requires:
...
@@ -67,8 +78,8 @@ The recommended configuration for a PostgreSQL HA setup requires:
postgresql['shared_preload_libraries']='repmgr_funcs'# If this attribute is already defined, append the new value as a comma separated list
postgresql['shared_preload_libraries']='repmgr_funcs'# If this attribute is already defined, append the new value as a comma separated list
# pgbouncer user
# pgbouncer user
postgresql['pgbouncer_user']='pgbouncer'
postgresql['pgbouncer_user']='PGBOUNCER_USER'
postgresql['pgbouncer_user_password']='HASH'# This is the hash generated in the preparation section
postgresql['pgbouncer_user_password']='PGBOUNCER_PASSWORD_HASH'# This is the hash generated in the preparation section
# repmgr configuration
# repmgr configuration
repmgr['enable']=true
repmgr['enable']=true
...
@@ -138,8 +149,8 @@ pgbouncer['enable'] = true
...
@@ -138,8 +149,8 @@ pgbouncer['enable'] = true
pgbouncer['databases']={
pgbouncer['databases']={
gitlabhq_production: {
gitlabhq_production: {
host: '172.21.0.2',
host: '172.21.0.2',
user: 'pgbouncer',
user: 'PGBOUNCER_USER',
password: 'HASH'# This should be the hash from the preparation section
password: 'PGBOUNCER_PASSWORD_HASH'# This should be the hash from the preparation section