Сервис базы данных

Сервис MongoDB

Самостоятельно размещаемая база данных MongoDB для приложений, которые хранят JSON-подобные документы внутри стека и выполняют к ним запросы.

Вы добавляете этот сервис в стек и выбираете там его версию и ресурсы. Каждое окружение может их переопределить.

В StackMaster

Как MongoDB работает в StackMaster

What Wodby sets up for this database service, which runs the official MongoDB image. Check it before creating databases or users by hand, or writing a connection string into an application.

Database, user and passwords

Wodby manages the database and its user; the application does not create them.

  • One database and one user are created for the environment, both named after the application and the environment.
  • The user is created in the admin database and has the readWrite role on the environment's database only. A client therefore authenticates against admin (authSource=admin), not against the application database. Authenticating against the application database is the usual reason a correct password is refused.
  • Wodby creates the database by creating a collection named __wodby in it. Leave that collection in place.
  • The administrator is root (MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD in the container). Its password and the user's password are generated once per environment (tokens root_password and password).
  • Creating the user is safe to repeat. A user of the same name that accepts the generated password is kept. One with a different password is left unchanged and the creation fails, so a password changed inside MongoDB is never reset.

How a linked service reaches it

  • Host: the name of this app service inside the environment. Port: 27017.
  • A service linked to this one receives the connection details as environment variables defined by its own link. Read those in the application; do not hardcode them and do not use root from the application.
  • A connection URL that Wodby builds for a link already carries authSource=admin. A URL assembled in the application from host, port, user and password has to add it.

Data, backups and imports

  • Data is on the data volume, mounted at /data/db. The service runs a single instance.
  • The backup is a .tar.gz holding a gzipped mongodump archive of the environment's database and a restore script.
  • The database import takes a .tar.gz or .tgz backup made by this service.
  • The manifest declares no configuration settings; the server runs with the image's defaults.

Check the result

In the database container, mongosh --quiet -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin --eval 'db.adminCommand({listDatabases: 1})' lists the databases.

Обзор

Технический профиль MongoDB

Здесь перечислены версии, которые можно выбрать для MongoDB в стеке или окружении. Сам сервис публикуется ревизиями, и стек ссылается на конкретную ревизию.

Тип сервиса

Сервис базы данных

Версии

8.0

Постоянные тома

Data

Стеки

Стеки, в которые входит MongoDB

MongoDB входит в этот публичный стек. Можно создать приложение из публичного стека как есть или добавить сервис в собственный стек.

Данные

Резервные копии и импорт данных: MongoDB

Сервис MongoDB определяет, как создаются резервные копии его данных и как они импортируются. Резервное копирование и импорт запускаются из окружения, которому принадлежит сервис.

Резервные копии вручную и по расписанию

Создавайте резервную копию, когда она нужна, или задайте расписание в пресете резервного копирования.

Импорт из архива, по URL или из резервной копии

Источником импорта может быть загруженный архив, публичный URL или готовая резервная копия совместимого сервиса.

Где хранятся архивы

StackMaster записывает каждый архив в StackMaster Blob Storage или в бакет у провайдера хранилища, подключённого как интеграция.

Конфигурация

Конфигурация сервиса MongoDB

Сервис MongoDB объявляет следующее. Если значение можно изменить, его задаёт стек, а каждое окружение может его переопределить.

Тома

Data