# Etapa 6

No GitLab 12.1 e posterior, apenas o PostgreSQL é compatível. No GitLab 14.0 e posterior, nós [require PostgreSQL 12+](https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements).

Instale os pacotes de banco de dados.

Para Ubuntu 20.04 e posterior:

```
sudo apt install -y postgresql postgresql-client libpq-dev postgresql-contrib
```

Para Ubuntu 18.04 e anteriores, o PostgreSQL disponível não atende ao requisito de versão mínima. Você deve adicionar o repositório do PostgreSQL:

```
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
```

```
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
```

```
sudo apt update
```

```
sudo apt -y install postgresql-12 postgresql-client-12 libpq-dev
```

Verifique se a versão do PostgreSQL que você possui é compatível com a versão do GitLab que você está instalando:

```
psql --version
```

Inicie o serviço PostgreSQL e confirme se o serviço está em execução:

```
sudo service postgresql start
sudo service postgresql status
```

Crie um usuário de banco de dados para o GitLab:

```
sudo -u postgres psql -d template1 -c "CREATE USER git CREATEDB;"
```

Crie a extensão pg\_trgm:

```
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
```

Crie a extenção `btree_gist` ( necessário para GitLab 13.1+):

```
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"
```

Crie a extenção `plpgsql`:

```
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS plpgsql;"
```

Crie o banco de dados de produção GitLab e conceda todos os privilégios no banco de dados:

```
sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;"
```

Tente se conectar ao novo banco de dados com o novo usuário:

```
sudo -u git -H psql -d gitlabhq_production
```

Verifique se a extensão pg\_trgm está habilitada::

```
SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'pg_trgm'
AND installed_version IS NOT NULL;
```

Se a extensão estiver habilitada, isso produzirá a seguinte saída:

```
enabled
---------
 t
(1 row)
```

Verifique se a extensão `btree_gist` está habilitada:

```
SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'btree_gist'
AND installed_version IS NOT NULL;
```

Se a extensão estiver habilitada, isso produzirá a seguinte saída:

```
enabled
---------
 t
(1 row)
```

Verifique se a extensão `plpgsql` está habilitada:

```
SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'plpgsql'
AND installed_version IS NOT NULL;
```

Se a extensão estiver habilitada, isso produzirá a seguinte saída:

```
enabled
---------
 t
(1 row)
```

Sair da sessão do banco de dados:

```
gitlabhq_production> \q
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liedsons-organization.gitbook.io/gitlab-no-ubuntu/~/changes/v2SMoF2OR3hlOcgvW1pm/instalacao-e-configuracao-source/etapa-6.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
