# Run an Archival Node

The following instructions are applicable across localnet, testnet, and mainnet.

If you are looking to learn how to compile and run a NEAR Archival node natively for one of the following networks, this guide is for you.

Running an archival node is very similar to running a validator node as both types of node use the same nearcore release. The main difference for running an archival node is a modification to the config.json by changing archive to true. See below for more details.

## Prerequisites​

• Rust. If not already installed, please follow these instructions.
• Git
• Installed developer tools:
• MacOS
$brew install cmake protobuf clang llvm awscli • Linux $ apt update$apt install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python docker.io protobuf-compiler libssl-dev pkg-config clang llvm cargo awscli ### Choosing your nearcore version​ When building your NEAR node you will have two branch options to choose from depending on your desired use: • master : (Experimental) • Use this if you want to play around with the latest code and experiment. This branch is not guaranteed to be in a fully working state and there is absolutely no guarantee it will be compatible with the current state of mainnet or testnet. • Latest stable release : (Stable) • Use this if you want to run a NEAR node for mainnet. For mainnet, please use the latest stable release. This version is used by mainnet validators and other nodes and is fully compatible with the current state of mainnet. • Latest release candidates : (Release Candidates) • Use this if you want to run a NEAR node for tesnet. For testnet, we first release a RC version and then later make that release stable. For testnet, please run the latest RC version. ## testnet​ ### 1. Clone nearcore project from GitHub​ First, clone the nearcore repository. $ git clone https://github.com/near/nearcore$cd nearcore$ git fetch origin --tags

Checkout to the branch you need if not master (default). Latest release is recommended. Please check the releases page on GitHub.

$git checkout tags/1.26.1 -b mynode ### 2. Compile nearcore binary​ In the nearcore folder run the following commands: $ make release

This will start the compilation process. It will take some time depending on your machine power (e.g. i9 8-core CPU, 32 GB RAM, SSD takes approximately 25 minutes). Note that compilation will need over 1 GB of memory per virtual core the machine has. If the build fails with processes being killed, you might want to try reducing number of parallel jobs, for example: CARGO_BUILD_JOBS=8 make release.

By the way, if you’re familiar with Cargo, you could wonder why not run cargo build -p neard --release instead. While this will produce a binary, the result will be a less optimized version. On technical level, this is because building via make neard enables link-time optimisation which is disabled by default.

The binary path is target/release/neard

### 3. Initialize working directory​

The NEAR node requires a working directory with a couple of configuration files. Generate the initial required working directory by running:

### 6. Run the node​

To start your node simply run the following command:

$./target/release/neard --home ~/.near run That's all. The node is running you can see log outputs in your console. It will download a bit of missing data since the last backup was performed but it shouldn't take much time. ## mainnet​ ### 1. Clone nearcore project from GitHub​ First, clone the nearcore repository. $ git clone https://github.com/near/nearcore$cd nearcore$ git fetch origin --tags

Next, checkout the release branch you need (recommended) if you will not be using the default master branch. Please check the releases page on GitHub for the latest release.

For more information on choosing between master and latest release branch [ click here ].

$git checkout tags/1.26.1 -b mynode ### 2. Compile nearcore binary​ In the nearcore folder run the following commands: $ make release

This will start the compilation process. It will take some time depending on your machine power (e.g. i9 8-core CPU, 32 GB RAM, SSD takes approximately 25 minutes). Note that compilation will need over 1 GB of memory per virtual core the machine has. If the build fails with processes being killed, you might want to try reducing number of parallel jobs, for example: CARGO_BUILD_JOBS=8 make release.

By the way, if you’re familiar with Cargo, you could wonder why not run cargo build -p neard --release instead. While this will produce a binary, the result will be a less optimized version. On technical level, this is because building via make neard enables link-time optimisation which is disabled by default.

The binary path is target/release/neard

### 3. Initialize working directory​

The NEAR node requires a working directory with a couple of configuration files. Generate the initial required working directory by running:

### 6. Run the node​

To start your node simply run the following command:

\$ ./target/release/neard --home ~/.near run

That's all. The node is running and you can see log outputs in your console. It will download a bit of missing data since the last backup was performed but it shouldn't take much time.

Got a question?

Ask it on StackOverflow!