Run a Node on Linux and MacOS
If this is the first time for you to setup a validator node, head to our Validator Bootcamp 🚀. Please head to Run a node for instructions on how to setup a validator node with neard.
This doc is written for developers, sysadmins, DevOps, or curious people who want to know how to run a NEAR node on Linux and MacOS.
Running a Node using Docker​
For running a node using Docker, please refer to the Docker setup guide.
Compiling and Running a Node without Docker​
You can build and run a node without Docker by compiling neard locally. Steps in this section provide details of how to do this.
As a prerequisite, Rust needs to be installed on your machine.
For Mac OS, make sure you have developer tools installed and then use brew to install extra tools:
brew install cmake protobuf clang llvm
For Linux, install these dependencies:
sudo apt update
sudo 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
Then clone the repo:
git clone https://github.com/near/nearcore.git
cd nearcore
Checkout the version you wish to build:
git checkout <version>
You can then run:
make neard
This will compile the neard binary for the version you have checked out, it will be available under target/release/neard.
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 neard.
NB. Please ensure you build releases through make rather than cargo
build --release. The latter skips some optimisations (most notably
link-time optimisation) and thus produces a less efficient executable.
If your machine is behind a firewall or NAT, make sure port 24567 is open and forwarded to the machine where the node is going to be running.
Finally, initialize the working directory and start the node:
./target/release/neard --home ~/.near init --chain-id testnet --download-genesis --download-config rpc
./target/release/neard --home ~/.near run
If you want to run localnet instead of testnet, then replace
testnet with localnet in the command above. (If you're running
localnet you don't need to open port 24567).
For validation, please follow the Validator Bootcamp.
Running a Node on the Cloud​
Create a new instance following the Hardware requirements.
Add firewall rules to allow traffic to port 24567 from all IPs (0.0.0.0/0).
SSH into the machine. Depending on your cloud provider this may
require different commands. Often simple ssh hosts-external-ip
should work. Cloud providers may offer custom command to help with
connecting to the instances: GCP offers gcloud compute
ssh, AWS
offers aws emr
ssh
and Azure offers az
ssh.
Once connected to the instance, follow the steps listed above.
Starting a node from backup​
Using data backups allows you to sync your node quickly by using public tar backup files. There are two types of backups for available for both testnet and mainnet:
- regular
- archival
Archive links​
Download the latest snapshots from Node Data Snapshots.
Starting node using neard backup data:
./neard init --chain-id <chain-id> --download-genesis
mkdir ~/.near/data
wget -c <link-above> -O - | tar -xC ~/.near/data
./neard run
Where <chain-id> corresponds to testnet or mainnet.
Got a question?
Ask it on StackOverflow!