PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/administration/high_availability/database.md

https://gitlab.com/visay/gitlab-ce
Markdown | 122 lines | 90 code | 32 blank | 0 comment | 0 complexity | 4490a90969aaf379f454a9e7075b2e1d MD5 | raw file
  1# Configuring a Database for GitLab HA
  2
  3You can choose to install and manage a database server (PostgreSQL/MySQL)
  4yourself, or you can use GitLab Omnibus packages to help. GitLab recommends
  5PostgreSQL. This is the database that will be installed if you use the
  6Omnibus package to manage your database.
  7
  8## Configure your own database server
  9
 10If you're hosting GitLab on a cloud provider, you can optionally use a
 11managed service for PostgreSQL. For example, AWS offers a managed Relational
 12Database Service (RDS) that runs PostgreSQL.
 13
 14If you use a cloud-managed service, or provide your own PostgreSQL:
 15
 161. Setup PostgreSQL according to the
 17   [database requirements document](../../install/requirements.md#database).
 181. Set up a `gitlab` username with a password of your choice. The `gitlab` user
 19   needs privileges to create the `gitlabhq_production` database.
 201. Configure the GitLab application servers with the appropriate details.
 21   This step is covered in [Configuring GitLab for HA](gitlab.md).
 22
 23## Configure using Omnibus
 24
 251. Download/install GitLab Omnibus using **steps 1 and 2** from
 26   [GitLab downloads](https://about.gitlab.com/downloads). Do not complete other
 27   steps on the download page.
 281. Create/edit `/etc/gitlab/gitlab.rb` and use the following configuration.
 29   Be sure to change the `external_url` to match your eventual GitLab front-end
 30   URL. If there is a directive listed below that you do not see in the configuration, be sure to add it.
 31
 32    ```ruby
 33    external_url 'https://gitlab.example.com'
 34
 35    # Disable all components except PostgreSQL
 36    postgresql['enable'] = true
 37    bootstrap['enable'] = false
 38    nginx['enable'] = false
 39    unicorn['enable'] = false
 40    sidekiq['enable'] = false
 41    redis['enable'] = false
 42    prometheus['enable'] = false
 43    gitaly['enable'] = false
 44    gitlab_workhorse['enable'] = false
 45    mailroom['enable'] = false
 46
 47    # PostgreSQL configuration
 48    gitlab_rails['db_password'] = 'DB password'
 49    postgresql['md5_auth_cidr_addresses'] = ['0.0.0.0/0']
 50    postgresql['listen_address'] = '0.0.0.0'
 51
 52    # Disable automatic database migrations
 53    gitlab_rails['auto_migrate'] = false
 54    ```
 55
 561. Run `sudo gitlab-ctl reconfigure` to install and configure PostgreSQL.
 57
 58    > **Note**: This `reconfigure` step will result in some errors.
 59      That's OK - don't be alarmed.
 60
 611. Open a database prompt:
 62
 63    ```
 64    su - gitlab-psql
 65    /bin/bash
 66    psql -h /var/opt/gitlab/postgresql -d template1
 67
 68    # Output:
 69
 70    psql (9.2.15)
 71    Type "help" for help.
 72
 73    template1=#
 74    ```
 75
 761. Run the following command at the database prompt and you will be asked to
 77   enter the new password for the PostgreSQL superuser.
 78
 79    ```
 80    \password
 81
 82    # Output:
 83
 84    Enter new password:
 85    Enter it again:
 86    ```
 87
 881. Similarly, set the password for the `gitlab` database user. Use the same
 89   password that you specified in the `/etc/gitlab/gitlab.rb` file for
 90   `gitlab_rails['db_password']`.
 91
 92    ```
 93    \password gitlab
 94
 95    # Output:
 96
 97    Enter new password:
 98    Enter it again:
 99    ```
100
1011. Enable the `pg_trgm` extension:
102    ```
103    CREATE EXTENSION pg_trgm;
104
105    # Output:
106
107    CREATE EXTENSION
108    ```
1091. Exit the database prompt by typing `\q` and Enter.
1101. Exit the `gitlab-psql` user by running `exit` twice.
1111. Run `sudo gitlab-ctl reconfigure` a final time.
1121. Configure the GitLab application servers with the appropriate details.
113   This step is covered in [Configuring GitLab for HA](gitlab.md).
114
115---
116
117Read more on high-availability configuration:
118
1191. [Configure Redis](redis.md)
1201. [Configure NFS](nfs.md)
1211. [Configure the GitLab application servers](gitlab.md)
1221. [Configure the load balancers](load_balancer.md)