Running in the Cloud
The guide below may be specific to a cloud provider or operating system. You may require additional tooling and setup to build and run a validator node successfully. It is recommended to use the Docker Compose script as documented here.
Before getting started, you will need to have a cloud instance running and be able to SSH into your instance.
Setup Non-Root User
If there is already a non-root user available, you can skip this step.
# SSH into your machine
ssh root@{VALIDATOR_IP_ADDRESS}
# Update the system
sudo apt-get update && sudo apt-get upgrade -y
# Create a non-root user
USER={USER}
sudo mkdir -p /home/$USER/.ssh
sudo touch /home/$USER/.ssh/authorized_keys
sudo useradd -d /home/$USER $USER
sudo usermod -aG sudo $USER
sudo chown -R $USER:$USER /home/$USER/
sudo chmod 700 /home/$USER/.ssh
sudo chmod 644 /home/$USER/.ssh/authorized_keys
- VALIDATOR_IP_ADDRESS: The IP address of the remote machine / server
- USER: The name of the unix user you want to create
Make sure to paste your public SSH key into the authorized_keys file of the newly created user to be able to login via SSH
# Enable sudo without password for the user
sudo vi /etc/sudoers
Add the following line to the end of the file:
{USER} ALL=NOPASSWD: ALL
# Install zsh
sudo apt-get install -y zsh
# Set zsh as the default shell for the user
sudo vi /etc/passwd
Go to the line with your username (likely the same as {USER}
) and change the default shell at the end of the line from:
/bin/bash --> /bin/zsh
You can close the root SSH connection to the remote machine / server by typing exit
, then log in as your newly created user:
# Login as new user
ssh {USER}@{VALIDATOR_IP_ADDRESS}
- VALIDATOR_IP_ADDRESS: The IP address of the remote machine / server
- USER: The name of the unix user you created previously
Install the Required Tools
You should still be logged in as the new user via SSH.
First, install the required build tools:
# Install build-essential
sudo apt-get install -y build-essential
Install Golang
# Install go
wget https://dl.google.com/go/go1.17.1.linux-amd64.tar.gz
sudo tar -xvf go1.17.1.linux-amd64.tar.gz
sudo mv go /usr/local
Then open up your .zshrc
file with vi ~/.zshrc
and export the required go paths:
# Append at the bottom of .zshrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Reload your .zshrc config and validate your go installation:
# Reload .zshrc config
source ~/.zshrc
# Validate go installation
go version
Install PostgreSQL
You will need to add the official repository to your system.
# Install the required tools
sudo apt-get install -y wget ca-certificates
# Import the GPG repository key for PostgreSQL
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Then, add the PostgreSQL repository.
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ 'lsb_release -cs'-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
You should now update the package list to ensure you will install the lastest PostgreSQL package. To do so, type sudo apt-get update
.
# Install PostgreSQL and the PostgreSQL contrib package
sudo apt-get install postgresql postgresql-contrib
By default, the package will create a postgres user, once you successfully install the database system. This user account has the default postgres role.
Build the validator node source code
go build cmd/*
Run the node
Before running the following command, you need to have the necessary configuration populated.
go run cmd/*