Skip to main content

Run a Metal Node Using the Install Script

We have a shell (bash) script that installs MetalGo on your computer. This script sets up full, running node in a matter of minutes with minimal user input required.

Before You Start

Metal is an incredibly lightweight protocol, so nodes can run on commodity hardware with the following minimum specifications. Note that as network usage increases, hardware requirements may change.

  • CPU: Equivalent of 8 AWS vCPU
  • RAM: 16 GiB
  • Storage: 250 GiB
  • OS: Ubuntu 18.04/20.04 or MacOS >= Catalina
  • Network: sustained 5Mbps up/down bandwidth

Please note that HW requirements shall scale with the amount of METAL staked on the node. Nodes with big stakes (100k+ METAL) will need more powerful machines than listed, and will use more bandwidth as well.

This install script assumes:

  • MetalGo is not running and not already installed as a service
  • User running the script has superuser privileges (can run sudo)

Environment Considerations

If you run a different flavor of Linux, the script might not work as intended. It assumes systemd is used to run system services. Other Linux flavors might use something else, or might have files in different places than is assumed by the script. It will probably work on any distribution that uses systemd but it has been developed for and tested on Ubuntu.

If you have a node already running on the computer, stop it before running the script. Script won't touch the node working directory so you won't need to bootstrap the node again.

Node Running from Terminal

If your node is running in a terminal stop it by pressing ctrl+C.

Node Running as a Service

If your node is already running as a service, then you probably don't need this script. You're good to go.

Node Running in the Background

If your node is running in the background (by running with nohup, for example) then find the process running the node by running ps aux | grep metal. This will produce output like:

ubuntu  6834  0.0  0.0   2828   676 pts/1    S+   19:54   0:00 grep metal
ubuntu 2630 26.1 9.4 2459236 753316 ? Sl Dec02 1220:52 /home/ubuntu/build/metalgo

Look for line that doesn't have grep on it. In this example, that is the second line. It shows information about your node. Note the process id, in this case, 2630. Stop the node by running kill -2 2630.

Node Working Files

If you previously ran a MetalGo node on this computer, you will have local node files stored in $HOME/.metalgo directory. Those files will not be disturbed, and node set up by the script will continue operation with the same identity and state it had before. That being said, for your node's security, back up staker.crt and staker.key files, found in $HOME/.metalgo/staking and store them somewhere secure. You can use those files to recreate your node on a different computer if you ever need to. Check out this tutorial for backup and restore procedure.

Networking Considerations

To run successfully, MetalGo needs to accept connections from the Internet on the network port 9651. Before you proceed with the installation, you need to determine the networking environment your node will run in.

Running on a Cloud Provider

If your node is running on a cloud provider computer instance, it will have a static IP. Find out what that static IP is, or set it up if you didn't already. The script will try to find out the IP by itself, but that might not work in all environments, so you will need to check the IP or enter it yourself.

Running on a Home Connection

If you're running a node on a computer that is on a residential internet connection, you have a dynamic IP; that is, your IP will change periodically. The install script will configure the node appropriately for that situation. But, for a home connection, you will need to set up inbound port forwarding of port 9651 from the internet to the computer the node is installed on.

As there are too many models and router configurations, we cannot provide instructions on what exactly to do, but there are online guides to be found (like this, or this ), and your service provider support might help too.

danger

Please note that a fully connected Metal node maintains and communicates over a couple of thousand of live TCP connections. For some low-powered and older home routers that might be too much to handle. If that is the case you may experience lagging on other computers connected to the same router, node getting benched, failing to sync and similar issues.

Running the Script

So, now that you prepared your system and have the info ready, let's get to it.

To download and run the script, enter the following in the terminal:

wget -nd -m https://raw.githubusercontent.com/MetalBlockchain/metal-docs/master/scripts/metalgo-installer.sh;\
chmod 755 metalgo-installer.sh;\
./metalgo-installer.sh

And we're off! The output should look something like this:

MetalGo installer
---------------------
Preparing environment...
Found arm64 architecture...
Looking for the latest arm64 build...
Will attempt to download:
https://github.com/MetalBlockchain/metalgo/releases/download/v1.1.1/metalgo-linux-arm64-v1.1.1.tar.gz
metalgo-linux-arm64-v1.1.1.tar.gz 100%[=========================================================================>] 29.83M 75.8MB/s in 0.4s
2020-12-28 14:57:47 URL:https://github-production-release-asset-2e65be.s3.amazonaws.com/246387644/f4d27b00-4161-11eb-8fb2-156a992fd2c8?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201228%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201228T145747Z&X-Amz-Expires=300&X-Amz-Signature=ea838877f39ae940a37a076137c4c2689494c7e683cb95a5a4714c062e6ba018&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=246387644&response-content-disposition=attachment%3B%20filename%3Dmetalgo-linux-arm64-v1.1.1.tar.gz&response-content-type=application%2Foctet-stream [31283052/31283052] -> "metalgo-linux-arm64-v1.1.1.tar.gz" [1]
Unpacking node files...
metalgo-v1.1.1/plugins/
metalgo-v1.1.1/plugins/evm
metalgo-v1.1.1/metalgo
Node files unpacked into /home/ubuntu/metal-node

