Run an Indexer Fullnode
Summary
Section titled “Summary”To run an indexer fullnode, these are the steps in summary:
- Make sure that you have all the required tools and packages described below in this document.
- Follow the instructions to set up a public fullnode but do not start the fullnode yet.
- Edit the
fullnode.yaml
as described below in this document. - Run the indexer fullnode per the instructions below.
Prerequisites
Section titled “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:
brew
-/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Run the commands emitted in the output to add the command to your path and install any dependenciescargo
Rust package manager -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
docker
-brew install docker
- libpq Postgres C API library containing the
pg_ctl
command -brew install libpq
Make sure to perform all export commands after the installation. postgres
PostgreSQL server -brew install postgresql
diesel
-brew install diesel
Set up the database
Section titled “Set up the database”- Start the PostgreSQL server:
brew services start postgresql
- Ensure you can run
psql postgres
and then exit the prompt by entering:\q
- Create a PostgreSQL user
postgres
with thecreateuser
command (find it withwhich
):Terminal window /path/to/createuser -s postgres - Clone
aptos-core
repository if you have not already:Terminal window git clone https://github.com/aptos-labs/aptos-core.git - Navigate (or
cd
) intoaptos-core/crates/indexer
directory. - Create the database schema:
This will create a database schema with the subdirectory
Terminal window diesel migration run --database-url postgresql://localhost/postgresmigrations
located in thisaptos-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
Section titled “Start the fullnode indexer”-
Follow the instructions to set up a public fullnode and prepare the setup, but do not yet start the indexer (with
cargo run
ordocker run
). -
Pull the latest indexer Docker image with:
Terminal window docker pull aptoslabs/validator:nightly_indexer -
Edit the
./fullnode.yaml
and add the following configuration:storage:enable_indexer: true# This is to avoid the node being prunedstorage_pruner_config:ledger_pruner_config:enable: falseindexer:enabled: truepostgres_uri: "postgres://postgres@localhost:5432/postgres"processor: "default_processor"check_chain_id: trueemit_every: 500
- Run the indexer fullnode with either
cargo run
ordocker run
depending upon your setup. Remember to supply the arguments you need for your specific node:or:Terminal window 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.yamlTerminal window cargo run -p aptos-node --features "indexer" --release -- -f ./fullnode.yaml
Restart the indexer
Section titled “Restart the indexer”To restart the PostgreSQL server:
-
Shut down the server by searching for the
postmaster
process and killing it:Terminal window ps -ef | grep -i postmaster -
Copy the process ID (PID) for the process and pass it to the following command to shut it down:
Terminal window kill -INT PID -
Restart the PostgreSQL server with:
Terminal window brew services restart postgresql@14