> For the complete documentation index, see [llms.txt](https://doc.dbrain.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.dbrain.io/dbrain-official/podklyuchenie/lokalnyi-servis-licenzii.md).

# Локальный сервис лицензий

Если разворачиваете сервис Dbrain в закрытом IT-контуре без возможности выхода в Интернет, можете воспользоваться локальным сервисом лицензий

### Установка локального сервиса лицензий

{% hint style="danger" %}
Если вы используете Windows, обязательно [установите Powershell](https://github.com/PowerShell/PowerShell#get-powershell) и выполняйте процесс через него. В противном случае ничего не получится
{% endhint %}

1\. Запустите локальный сервис лицензий:

```bash
docker run --rm -d --name local-license-server -p 8081:8080 registry.dbrain.io/public/license-local:challenge-v2
```

2\. Убедитесь, что сервис запущен:

```bash
curl http://localhost:8081/info
{"limit": 0, "used": 0, "left": 0, "activatedAt": null}
```

Если увидели такой ответ, значит сервис ещё не активирован.

3\. Начните процесс активации, сгенерировав `challenge` строку. Это можно сделать через `curl` или любым иным `http` клиентом.

```bash
curl http://localhost:8081/activation/challenge
<challenge_string>
```

4\. Получите `challenge-answer` — ответ на свою `challenge` строку одним из двух способов:

* С помощью сотрудника `Dbrain` — утилитой `nl_server_starter`
* Отправив e-mail по адресу `robot@license.dbrain.io` с единственным прикреплённым файлом в формате `yaml`:

```yaml
auth_string: user_name:user_password
endpoint: local_license_activate
params:
  challenge: введите_тут_вашу_challenge-строку
```

`username` и `user_password` — заранее выданные логин и пароль. Запросите их у сотрудников `Dbrain`.

5\. Завершите активацию сервиса лицензий, введя `challenge-answer` строку:

```bash
curl http://localhost:8081/activation/activate --data 'ответ_на_challenge-строку'
```

**Обратите внимание: одинарные кавычки в параметре `--data 'string'` важны при использовании в командной строке, иначе некоторые символы `challenge-answer` строки будут неверно интерпретированы в `bash` и активация не удастся.**

6\. Проверьте успешность активации:

```bash
curl http://localhost:8081/info
{"limit": 1000, "used": 0, "left": 1000, "activatedAt": 1651771605}
```

`activatedAt` указывает на `unix`время активации.

7\. Всё, можно пользоваться. Сервис лицензий доступен для сервисов Dbrain по адресу `http://localhost:8081/check/v2`. Не забудьте прописать этот адрес в переменной окружения сервисов Dbrain `LICENSE_URL=<адрес-сервера-лицензий>/check/v2`.

8\. Лимиты и использованные квоты можно проверить в любой момент в эндпоинте `/info`.

9\. Для повторной активации перезапускать сервис не нужно — достаточно снова перейти к пункту (3) и запросить новую `challenge` строку.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.dbrain.io/dbrain-official/podklyuchenie/lokalnyi-servis-licenzii.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
