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