And then the script will prompt you for information about the network environment:

To complete the setup some networking information is needed.
Where is the node installed:
1) residential network (dynamic IP)
2) cloud provider (static IP)
Enter your connection type [1,2]:

enter 1 if you have dynamic IP, and 2 if you have a static IP. If you are on a static IP, it will try to auto-detect the IP and ask for confirmation.

Detected '3.15.152.14' as your public IP. Is this correct? [y,n]:

Confirm with y, or n if the detected IP is wrong (or empty), and then enter the correct IP at the next prompt.

Next, you have to set up RPC port access for your node. Those are used to query the node for its internal state, to send commands to the node, or to interact with the platform and its chains (sending transactions, for example). You will be prompted:

Do you want the RPC port to be accessible to any or only local network interface? [any, local]:

If you're ok with sending RPC requests only from the node machine itself, enter local at the prompt. If you want to be able to send RPC requests to your node from a remote machine, enter any. Please note that if you choose to allow RPC requests on any network interface you will need to set up a firewall to only let through RPC requests from known IP addresses, otherwise your node will be accessible to anyone and might be overwhelmed by RPC calls from malicious actors! If you do not plan to use your node to send RPC calls, enter local for increased node security.

The script will then continue with system service creation and finish with starting the service:

Created symlink /etc/systemd/system/multi-user.target.wants/metalgo.service → /etc/systemd/system/metalgo.service.

Done!

Your node should now be bootstrapping.
Node configuration file is /home/ubuntu/.metalgo/configs/node.json
C-Chain configuration file is /home/ubuntu/.metalgo/configs/chains/C/config.json
To check that the service is running use the following command (q to exit):
sudo systemctl status metalgo
To follow the log use (ctrl-c to stop):
sudo journalctl -u metalgo -f

The script is finished, and you should see the system prompt again.

Post Installation

MetalGo should be running in the background as a service. You can check that it's running with:

sudo systemctl status metalgo

This will print the node's latest logs, which should look like this:

● metalgo.service - MetalGo systemd service
Loaded: loaded (/etc/systemd/system/metalgo.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-01-05 10:38:21 UTC; 51s ago
Main PID: 2142 (metalgo)
Tasks: 8 (limit: 4495)
Memory: 223.0M
CGroup: /system.slice/metalgo.service
└─2142 /home/ubuntu/metal-node/metalgo --dynamic-public-ip=opendns --http-host=

Jan 05 10:38:45 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:38:45] <P Chain> metalgo/vms/platformvm/vm.go#322: initializing last accepted block as 2FUFPVPxbTpKNn39moGSzsmGroYES4NZRdw3mJgNvMkMiMHJ9e
Jan 05 10:38:45 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:38:45] <P Chain> metalgo/snow/engine/snowman/transitive.go#58: initializing consensus engine
Jan 05 10:38:45 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:38:45] metalgo/api/server.go#143: adding route /ext/bc/11111111111111111111111111111111LpoYY
Jan 05 10:38:45 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:38:45] metalgo/api/server.go#88: HTTP API server listening on ":9650"
Jan 05 10:38:58 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:38:58] <P Chain> metalgo/snow/engine/common/bootstrapper.go#185: Bootstrapping started syncing with 1 vertices in the accepted frontier
Jan 05 10:39:02 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:39:02] <P Chain> metalgo/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 2500 blocks
Jan 05 10:39:04 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:39:04] <P Chain> metalgo/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 5000 blocks
Jan 05 10:39:06 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:39:06] <P Chain> metalgo/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 7500 blocks
Jan 05 10:39:09 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:39:09] <P Chain> metalgo/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 10000 blocks
Jan 05 10:39:11 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:39:11] <P Chain> metalgo/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 12500 blocks

Note the active (running) which indicates the service is running ok. You may need to press q to return to the command prompt.

To find out your NodeID, which is used to identify your node to the network, run the following command:

sudo journalctl -u metalgo | grep "NodeID"

It will produce output like:

Jan 05 10:38:38 ip-172-31-30-64 metalgo[2142]: INFO [01-05|10:38:38] metalgo/node/node.go#428: Set node's ID to 6seStrauyCnVV7NEVwRbfaT9B6EnXEzfY

Prepend NodeID- to the value to get, for example, NodeID-6seStrauyCnVV7NEVwRbfaT9B6EnXEzfY. Store that; it will be needed for staking or looking up your node.

Your node should be in the process of bootstrapping now. You can monitor the progress by issuing the following command:

sudo journalctl -u metalgo -f

Press ctrl+C when you wish to stop reading node output.

Stopping the Node

To stop MetalGo, run:

sudo systemctl stop metalgo

To start it again, run:

sudo systemctl start metalgo

Node Upgrade

MetalGo is an ongoing project and there are regular version upgrades. Most upgrades are recommended but not required. Advance notice will be given for upgrades that are not backwards compatible. When a new version of the node is released, you will notice log lines like:

