Skip to content
🎉 Welcome to the new Aptos Docs! Click here to submit feedback!
Build
Run an Indexer Fullnode

Run an Aptos Indexer

⚠️

This is documentation for the legacy indexer. To learn how to run the underlying infrastructure for the latest indexer stack, see Transaction Stream Service.

⚠️

The below installation steps are verified only on macOS with Apple Silicon. They might require minor tweaking when running on other builds.

Summary

To run an indexer fullnode, these are the steps in summary:

  1. Make sure that you have all the required tools and packages described below in this document.
  2. Follow the instructions to set up a public fullnode but do not start the fullnode yet.
  3. Edit the fullnode.yaml as described below in this document.
  4. Run the indexer fullnode per the instructions below.

Prerequisites

Install the packages below. Note, you may have already installed many of these while preparing your development environment. You can confirm by running which command-name and ensuring the package appears in the output (although libpq will not be returned even when installed).

Important: If you are on macOS, you will need to install Docker following the official guidance rather than brew.

For an Aptos indexer fullnode, install these packages:

Set up the database

  1. Start the PostgreSQL server: brew services start postgresql
  2. Ensure you can run psql postgres and then exit the prompt by entering: \q
  3. Create a PostgreSQL user postgres with the createuser command (find it with which):
    Terminal
    /path/to/createuser -s postgres
  4. Clone aptos-core repository if you have not already:
    Terminal
    git clone https://github.com/aptos-labs/aptos-core.git
  5. Navigate (or cd) into aptos-core/crates/indexer directory.
  6. Create the database schema:
    Terminal
    diesel migration run --database-url postgresql://localhost/postgres
    This will create a database schema with the subdirectory migrations located in this aptos-core/crates/indexer directory. If for some reason this database is already in use, try a different database. For example: DATABASE_URL=postgres://postgres@localhost:5432/indexer_v2 diesel database reset

Start the fullnode indexer

  1. Follow the instructions to set up a public fullnode and prepare the setup, but do not yet start the indexer (with cargo run or docker run).

  2. Pull the latest indexer Docker image with:

    Terminal
    docker pull aptoslabs/validator:nightly_indexer
  3. Edit the ./fullnode.yaml and add the following configuration:

    fullnode.yaml
    storage:
      enable_indexer: true
      # This is to avoid the node being pruned
      storage_pruner_config:
        ledger_pruner_config:
          enable: false
     
    indexer:
      enabled: true
      postgres_uri: "postgres://postgres@localhost:5432/postgres"
      processor: "default_processor"
      check_chain_id: true
      emit_every: 500

Bootstrapping the fullnode

Instead of syncing your indexer fullnode from genesis, which may take a long period of time, you can choose to bootstrap your fullnode using backup data before starting it. To do so, follow the instructions to restore from a backup.

Note: indexers cannot be bootstrapped using a snapshot or fast sync.

  1. Run the indexer fullnode with either cargo run or docker run depending upon your setup. Remember to supply the arguments you need for your specific node:
    Terminal
    docker run -p 8080:8080 \
      -p 9101:9101 -p 6180:6180 \
      -v $(pwd):/opt/aptos/etc -v $(pwd)/data:/opt/aptos/data \
      --workdir /opt/aptos/etc \
      --name=aptos-fullnode aptoslabs/validator:nightly_indexer aptos-node \
      -f /opt/aptos/etc/fullnode.yaml
    or:
    Terminal
    cargo run -p aptos-node --features "indexer" --release -- -f ./fullnode.yaml

Restart the indexer

To restart the PostgreSQL server:

  1. Shut down the server by searching for the postmaster process and killing it:

    Terminal
    ps -ef | grep -i postmaster
  2. Copy the process ID (PID) for the process and pass it to the following command to shut it down:

    Terminal
    kill -INT PID
  3. Restart the PostgreSQL server with:

    Terminal
    brew services restart postgresql@14