Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Комментарий: Published by Scroll Versions from space TMAG and version 7.15
Sv translation
languageru

Данные Traffic Monitor хранятся в Data Storage в корзинах (bucket). Чтобы создать резервную копию хранилища бинарных данных,

...

нужно создать копии этих корзин. Эта процедура состоит из следующих шагов:

  1. Включение возможности резервного копирования
  2. Получение токена для работы с сервисом Data Storage
  3. Получение списка корзин

...

  1. для бэкапа
  2. Создание задачи резервного копирования
  3. Проверка успешного завершения копирования

...

В процессе создания копии Data Storage потребуется выполнять запросы с помощью утилиты curl.

Якорь
Address
Address
При их выполнении в качестве адреса сервера <ADDRESS> вы можете указывать:

  • localhost:40731, если запросы будут выполняться на сервере, где установлено хранилище.
  • <IP_адрес_сервера>:40732, если запросы отправляются с другого сервера.

Якорь
Enable
Enable
Включение возможности резервного копирования

...

Чтобы можно было создать резервную копию Data Storage, нужно задать директорию для нее.

Рекомендуем делать это при установке хранилища,

...

указывая при запуске инсталлятора параметр --dsbackupspath с директорией сохранения бэкапов.
Пример: ./setup.py install --dsbackupspath=/opt/dsbackups

Чтобы

...

задать директорию уже после установки, добавьте ее в деплоймент Data Storage. Для этого:

  1. На сервере Data Storage

...

  1. создайте директорию для хранения резервной копии хранилища:

    Блок кода
    mkdir /opt/dsbackups
  2. Смонтируйте в эту директорию внешнее хранилище резервных копий. Требования к хранилищу бэкапов описаны в статье Проверка хранилища резервной копии.
  3. Назначьте пользователя и права доступа для созданной директории:

    Блок кода
    chown 1000 /opt/dsbackups
    chmod 700 /opt/dsbackups
  4. Откройте деплоймент Data Storage для редактирования с помощью команды:

    Блок кода
    kubectl -n infowatch edit deployment datastorage-<node_label>

    где <node_label> – здесь и далее лейбл ноды, на которой установлено хранилище. Для центральной ноды кластера или, если хранилище установлено не в кластере платформенных продуктов, используйте лейбл central. Для офисной ноды лейбл задается при установке, по умолчанию: office.
    Следующие действия зависят от того, какой вы используете текстовый редактор. В нашем примере мы используем vi. Чтобы войти в режим ввода, нажмите клавишу i.

  5. В секцию containers -

...

  1. > volumeMounts добавьте следующие строки:

    Блок кода
    - name: datastorage-databackups-host-volume-<node_label>
      mountPath: /var/lib/databackups
      mountPropagation: HostToContainer

    В этом и следующем шаге делайте отступы с помощью пробела и не используйте табуляцию.

  2. В секцию volumes добавьте следующие строки:

    Блок кода
    - name: datastorage-databackups-host-volume-<node_label>
      hostPath:
        path: /opt/dsbackups
  3. Сохраните изменения и выйдите из редактора.
    Например, если вы используете редактор vi, нажмите Esc и введите :wq.

Якорь
Token
Token
Получение токена для работы с сервисом Data Storage

Для работы с сервисом Data Storage нужно получить Bearer-токен для HTTP-авторизации. В запросах к Data Storage его нужно указывать в заголовке Authorization.
Значение токена может устаревать, и тогда в ответ на запрос сервис возвращает HTTP-код 440. В таком случае получите токен повторно.

Чтобы получить токен, отправьте в Data Storage запрос следующего вида:

Блок кода
curl -X GET -I --silent "http://<ADDRESS>/v2/logon?extAPIToken=<DS_user_token>" 2>&1 | grep '^Authorization'

где <ADDRESS> – адрес сервера. Подробнее см. выше.
<DS_user_token> – токен авторизации Data Storage. Значение по умолчанию: 1exwo92iwpczl1hy6jxy. Подробнее см. Настройка соединения с Data Storage.

В результате будет выведен заголовок Authorization в следующем формате:
Authorization: Bearer <token_value>

Якорь
Bucket_list
Bucket_list
Получение списка корзин для бэкапа

Чтобы получить список идентификаторов корзин Data Storage, в которых хранятся данные Traffic Monitor, подключитесь к базе данных (БД) Traffic Monitor и выполните запрос:

Блок кода
select distinct(storage_bucket_id) from iwtm.tbs_list;

Если вам нужно узнать список всех существующих корзин Data Storage (их идентификаторы bucketID), выполните следующий запрос к сервису хранилища:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets?filter=*" 2>&1

где <AUTH_HEADER> – это заголовок Authorization, полученный на предыдущем шаге;
<ADDRESS> – адрес сервера.

