As of GitLab 13.3, PostgreSQL 11.7 and 12.3 are both shipped with Omnibus.
During a package upgrade, the database is not automatically upgraded
to PostgreSQL 12. If you want to upgrade to PostgreSQL 12, you must do it manually:
During a package upgrade, the database isn't upgraded to PostgreSQL 12. If you
want to upgrade to PostgreSQL 12, you must do it manually:
```shell
sudo gitlab-ctl pg-upgrade -V 12
```
PostgreSQL 12 is not supported on Geo deployments and is [planned](https://gitlab.com/groups/gitlab-org/-/epics/2374)
PostgreSQL 12 isn't supported on Geo deployments and is [planned](https://gitlab.com/groups/gitlab-org/-/epics/2374)
for the future releases. The [fault-tolerant PostgreSQL 12 deployment](https://docs.gitlab.com/ee/administration/postgresql/replication_and_failover.html)
is only possible using Patroni. Repmgr is no longer supported for PostgreSQL 12.
is possible only by using Patroni. Repmgr is no longer supported for
PostgreSQL 12.
#### GitLab 12.10 and later
The default PostgreSQL version is set to 11.x, and an automatic upgrade of the
database is done on package upgrades for installs that are not using repmgr or Geo.
The default PostgreSQL version is set to 11.x, and an upgrade of the database is
done on package upgrades for installs that are not using repmgr or Geo.
The automatic upgrade is skipped in any of the following cases:
The upgrade is skipped in any of the following cases:
-you are running the database in high availability using repmgr.
-your database nodes are part of GitLab Geo configuration.
-you have specifically [opted out](#opt-out-of-automatic-postgresql-upgrades).
-You're running the database in high availability using repmgr.
-Your database nodes are part of GitLab Geo configuration.
-You have specifically [opted out](#opt-out-of-automatic-postgresql-upgrades).
To upgrade PostgreSQL on installs with HA or Geo, see [Packaged PostgreSQL deployed in an HA/Geo Cluster](#packaged-postgresql-deployed-in-an-hageo-cluster).
Loading
Loading
@@ -410,10 +420,10 @@ To upgrade PostgreSQL on installs with HA or Geo, see [Packaged PostgreSQL deplo
**As of GitLab 12.8, PostgreSQL 9.6.17, 10.12, and 11.7 are shipped with
Omnibus GitLab.**
Automatically during package upgrades (unless opted out) and when user manually
runs `gitlab-ctl pg-upgrade`, `omnibus-gitlab` will still be attempting to
upgrade the database only to 10.x, while 11.x will be available for users to
manually upgrade to. To manually update PostgreSQL to version 11.x , the `pg-upgrade`
During package upgrades (unless opted out) and when user manually runs
`gitlab-ctl pg-upgrade`, `omnibus-gitlab` will still be attempting to upgrade
the database only to 10.x, while 11.x will be available for users to manually
upgrade to. To manually update PostgreSQL to version 11.x , the `pg-upgrade`
command has to be passed with a version argument (`-V` or `--target-version`):
## Using a non-packaged PostgreSQL database management server
By default, GitLab is configured to use the PostgreSQL server that is included
By default, GitLab is configured to use the PostgreSQL server that's included
in Omnibus GitLab. You can also reconfigure it to use an external instance of
PostgreSQL.
Loading
Loading
@@ -516,8 +526,9 @@ sure that PostgreSQL is set up according to the [database requirements document]
### UNIX socket configuration for non-packaged PostgreSQL
If you want to use your system's PostgreSQL server (installed on the same machine as GitLab)
instead of the one bundled with GitLab, you can do so by using a UNIX socket:
If you want to use your system's PostgreSQL server (installed on the same system
as GitLab) instead of the one bundled with GitLab, you can do so by using a UNIX
socket:
1. Edit `/etc/gitlab/gitlab.rb`:
Loading
Loading
@@ -556,14 +567,14 @@ instead of the one bundled with GitLab, you can do so by using a UNIX socket:
gitlab-ctl restart postgresql
```
If PostgreSQL fails to start, check the logs
(e.g. `/var/log/gitlab/postgresql/current`) for more details.
If PostgreSQL fails to start, check the logs (for example,
`/var/log/gitlab/postgresql/current`) for more details.
#### Require SSL and verify server certificate against CA bundle
PostgreSQL can be configured to require SSL and verify the server certificate
against a CA bundle in order to prevent spoofing.
The CA bundle that is specified in `gitlab_rails['db_sslrootcert']` must contain
against a CA bundle to prevent spoofing.
The CA bundle that's specified in `gitlab_rails['db_sslrootcert']` must contain
both the root and intermediate certificates.
1. Add the following to `/etc/gitlab/gitlab.rb`:
Loading
Loading
@@ -587,8 +598,8 @@ both the root and intermediate certificates.
gitlab-ctl restart postgresql
```
If PostgreSQL fails to start, check the logs
(e.g. `/var/log/gitlab/postgresql/current`) for more details.
If PostgreSQL fails to start, check the logs (for example,
`/var/log/gitlab/postgresql/current`) for more details.
### Backup and restore a non-packaged PostgreSQL database
Loading
Loading
@@ -634,28 +645,39 @@ correct executables by running both the [backup](https://docs.gitlab.com/ee/rake
Before proceeding with the upgrade, note the following:
- Before upgrading, check the [GitLab and PostgreSQL version compatibility table](../package-information/postgresql_versions.md) to determine your upgrade path.
When using GitLab backup/restore you **must** keep the same version of GitLab so upgrade PostgreSQL first then GitLab.
- The [backup and restore Rake task](https://docs.gitlab.com/ee/raketasks/backup_restore.html#create-a-backup-of-the-gitlab-system) can be used to back up and
restore the database to a later version of PostgreSQL.
- If configuring a version number whose binaries are unavailable on the file system, GitLab/Rails will use the default database's version binaries (default as per [GitLab and PostgreSQL version compatibility table](../package-information/postgresql_versions.md)).
- If you're using Amazon RDS and are seeing extremely high (near 100%) CPU utilization following a major version upgrade (i.e. from `10.x` to `11.x`), running an `ANALYZE VERBOSE;` query may be necessary to recreate query plans and reduce CPU utilization on the database server(s). [Amazon recommends this](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.PostgreSQL.html) as part of a major version upgrade.
- Before upgrading, review the [GitLab and PostgreSQL version compatibility table](../package-information/postgresql_versions.md)
to determine your upgrade path. When using GitLab backup or restore, you
_must_ keep the same version of GitLab; first upgrade PostgreSQL, and then GitLab.
- The [backup and restore Rake task](https://docs.gitlab.com/ee/raketasks/backup_restore.html#create-a-backup-of-the-gitlab-system)
can be used to back up and restore the database to a later version of PostgreSQL.
- If configuring a version number whose binaries are unavailable on the file
system, GitLab/Rails uses the default database's version binaries (default as
per [GitLab and PostgreSQL version compatibility table](../package-information/postgresql_versions.md)).
- If you're using Amazon RDS and are seeing extremely high (near 100%) CPU
utilization following a major version upgrade (for example, from `10.x` to
`11.x`), running an `ANALYZE VERBOSE;` query may be necessary to recreate query
plans and reduce CPU utilization on the database server(s).
The following example demonstrates upgrading from a database host running PostgreSQL 10 to another database host running PostgreSQL 11 and incurs downtime:
1. Spin up a new PostgreSQL 11 database server that is set up according to the [database requirements](https://docs.gitlab.com/ee/install/requirements.html#database).
1. Spin up a new PostgreSQL 11 database server that's set up according to the [database requirements](https://docs.gitlab.com/ee/install/requirements.html#database).
1.You should ensure that the compatible versions of `pg_dump` and `pg_restore`
are being used on the GitLab Rails instance. To amend GitLab configuration, edit`/etc/gitlab/gitlab.rb`
and specify the value of `postgresql['version']`:
1.Ensure that the compatible versions of `pg_dump` and `pg_restore` are being
used on the GitLab Rails instance. To amend GitLab configuration, edit
`/etc/gitlab/gitlab.rb`and specify the value of `postgresql['version']`:
```ruby
postgresql['version'] = 11
```
NOTE: **Note:**
Connecting to PostgreSQL 12 (alongside with amending `postgresql['version'] = 12`) will currently break the [GitLab Backup/Restore](https://docs.gitlab.com/ee/raketasks/backup_restore.html) functionality unless the v12 client binaries are available on the file system. More on this topic can be found under [backup and restore a non-packaged database](#backup-and-restore-a-non-packaged-postgresql-database).
This problem with missing 12 client binaries is partially resolved in GitLab 13.3 where PostgreSQL 12 is shipped with Omnibus GitLab, and it's being tackled in the [support for PostgreSQL 12](https://gitlab.com/groups/gitlab-org/-/epics/2374) epic.
Connecting to PostgreSQL 12 (alongside with amending `postgresql['version'] = 12`)
breaks the [GitLab Backup/Restore](https://docs.gitlab.com/ee/raketasks/backup_restore.html) functionality unless the v12 client binaries are available on the file system. More on this topic can be found under [backup and restore a non-packaged database](#backup-and-restore-a-non-packaged-postgresql-database).
This problem with missing 12 client binaries is partially resolved in GitLab 13.3,
where PostgreSQL 12 is shipped with Omnibus GitLab, and it's being tackled in
the [support for PostgreSQL 12](https://gitlab.com/groups/gitlab-org/-/epics/2374) epic.
1. Reconfigure GitLab:
Loading
Loading
@@ -669,7 +691,8 @@ The following example demonstrates upgrading from a database host running Postgr
sudo gitlab-ctl stop
```
1. Run the backup Rake task using the SKIP options to back up only the database. Make a note of the backup file name, you'll use it later to restore:
1. Run the backup Rake task using the SKIP options to back up only the database.
Make a note of the backup file name; you'll use it later to restore.
@@ -677,8 +700,8 @@ The following example demonstrates upgrading from a database host running Postgr
1. Shutdown the PostgreSQL 10 database host.
1. Edit `/etc/gitlab/gitlab.rb` and update the `gitlab_rails['db_host']` setting to point to
the PostgreSQL database 11 host.
1. Edit `/etc/gitlab/gitlab.rb` and update the `gitlab_rails['db_host']` setting
to point to the PostgreSQL database 11 host.
1. Reconfigure GitLab:
Loading
Loading
@@ -686,7 +709,8 @@ the PostgreSQL database 11 host.
sudo gitlab-ctl reconfigure
```
1. Restore the database using the database backup file created earlier, and make sure to answer **no** when asked "This task will now rebuild the authorized_keys file":
1. Restore the database using the database backup file created earlier, and be
sure to answer **no** when asked "This task will now rebuild the authorized_keys file":
@@ -701,12 +725,10 @@ the PostgreSQL database 11 host.
### Seed the database (fresh installs only)
CAUTION: **Caution:**
This is a destructive command; do not run it on an existing database!
---
This is a destructive command; do not run it on an existing database.
Omnibus GitLab will not automatically seed your external database. Run the
following command to import the schema and create the first administration user:
Omnibus GitLab will not seed your external database. Run the following command
to import the schema and create the first administration user:
```shell
# Remove 'sudo' if you are the 'git' user
Loading
Loading
@@ -832,13 +854,13 @@ or not specifying the setting at all disables the timeout.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/249662) in GitLab 13.5.
CAUTION: **Warning:**
This is an experimental feature that is not enabled by default.
This is an experimental feature that isn't enabled by default.
Recreates database indexes in the background (called "reindexing"). This can
be used to remove bloated space that has accumulated in indexes and helps to maintain healthy and
efficient indexes.
The reindexing task can be started regularly through a cronjob. In order to configure the cronjob,
The reindexing task can be started regularly through a cronjob. To configure the cronjob,
`gitlab_rails['database_reindexing']['enable']` should be set to `true`.
In a multi-node environment, this feature should only be enabled on an application host.
Loading
Loading
@@ -945,7 +967,7 @@ additional considerations when upgrading GitLab and/or when upgrading
PostgreSQL described below.
CAUTION: **Caution:**
If you are running a Geo installation using PostgreSQL 9.6.x, please upgrade to GitLab 12.4 or newer. Older versions were affected [by an issue](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4692) that could cause automatic upgrades of the PostgreSQL database to fail on the secondary. See [Disabling automatic PostgreSQL upgrades](#disabling-automatic-postgresql-upgrades) to workaround the issue. This issue is now fixed.
If you are running a Geo installation using PostgreSQL 9.6.x, upgrade to GitLab 12.4 or newer. Older versions were affected [by an issue](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4692) that could cause upgrades of the PostgreSQL database to fail on the secondary. See [Disabling automatic PostgreSQL upgrades](#disabling-automatic-postgresql-upgrades) to workaround the issue. This issue is now fixed.
#### Caveats when upgrading PostgreSQL with Geo
Loading
Loading
@@ -964,14 +986,15 @@ for more.
#### Disabling automatic PostgreSQL upgrades
From GitLab 12.1 through GitLab 12.9, GitLab package upgrades automatically try
to upgrade PostgreSQL to version 10.x. In GitLab 12.10+, upgrades of PostgreSQL do not happen automatically when using Geo.
From GitLab 12.1 through GitLab 12.9, GitLab package upgrades try to upgrade
PostgreSQL to version 10.x. In GitLab 12.10 and later, upgrades of PostgreSQL
don't happen in an unattended manner when using Geo.
Before upgrading to GitLab 12.1 through GitLab 12.9, we strongly recommend
disabling automatic upgrades of PostgreSQL and manually upgrading PostgreSQL
disabling unattended upgrades of PostgreSQL and manually upgrading PostgreSQL
separately from upgrading the GitLab package to avoid any unintended downtime.
You can disable automatic upgrades of PostgreSQL by running the following on
You can disable unattended upgrades of PostgreSQL by running the following on
all nodes running `postgresql` or `geo-postgresql`:
```shell
Loading
Loading
@@ -990,7 +1013,7 @@ replication user's password.
sudo gitlab-psql -qt -c 'select slot_name from pg_replication_slots'
```
If you can't find your `slot_name` here, or there is no output returned, your Geo secondaries may not be healthy. In that case, make sure that [the secondaries are healthy and replication is working](https://docs.gitlab.com/ee/administration/geo/replication/troubleshooting.html#check-the-health-of-the-secondary-node).
If you can't find your `slot_name` here, or there is no output returned, your Geo secondaries may not be healthy. In that case, make sure the [secondaries are healthy and replication is working](https://docs.gitlab.com/ee/administration/geo/replication/troubleshooting.html#check-the-health-of-the-secondary-node).
1. Gather the replication user's password. It was set while setting up Geo in
[Step 1. Configure the primary server](https://docs.gitlab.com/ee/administration/geo/replication/database.html#step-1-configure-the-primary-server).