Guides

Preparing your VPS for Znodes

By November 29, 2017 No Comments

Some of you have expressed your eagerness to setup your VPS beforehand in preparation for Znodes. This guide takes you through some basic steps to get your VPS ready to minimize the deployment time once Znodes come online.

This guide is based off Ubuntu 16.04 which is the latest stable long term release though it should work in later versions as well.

First of all select a VPS that meets the minimum requirements:

  • 1 gig of RAM (2G recommended)
  • 20+ gigs of disk space

Creating a New User

It is always good practice to create a new user to run the Znode so that the Znode application does not run with root access.

Login as root.

Create a new user with the following command, replacing <username> with a username of your choice.
adduser <username>
You will be prompted for a password. Enter and confirm using a new password (different to your root password) and store it in a safe place.

You will also see prompts for user information, but this can be left blank.

Once the user has been created, we will add them to the sudo group so they can perform commands as root. Only commands/applications run with sudo will run with root privileges, while others will run with regular privileges
usermod -aG sudo <username>
Now, while still as root, we will update the system from the Ubuntu package repository.
apt update
apt upgrade

Installing a Firewall

We are installing UFW (uncomplicated firewall) to further secure your server.

While still in root user (or alternatively you can sudo within your newly created user).
apt install ufw
(press Y and Enter to confirm)

The next step opens port 8168 which is required for your Znode to communicate.
ufw allow ssh/tcp
ufw limit ssh/tcp
ufw allow 8168/tcp
ufw logging on
ufw enable

(press Y and Enter to confirm)

You now have a firewall setup!

Allocating a Swap File

Allocating a swap file can guard your server against out of memory errors in the event your RAM is fully utilized.

Swap is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM. Basically, this gives you the ability to increase the amount of information that your server can keep in its working “memory”, with some caveats. The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data.

The information written to disk will be significantly slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a fall back for when your system’s RAM is depleted can be a good safety net against out-of-memory exceptions on systems.
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
nano /etc/fstab

Add the following line at the end of the file (press tab to separate each word/number),
/swapfile none swap sw 0 0
then press Ctrl + X to close the editor, then Y and Enter save the file.
Then reboot the server.
reboot now

Your VPS is now ready for operation.