Раскрыть
titleРезультат в формате JSON может иметь следующий вид:
Блок кода
{
  "data": [
    {
      "backendType": "seaweedfs",
      "id": "barbucket",
      "isDumped": false,
      "isInaccurate": false,
      "isSlowDrive": false,
      "size": 27632
    },
    {
      "backendType": "seaweedfs",
      "id": "bazbucket",
      "isDumped": false,
      "isInaccurate": false,
      "isSlowDrive": false,
      "size": 27633
    },
    {
      "backendType": "file",
      "id": "oldbucket",
      "isDumped": false,
      "isInaccurate": false,
      "isSlowDrive": false,
      "size": 27634
    }
  ]
}

Также вы можете отфильтровать список корзин с помощью регулярного выражения, используя утилиту jq. Например, следующий запрос найдет все корзины, у которых значение bucketID начинается на подстроку bar:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets?filter=*" 2>&1 | jq --raw-output '.data.[] | select(.backendType=="seaweedfs") | select(.id|test("^bar")).id'

Якорь
Task
Task
Создание задачи резервного копирования

Чтобы создать задачу на бэкап корзины, выполните следующий запрос:

Блок кода
curl -X POST --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?bucketID=<BUCKET_ID>"

где <AUTH_HEADER> – заголовок Authorization;
<ADDRESS> –
адрес сервера. Подробнее см. выше;
<BUCKET_ID> – идентификатор корзины.

В ответ будет выведен идентификатор созданной задачи:

Блок кода
{
  "taskID": "fe8163f2-a0fb-4990-8bb7-87aee5c425bc"
}

Также вы можете создать задачу на бэкап корзины и получить идентификатор этой задачи, используя утилиту jq:

Блок кода
curl -X POST --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?bucketID=<BUCKET_ID>" | jq --raw-output '.taskID'

Далее по идентификатору задачи можно проверить успешность выполнения резервного копирования корзины.

Якорь
Result
Result
Проверка успешного завершения копирования

Чтобы убедиться в том, что копирование успешно завершено, проверьте статус задачи. Для этого выполните запрос:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?taskID=<TASK_ID>"

где <AUTH_HEADER> – это заголовок Authorization;
<ADDRESS> –
адрес сервера. Подробнее см. выше;
<TASK_ID> – идентификатор задачи.

В случае успеха будут выведены имена созданных файлов данных и индекса в директории бэкапа:

Блок кода
{
  "bucketID": "foobucket",
  "dataFilename": "foobucket_0.tar.gz",
  "indexFilename": "foobucket_extindex.tar.gz",
  "taskStatus": "Success"
}

У случае неудачи будет выведено описание ошибки:

Блок кода
{
  "bucketID": "foobucket",
  "error": "permission denied: cannot extract data tarball",
  "taskStatus": "Success"
}

Убедитесь в том, что задача завершена и имеет один из следующих статусов: Success, Canceled, Failed.

Также вы можете получить статус задачи, используя утилиту jq:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?taskID=<TASK_ID>" | jq --raw-output '.taskStatus'
Sv translation
languageen

In Data Storage, Traffic Monitor data are stored in buckets. To back up the storage of binary data, you need to back up these buckets. This procedure consists of the following steps:

  1. Enabling functionality of backup
  2. Getting a token to work with the Data Storage service
  3. Getting a list of buckets for backup
  4. Creating the backup task
  5. Checking successful completion of backup

During the backuping process you need to send requests using the curl utility.

Якорь
Address
Address
When doing this, you can specify the following values as a server address <ADDRESS>:

  • localhost:40731, if you send requests from the server where Data Storage is installed.
  • <server_IP_address>:40732, if you send requests from another server.

Якорь
Enable
Enable
Enabling functionality of backup

To enable creating a backup of Data Storage, you need to specify a directory for that.

We recommend to do it when you install the storage. For this, run the installer using the --dsbackupspath parameter with the directory for backups.
Example: ./setup.py install --dsbackupspath=/opt/dsbackups

To specify the directory after installation, add it to the Data Storage deployment. For this:

  1. On the Data Storage server, create a directory for storing a backup:

    Блок кода
    mkdir /opt/dsbackups
  2. Mount an external storage for backups into this directory. Requirements for the backup storage are described in the Проверка хранилища резервной копии article.
  3. Set a user and access permissions for the created directory:

    Блок кода
    chown 1000 /opt/dsbackups
    chmod 700 /opt/dsbackups
  4. Open the Data Storage deployment for editing. For this use the command:

    Блок кода
    kubectl -n infowatch edit deployment datastorage-<node_label>

    where <node_label> (hereafter) is the label of the node where the storage is installed. For the central node or, if the storage is installed not in the cluster of Platform products, use the label central. For the office node, the label is specified during installation (office by default).
    The following actions depends on a text editor that you use. In our example, we use vi. To enter insert mode, press i.

  5. Add the following lines to the containers -> volumeMounts section:

    Блок кода
    - name: datastorage-databackups-host-volume-<node_label>
      mountPath: /var/lib/databackups
      mountPropagation: HostToContainer

    In this and the next step, indent with spaces and do not use a tab.

  6. Add the following lines to the volumes section:

    Блок кода
    - name: datastorage-databackups-host-volume-<node_label>
      hostPath:
        path: /opt/dsbackups
  7. Save the changes and exit the editor.
    For example, if you use the vi editor, press Esc and type :wq.

