@@ -785,7 +500,7 @@ run: sentinel: (pid 30098) 76832s; run: log: (pid 29704) 76850s
## Configure PostgreSQL
-In this section, you'll be guided through configuring a highly available PostgreSQL
+In this section, you are guided through configuring a highly available PostgreSQL
cluster to be used with GitLab.
### Provide your own PostgreSQL instance
@@ -819,7 +534,7 @@ replication and failover requires:
A local PgBouncer service to be configured on each PostgreSQL node. Note that this is separate from the main PgBouncer cluster that tracks the primary.
-The following IPs will be used as an example:
+The following IPs are used as an example:
- `10.6.0.21`: PostgreSQL primary
- `10.6.0.22`: PostgreSQL secondary 1
@@ -834,8 +549,8 @@ in the second step, do not supply the `EXTERNAL_URL` value.
#### PostgreSQL nodes
1. SSH in to one of the PostgreSQL nodes.
-1. Generate a password hash for the PostgreSQL username/password pair. This assumes you will use the default
- username of `gitlab` (recommended). The command will request a password
+1. Generate a password hash for the PostgreSQL username/password pair. This assumes you use the default
+ username of `gitlab` (recommended). The command requests a password
and confirmation. Use the value that is output by this command in the next
step as the value of `
`:
@@ -843,8 +558,8 @@ in the second step, do not supply the `EXTERNAL_URL` value.
sudo gitlab-ctl pg-password-md5 gitlab
```
-1. Generate a password hash for the PgBouncer username/password pair. This assumes you will use the default
- username of `pgbouncer` (recommended). The command will request a password
+1. Generate a password hash for the PgBouncer username/password pair. This assumes you use the default
+ username of `pgbouncer` (recommended). The command requests a password
and confirmation. Use the value that is output by this command in the next
step as the value of ``:
@@ -852,8 +567,8 @@ in the second step, do not supply the `EXTERNAL_URL` value.
sudo gitlab-ctl pg-password-md5 pgbouncer
```
-1. Generate a password hash for the PostgreSQL replication username/password pair. This assumes you will use the default
- username of `gitlab_replicator` (recommended). The command will request a password
+1. Generate a password hash for the PostgreSQL replication username/password pair. This assumes you use the default
+ username of `gitlab_replicator` (recommended). The command requests a password
and a confirmation. Use the value that is output by this command in the next step
as the value of ``:
@@ -861,8 +576,8 @@ in the second step, do not supply the `EXTERNAL_URL` value.
sudo gitlab-ctl pg-password-md5 gitlab_replicator
```
-1. Generate a password hash for the Consul database username/password pair. This assumes you will use the default
- username of `gitlab-consul` (recommended). The command will request a password
+1. Generate a password hash for the Consul database username/password pair. This assumes you use the default
+ username of `gitlab-consul` (recommended). The command requests a password
and confirmation. Use the value that is output by this command in the next
step as the value of ``:
@@ -935,7 +650,7 @@ in the second step, do not supply the `EXTERNAL_URL` value.
# END user configuration
```
-PostgreSQL, with Patroni managing its failover, will default to use `pg_rewind` by default to handle conflicts.
+PostgreSQL, with Patroni managing its failover, defaults to use `pg_rewind` by default to handle conflicts.
Like most failover handling methods, this has a small chance of leading to data loss.
For more information, see the various [Patroni replication methods](../postgresql/replication_and_failover.md#selecting-the-appropriate-patroni-replication-method).
@@ -992,7 +707,7 @@ NOTE:
PgBouncer is single threaded and doesn't significantly benefit from an increase in CPU cores.
Refer to the [scaling documentation](index.md#scaling-an-environment) for more information.
-The following IPs will be used as an example:
+The following IPs are used as an example:
- `10.6.0.31`: PgBouncer 1
- `10.6.0.32`: PgBouncer 2
@@ -1098,6 +813,198 @@ The following IPs will be used as an example:
+## Configure Redis
+
+Using [Redis](https://redis.io/) in scalable environment is possible using a **Primary** x **Replica**
+topology with a [Redis Sentinel](https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/) service to watch and automatically
+start the failover procedure.
+
+NOTE:
+Redis clusters must each be deployed in an odd number of 3 nodes or more. This is to ensure Redis Sentinel can take votes as part of a quorum. This does not apply when configuring Redis externally, such as a cloud provider service.
+
+NOTE:
+Redis is primarily single threaded and doesn't significantly benefit from an increase in CPU cores.
+Refer to the [scaling documentation](index.md#scaling-an-environment) for more information.
+
+Redis requires authentication if used with Sentinel. See
+[Redis Security](https://redis.io/docs/latest/operate/rc/security/) documentation for more
+information. We recommend using a combination of a Redis password and tight
+firewall rules to secure your Redis service.
+You are highly encouraged to read the [Redis Sentinel](https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/) documentation
+before configuring Redis with GitLab to fully understand the topology and
+architecture.
+
+The requirements for a Redis setup are the following:
+
+1. All Redis nodes must be able to talk to each other and accept incoming
+ connections over Redis (`6379`) and Sentinel (`26379`) ports (unless you
+ change the default ones).
+1. The server that hosts the GitLab application must be able to access the
+ Redis nodes.
+1. Protect the nodes from access from external networks (Internet), using options such as a firewall.
+
+In this section, you'll be guided through configuring two external Redis clusters
+to be used with GitLab. The following IPs will be used as an example:
+
+- `10.6.0.61`: Redis Primary
+- `10.6.0.62`: Redis Replica 1
+- `10.6.0.63`: Redis Replica 2
+
+### Provide your own Redis instance
+
+You can optionally use a [third party external service for the Redis instance](../redis/replication_and_failover_external.md#redis-as-a-managed-service-in-a-cloud-provider) with the following guidance:
+
+- A reputable provider or solution should be used for this. [Google Memorystore](https://cloud.google.com/memorystore/docs/redis/memorystore-for-redis-overview) and [AWS ElastiCache](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/WhatIs.html) are known to work.
+- Redis Cluster mode is specifically not supported, but Redis Standalone with HA is.
+- You must set the [Redis eviction mode](../redis/replication_and_failover_external.md#setting-the-eviction-policy) according to your setup.
+
+For more information, see [Recommended cloud providers and services](index.md#recommended-cloud-providers-and-services).
+
+### Configure the Redis cluster
+
+This is the section where we install and set up the new Redis instances.
+
+Both the primary and replica Redis nodes need the same password defined in
+`redis['password']`. At any time during a failover, the Sentinels can reconfigure
+a node and change its status from primary to replica (and vice versa).
+
+#### Configure the primary Redis node
+
+1. SSH in to the **Primary** Redis server.
+1. [Download and install](https://about.gitlab.com/install/) the Linux
+ package of your choice. Be sure to follow _only_ installation steps 1 and 2
+ on the page, and to select the correct Linux package, with the same version
+ and type (Community or Enterprise editions) as your current install.
+1. Edit `/etc/gitlab/gitlab.rb` and add the contents:
+
+ ```ruby
+ # Specify server roles as 'redis_master_role' with Sentinel and the Consul agent
+ roles ['redis_sentinel_role', 'redis_master_role', 'consul_role']
+
+ # Set IP bind address and Quorum number for Redis Sentinel service
+ sentinel['bind'] = '0.0.0.0'
+ sentinel['quorum'] = 2
+
+ # IP address pointing to a local IP that the other machines can reach to.
+ # You can also set bind to '0.0.0.0' which listen in all interfaces.
+ # If you really need to bind to an external accessible IP, make
+ # sure you add extra firewall rules to prevent unauthorized access.
+ redis['bind'] = '10.6.0.61'
+
+ # Define a port so Redis can listen for TCP requests which will allow other
+ # machines to connect to it.
+ redis['port'] = 6379
+
+ ## Port of primary Redis server for Sentinel, uncomment to change to non default. Defaults
+ ## to `6379`.
+ #redis['master_port'] = 6379
+
+ # Set up password authentication for Redis and replicas (use the same password in all nodes).
+ redis['password'] = 'REDIS_PRIMARY_PASSWORD'
+ redis['master_password'] = 'REDIS_PRIMARY_PASSWORD'
+
+ ## Must be the same in every Redis node
+ redis['master_name'] = 'gitlab-redis'
+
+ ## The IP of this primary Redis node.
+ redis['master_ip'] = '10.6.0.61'
+
+ ## Enable service discovery for Prometheus
+ consul['monitoring_service_discovery'] = true
+
+ ## The IPs of the Consul server nodes
+ ## You can also use FQDNs and intermix them with IPs
+ consul['configuration'] = {
+ retry_join: %w(10.6.0.11 10.6.0.12 10.6.0.13),
+ }
+
+ # Set the network addresses that the exporters will listen on
+ node_exporter['listen_address'] = '0.0.0.0:9100'
+ redis_exporter['listen_address'] = '0.0.0.0:9121'
+
+ # Prevent database migrations from running on upgrade automatically
+ gitlab_rails['auto_migrate'] = false
+ ```
+
+1. Copy the `/etc/gitlab/gitlab-secrets.json` file from the first Linux package node you configured and add or replace
+ the file of the same name on this server. If this is the first Linux package node you are configuring then you can skip this step.
+
+1. [Reconfigure GitLab](../restart_gitlab.md#reconfigure-a-linux-package-installation) for the changes to take effect.
+
+#### Configure the replica Redis nodes
+
+1. SSH in to the **replica** Redis server.
+1. [Download and install](https://about.gitlab.com/install/) the Linux
+ package of your choice. Be sure to follow _only_ installation steps 1 and 2
+ on the page, and to select the correct Linux package, with the same version
+ and type (Community or Enterprise editions) as your current install.
+1. Edit `/etc/gitlab/gitlab.rb` and add the contents:
+
+ ```ruby
+ # Specify server roles as 'redis_sentinel_role' and 'redis_replica_role'
+ roles ['redis_sentinel_role', 'redis_replica_role', 'consul_role']
+
+ # Set IP bind address and Quorum number for Redis Sentinel service
+ sentinel['bind'] = '0.0.0.0'
+ sentinel['quorum'] = 2
+
+ # IP address pointing to a local IP that the other machines can reach to.
+ # You can also set bind to '0.0.0.0' which listen in all interfaces.
+ # If you really need to bind to an external accessible IP, make
+ # sure you add extra firewall rules to prevent unauthorized access.
+ redis['bind'] = '10.6.0.62'
+
+ # Define a port so Redis can listen for TCP requests which will allow other
+ # machines to connect to it.
+ redis['port'] = 6379
+
+ ## Port of primary Redis server for Sentinel, uncomment to change to non default. Defaults
+ ## to `6379`.
+ #redis['master_port'] = 6379
+
+ # The same password for Redis authentication you set up for the primary node.
+ redis['password'] = 'REDIS_PRIMARY_PASSWORD'
+ redis['master_password'] = 'REDIS_PRIMARY_PASSWORD'
+
+ ## Must be the same in every Redis node
+ redis['master_name'] = 'gitlab-redis'
+
+ # The IP of the primary Redis node.
+ redis['master_ip'] = '10.6.0.61'
+
+ ## Enable service discovery for Prometheus
+ consul['monitoring_service_discovery'] = true
+
+ ## The IPs of the Consul server nodes
+ ## You can also use FQDNs and intermix them with IPs
+ consul['configuration'] = {
+ retry_join: %w(10.6.0.11 10.6.0.12 10.6.0.13),
+ }
+
+ # Set the network addresses that the exporters will listen on
+ node_exporter['listen_address'] = '0.0.0.0:9100'
+ redis_exporter['listen_address'] = '0.0.0.0:9121'
+
+ # Prevent database migrations from running on upgrade automatically
+ gitlab_rails['auto_migrate'] = false
+ ```
+
+1. Copy the `/etc/gitlab/gitlab-secrets.json` file from the first Linux package node you configured and add or replace
+ the file of the same name on this server. If this is the first Linux package node you are configuring then you can skip this step.
+
+1. [Reconfigure GitLab](../restart_gitlab.md#reconfigure-a-linux-package-installation) for the changes to take effect.
+1. Go through the steps again for all the other replica nodes, and
+ make sure to set up the IPs correctly.
+
+Advanced [configuration options](https://docs.gitlab.com/omnibus/settings/redis.html)
+are supported and can be added if needed.
+
+