docs2 icon indicating copy to clipboard operation
docs2 copied to clipboard

docs: Step by step installation of a full archive node on Debian 11

Open Theroxat opened this issue 1 year ago • 0 comments

Hi everyone, I've just set up a Mina archive node and I couldn't find any documentation on importing the daily dump before starting the synchronization, to have a complete archive node. So, I've created a procedure to do it:

This tutorial is based on a freshly installed Debian 11.

Installation of PostgreSQL 15 (with version 13, there are import errors):

sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https lsb-release sudo wget unzip curl -y

curl -fsSl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /usr/share/keyrings/postgresql.gpg > /dev/null

echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main | sudo tee /etc/apt/sources.list.d/postgresql.list

sudo apt update

sudo apt install postgresql-client-15 postgresql-15

Check if the database is started:

systemctl status postgresql

Then log in with the postgres user

su - postgres

Creating the password for postgres(set your own password) :

psql -c "alter user postgres with password '**StrongDBPassword**'"

Finally, we create our database:

createdb archive_balances_migrated

Now you need to download the latest dump, search for the exact name of the most recent snapshot here, adjust the download link with the date of the previous day to download the most recent dump

wget https://storage.googleapis.com/mina-archive-dumps/mainnet-archive-dump-2023-12-01_0000.sql.tar.gz

tar xvf mainnet-archive-dump-2023-12-01_0000.sql.tar.gz

Import the dump into the database:

psql -d archive_balances_migrated -f mainnet-archive-dump-2023-12-01_0000.sql

Install the mina archive daemon :

echo "deb [trusted=yes] http://packages.o1test.net $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/mina.list

sudo apt-get update

sudo apt-get install -y mina-mainnet=1.4.0-c980ba8

Finally, launch the archive node, the synchronization of the latest blocks will be performed:

mina-archive run --postgres-uri postgres://postgres:**StrongDBPassword**@localhost:5432/archive_balances_migrated --server-port 3086

Add this argument to your .mina-env file on your Mina node so that it points to your archive node:

--archive-address yourip:3086

When the latest blocks are synced, you need to check that everything is okay:

psql -d archive_balances_migrated

SELECT count( * )
FROM (SELECT h::int FROM generate_series(1 , (select max(height) from blocks)) h
LEFT JOIN blocks b
ON h = b.height where b.height is null) as v;

The result should be 0

select count(*) from blocks where parent_id is null;

the result should be 1

Here is a script that will check for missing blocks and restore them periodically: https://github.com/MinaProtocol/mina/blob/develop/src/app/rosetta/download-missing-blocks.sh

Many thanks to @garethtdavies for his help.

Theroxat avatar Dec 02 '23 09:12 Theroxat