Skip to content

Databases

Stefan Benten edited this page Dec 28, 2020 · 5 revisions

Databases

This document decribes the following:

Storj Components With Databases

Each component of the Storj network (i.e. satellites, storage nodes, uplinks) has different persistent data stores.

Satellites and Storage Nodes both have a single Database interface, referred to as the master DB. The master DB specifies which databases are needed, it doesn't specify how they are implemented. This means different satellites can use different backends.

Satellites have two databases behind the master DB interface.

The three databases are:

  1. Satellite.DB
  2. PointerDB

Storage Nodes have three databases behind the master DB interface.

The databases include:

  1. pieces
  2. infodb
  3. psdb

storj-components-with-databases See below for more details about each database. Note: Kademlia has been deprecated.

Satellites

Satellites store the most data of all the components. Satellites have three databases behind one interface. The interface is called the master DB. The master database specifies which databases are needed, it doesn't specify how they are implemented. This means different satellites can end up with different backends.

Satellites have two databases:

  1. Satellite.DB.
  2. PointerDB.

Satellite.DB

The Satellite.DB is a SQL relational database. Currently supported are SQLite3 and PostgreSQL.

There are a number of different tables in the Satellite.DB including the following:

  • Users
  • Accounting
  • Nodes and Overlay Cache Nodes
  • Projects and ApiKeys
  • and more

References:

PointerDB

PointerDB is a key/value store. Currently supported are BoltDB and Postgresql k/v store. PointerDB stores information about pieces and which storage nodes they are stored on.

Keys in PointerDB are a path name (Storj.Path object) in the format "projectName/segment/bucketName".

Values in PointerDB are Pointer objects. Pointer objects store metadata about where pieces are stored on which nodes.

Reference:

Storage Nodes

Storage Nodes have three databases behind a single master DB interface.

The databases include:

  1. pieces
  2. infodb
  3. psdb

pieces Database

pieces is an interface to disk blob storage. pieces saves the actual pieces.

info Database

A SQL database that contains six tables. The tables contain information on:

  • OrderArchive and UnsentOrders: stores sent and unsent orders to track what still needs to be sent to the Satellite.
  • PieceInfo: stores piece meta info, tracking what pieces are currently stored.
  • Cert: stores uplink and satellite certificates.
  • Bandwidth: stores bandwidth usage info, tracking how much bandwidth has been transferred.
  • UserSerials: stores serial numbers that have already been used.

psdb Database

Is a SQL database that stores bandwidth agreements.

Uplinks

Uplinks do not have any persistent storage.

View the Contents of a Database

SQLite

To view the contents of a sqlite3 database file, you can use the command sqlite3. This comes installed by default on OSX. See documentation on for details SQLite CLI.

$ sqlite3 path/to/db/file

BoltDB

To view the contents of a BoltDB database file, there are a number of BoltDB browser tools. See bolt browser or bolter as options.

$ boltbrowser path/to/boltdb/file

PostgreSQL

To view the contents of a PostgreSQL database, use the psql command line program. See psql docs for details.

$ psql -h hostname -U user

Steps to Modify Existing Databases

Satellite