Якорь
Token
Token
Getting a token to work with the Data Storage service

To work with the Data Storage service, you need to get a Bearer token for HTTP authorization. In requests to Data Storage, specify it in the Authorization header.
The token value can become outdated. So in response to a request, the service returns the 440 HTTP code. In this case, get the token again.

To get the token, send the following request to Data Storage:

Блок кода
curl -X GET -I --silent "http://<ADDRESS>/v2/logon?extAPIToken=<DS_user_token>" 2>&1 | grep '^Authorization'

where <ADDRESS> is the server address. For details, see above.
<DS_user_token> is the Data Storage authorization token. The default value: 1exwo92iwpczl1hy6jxy. To learn more, see Настройка соединения с Data Storage.

As a result, you will see the Authorization header in the following format:
Authorization: Bearer <token_value>

Якорь
Bucket_list
Bucket_list
Getting a list of buckets for backup

To get a list of identifiers of Data Storage buckets which store Traffic Monitor data, connect to the Traffic Monitor database and run the query:

Блок кода
select distinct(storage_bucket_id) from iwtm.tbs_list;

If you need to know a list of all existing Data Storage buckets (their bucketID identifiers), send the following request to the storage service:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets?filter=*" 2>&1

where <AUTH_HEADER> is the Authorization header received on the previous step;
<ADDRESS> is the server address. For details, see above.

Раскрыть
titleResults in the JSON format may look as follows:
Блок кода
{
  "data": [
    {
      "backendType": "seaweedfs",
      "id": "barbucket",
      "isDumped": false,
      "isInaccurate": false,
      "isSlowDrive": false,
      "size": 27632
    },
    {
      "backendType": "seaweedfs",
      "id": "bazbucket",
      "isDumped": false,
      "isInaccurate": false,
      "isSlowDrive": false,
      "size": 27633
    },
    {
      "backendType": "file",
      "id": "oldbucket",
      "isDumped": false,
      "isInaccurate": false,
      "isSlowDrive": false,
      "size": 27634
    }
  ]
}

Also you can filter the bucket list with a regular expression using the jq utility. For example, the following request will find all buckets whose bucket ID value begins with the "bar" substring:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets?filter=*" 2>&1 | jq --raw-output '.data.[] | select(.backendType=="seaweedfs") | select(.id|test("^bar")).id'

Якорь
Task
Task
Creating the backup task

To create a task of bucket backup, send the following request:

Блок кода
curl -X POST --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?bucketID=<BUCKET_ID>"

where <AUTH_HEADER> is the Authorization header;
<ADDRESS> is the server address. For details, see above;

<BUCKET_ID> is the bucket identifier.

In response, the ID of the created task will be displayed:

Блок кода
{
  "taskID": "fe8163f2-a0fb-4990-8bb7-87aee5c425bc"
}

Also you can create a bucket backup task and get the ID of this task using the jq utility:

Блок кода
curl -X POST --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?bucketID=<BUCKET_ID>" | jq --raw-output '.taskID'

Next, you can check successful completion of bucket backup using the task ID.

Якорь
Result
Result
Checking successful completion of backup

To make sure that backuping completed successfully, check the status of the task. For this, send the request:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?taskID=<TASK_ID>"

where <AUTH_HEADER> is the Authorization header;
<ADDRESS> is the server address. For details, see above;

<TASK_ID> is the task identifier.

If succesfull, you will see names of data and index files created in the backup directory:

Блок кода
{
  "bucketID": "foobucket",
  "dataFilename": "foobucket_0.tar.gz",
  "indexFilename": "foobucket_extindex.tar.gz",
  "taskStatus": "Success"
}

In case of failure, the error description will be displayed:

Блок кода
{
  "bucketID": "foobucket",
  "error": "permission denied: cannot extract data tarball",
  "taskStatus": "Success"
}

Make sure that the task is completed and has one of the following statuses: Success, Canceled, Failed.

Also you can get the task status using the jq utility:

Блок кода
curl -X GET --header "<AUTH_HEADER>" --silent "http://<ADDRESS>/v3/buckets/backups?taskID=<TASK_ID>" | jq --raw-output '.taskStatus'