Jan 08 10:26:45 ip-172-31-16-229 metalgo[6335]: INFO [01-08|10:26:45] metalgo/network/peer.go#526: beacon 9CkG9MBNavnw7EVSRsuFr7ws9gascDQy3 attempting to connect with newer version metalgo/1.1.1. You may want to update your client

It is recommended to always upgrade to the latest version, because new versions bring bug fixes, new features and upgrades.

To upgrade your node, just run the installer script again:

./metalgo-installer.sh

It will detect that you already have MetalGo installed:

MetalGo installer
---------------------
Preparing environment...
Found 64bit Intel/AMD architecture...
Found MetalGo systemd service already installed, switching to upgrade mode.
Stopping service...

It will then upgrade your node to the latest version, and after it's done, start the node back up, and print out the information about the latest version:

Node upgraded, starting service...
New node version:
metalgo/1.1.1 [network=mainnet, database=v1.0.0, commit=f76f1fd5f99736cf468413bbac158d6626f712d2]
Done!

Advanced Node Configuration

Without any additional arguments, the script installs the node in a most common configuration. But the script also enables various advanced options to be configured, via the command line prompts. Following is a list of advanced options and their usage:

  • admin - Admin API will be enabled
  • archival - disables database pruning and preserves the complete transaction history
  • db-dir - use to provide the full path to the location where the database will be stored
  • tahoe - node will connect to Tahoe testnet instead of the mainnet
  • index - Index API will be enabled
  • ip - use dynamic, static arguments, of enter a desired IP directly to be used as the public IP node will advertise to the network
  • rpc - use any or local argument to select any or local network interface to be used to listen for RPC calls
  • version - install a specific node version, instead of the latest. See here for usage.

Please note that configuring index and archival options on an existing node will require a fresh bootstrap to recreate the database.

Complete script usage can be displayed by entering:

./metalgo-installer.sh --help

Unattended Installation

If you want to use the script in an automated environment where you cannot enter the data at the prompts you must provide at least the rpc and ip options. For example:

./metalgo-installer.sh --ip 1.2.3.4 --rpc local

Usage Examples

To run a Tahoe node with indexing enabled and auto-detected static IP:

./metalgo-installer.sh --tahoe --ip static --index

To run an archival mainnet node with dynamic IP and database located at /home/node/db:

./metalgo-installer.sh --archival --ip dynamic --db-dir /home/node/db

To reinstall the node using node version 1.7.10 and use specific IP and local RPC only:

./metalgo-installer.sh --reinstall --ip 1.2.3.4 --version v1.7.10 --rpc local

Node Configuration

File that configures node operation is ~/.metalgo/configs/node.json. You can edit it to add or change configuration options. The documentation of configuration options can be found here. Configuration may look like this:

{
"dynamic-public-ip": "opendns",
"http-host": ""
}

Note that configuration file needs to be a properly formatted JSON file, so switches are formatted differently than for command line, so don't enter options like --dynamic-public-ip=opendns but as in the example above.

Script also creates an empty C-Chain config file, located at ~/.metalgo/configs/chains/C/config.json. By editing that file you can configure the C-Chain, as described in detail here.

Using a Previous Version

The installer script can also be used to install a version of MetalGo other than the latest version.

To see a list of available versions for installation, run:

./metalgo-installer.sh --list

It will print out a list, something like:

MetalGo installer
---------------------
Available versions:
v1.3.2
v1.3.1
v1.3.0
v1.2.4-arm-fix
v1.2.4
v1.2.3-signed
v1.2.3
v1.2.2
v1.2.1
v1.2.0

To install a specific version, run the script with --version followed by the tag of the version. For example:

./metalgo-installer.sh --version v1.3.1
danger

Note that not all MetalGo versions are compatible. You should generally run the latest version. Running a version other than latest may lead to your node not working properly and, for validators, not receiving a staking reward.

Thanks to community member Jean Zundel for the inspiration and help implementing support for installing non-latest node versions.

Reinstall and Script Update

Installer script gets updated from time to time, with new features and capabilities added. To take advantage of new features or to recover from modifications that made the node fail, you may want to reinstall the node. To do that, fetch the latest version of the script from the web with:

wget -nd -m https://raw.githubusercontent.com/MetalBlockchain/metal-docs/master/scripts/metalgo-installer.sh

After the script has updated, run it again with the --reinstall config flag:

./metalgo-installer.sh --reinstall

This will delete the existing service file, and run the installer from scratch, like it was started for the first time. Note that the database and NodeID will be left intact.

Removing the Node Installation

If you want to remove the node installation from the machine, you can run the script with the --remove option, like this:

./metalgo-installer.sh --remove

This will remove the service, service definition file and node binaries. It will not remove the working directory, node ID definition or the node database. To remove those as well, you can type:

rm -rf ~/.metalgo/

Please note that this is irreversible and the database and node ID will be deleted!

What Next?

That's it, you're running a Metal node!

If you're on a residential network (dynamic IP), don't forget to set up port forwarding. If you're on a cloud service provider, you're good to go.

Now you can interact with your node, stake your tokens, or level up your installation by setting up node monitoring to get a better insight into what your node is doing.

Finally, if you haven't already, it is a good idea to back up important files in case you ever need to restore your node to a different machine.