NEM Supernode Command Line Tutorial for Debian 8.4


#1

This tutorial will show you how to set up a supernode for NEM on a VPS with Debian 8.4 via the command line in three steps.

Also take a look at:

Command Line Knowledge

We are going to use vim as our text editor. You can also use nano if you are more familiar with it.

For a basic vim tutorial visit:

English:

German:

Hardware & Software Requirements

You will need a VPS that fulfills the following requirements:

  • RAM: At least 4GB recommended (at least 2800MB to NIS and 128MB to the servant)
  • CPU: 1Ghz+ single core or more is recommend
  • Upstream: at least 5mbps
  • Open inbound/outbound TCP ports for 7778, 7880, and 7890 on firewalls and routers
  • Debian 8.4 minimal
  • Root access via SSH

Hosting recommendations:

1. Installation

You will need to access your server as the root user:

ssh [email protected]

If you use Amazon AWS, visit: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html

Depending on your Linux distribution, you might not log in with [email protected]. In that case, once you are logged in with a different user type su -i to log in as the root user.

1.1. Create a swap file

If your host does not allow creating a swap file you can advance to section 1.2. but in this case I would recommend using a VPS with 4GB of RAM.

You can also skip this step if free -h shows you that a swap file already exists.

Change count to the size of your RAM. In my case my VPS has 4GB of RAM so I choose 4194304.

su
dd if=/dev/zero of=/swapfile bs=1024 count=4194304
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab

1.2. Install Java 8

su
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer

1.3. Download and configure NIS

Visit http://bob.nem.ninja/ to check for the latest nis-ncc url.

wget http://bob.nem.ninja/nis-0.6.96.tgz
tar -xvzf nis-0.6.96.tgz
rm nis-0.6.96.tgz
mkdir nis-ncc
mv package nis-ncc/package

Using vim we are going to create a custom config file. If it is not installed follow these commands:

sudo apt-get update
sudo apt-get install vim

And then continue:

cd nis-ncc
vim config-user.properties

Create one entry for nis.bootKey with your delegated private key. One entry for nis.bootName with your node’s public name and one entry for nis.shouldAutoHarvestOnBoot withthe value true.

nis.bootKey = 111111111111111111
nis.bootName = MySupernodeName
nis.shouldAutoHarvestOnBoot = true

Once you have made your changes press Esc and type the following to save and exit the file (using vim):

:wq
cp package/nix.runNis.sh nisStart.sh
vim nisStart.sh

We are going to limit the memory usage for NIS to 2800MB and change the paths. To edit press i:

#!/bin/bash

java -Xms2800M -Xmx2800M -cp ".:package/nis:package/nis/*:package/libs/*" org.nem.deploy.CommonStarter

Once you have made your changes press Esc and type the following to save and exit the file (using vim):

:wq
chmod +x nisStart.sh
./nisStart.sh

Let NIS run for a minute then quit it by pressing Ctrl-c. This will create the required folder structure for the next step.

cd

Visit http://bob.nem.ninja/ to check for the latest database dump url.

wget http://bob.nem.ninja/nis5_mainnet.h2-1680k.db.zip
apt-get install unzip
unzip nis5_mainnet.h2-1680k.db.zip
rm nis5_mainnet.h2-1680k.db.zip
mv nis5_mainnet.h2.db nem/nis/data/

1.4. Download and configure the servant

Visit http://bob.nem.ninja/ to check for the servant url

wget http://bob.nem.ninja/servant_0_0_4.zip
unzip servant_0_0_4.zip
rm servant_0_0_4.zip
mkdir supernode-servant
mv servant supernode-servant/servant
cd supernode-servant
vim config-user.properties

Create one entry for nem.host with your static IP or host name and one entry for servant.key with your delegated private key.

nem.host = 123.456.789.000
servant.key = 111111111111111111

Once you have made your changes press Esc and type the following to save and exit the file (using vim):

:wq
cp servant/startservant.sh servantStart.sh
vim servantStart.sh

We are going to limit the memory usage for the servant to 128MB and change the paths:

#!/bin/bash

java -Xms128M -Xmx128M -cp ".:servant/jars/*" org.nem.rewards.servant.NodeRewardsServant

Once you have made your changes press Esc and type the following to save and exit the file (using vim):

:wq
chmod +x servantStart.sh

1.5. Download and set up the supernode starter service

cd
wget https://github.com/PaulRieger/supernode-service/archive/master.zip
unzip master.zip
rm master.zip
chmod +x supernode-service-master/supernodeStart.sh
mv supernode-service-master/supernode.service /etc/systemd/system/
systemctl enable supernode.service

1.6. Set up a cronjob that deletes old logfiles

cd
crontab -e

Add the following entry to delete logfiles that are older than 30 days:

@midnight find ~/nem/nis/logs -mindepth 1 -mtime +30 ! -name 'nis-0.log.lck' ! -name 'nis-0.log' -delete  > /dev/null

Once you have made your changes press Esc and type the following to save and exit the file (using vim):

:wq

2. Run

reboot

Wait a few seconds, then:

ssh [email protected]

To see the log outputs, check:

tail -f nem/nis/logs/nis-0.log

and

tail -f nem/node-rewards/servant/logs/servant-0.log

If everything is set up correctly, you can visit YOUR-SERVER-IP:7890/node/extended-info to see information about your node.

3. Enroll your supernode

Send a NEM message to

NAFUNDBUKIOSTMD4BNXL7ZFE735QHN7A3FBS6CMY

with the following message:

enroll YOUR-SERVER-IP YOUR-NODE-NAME YOUR-DELEGATED-PUBLIC-KEY

Please make sure to send the delegated public key and not the private key that you used earlier in this tutorial.

Your node will show up at supernodes.nem.io after a few hours. If your node passes the last four tests during a day it will be included in the next rewards payout.

4. Update Guide

ssh [email protected]
cd nis-ncc

Remove the old package folder:

rm -rf package

Get the newest version:
Visit http://bob.nem.ninja/ to check for the latest nis-ncc url.

wget http://bob.nem.ninja/nis-0.6.96.tgz
tar -xvzf nis-0.6.96.tgz
rm nis-0.6.96.tgz

Reboot the node to restart everything:

reboot

If everything is set up correctly, you can visit YOUR-SERVER-IP:7890/node/extended-info to see if your node update has worked.


NEM Supernode Rewards Program
Supernode delegate account
Supernode NEM setup with Century Link http://clt.io but what next?
Installation use case testimonial
NEM Exchange Integration Guide
How to: Setup an Azure account for a NEM Supernode
NEM Supernode Rewards Program
How to Setup an Amazon AWS EC2 for a NEM Supernode
Can I run NIS from a webserver?
Update the node software
NEM Supernode Rewards Program
NEM Supernode Rewards Program
How to startup nis service in background and on reboot
How to setup a supernode after using nano wallet delegated harvesting?
Supernode advice
NEM Supernode Rewards Program
Few questions regarding setting up VPS for Harvesting
#2

Thx for this tutorial, Paul !


#3

Some suggestions:

  • swap might not work on every VPS
  • regarding NIS: it’s better to copy/create a start script + put the needed settings in config-user.properties, that way you don’t have to fix settings with every update…

#4

True, perhaps I should add that either the VPS should have more than enough RAM (e.g. 2GB) or one ought to make sure creating a swap file is possible. Is there usually a hint in the VPS description whether it’s possible or not?

So your approach would be to copy nix.runNis.sh and create a config-user.properties? Is NIS looking for such a file and if yes, where?


#5

The config-user.properties has to be in the same folder as the config.properties.
For a start script, just rename nix.runNis.sh to startnem.sh and then edit it. Thus the two files don’t get overwritten when updating to a new version.


#6

I’ve incorporated your suggestions in my latest edit.


#7

Updated to allow easy updates. The package folder in nis-ncc and the servant folder in supernode-servant can now be replaced without any problems.


#8

Hi, thx for good tutorial, I have ubuntu 14 server and it gives error “systemctl: command not found”, is there workaround?


#9

There’s a way to install systemd on 14.04: http://linuxg.net/how-to-install-and-test-systemd-on-ubuntu-14-04-trusty-tahr-and-ubuntu-12-04-precise-pangolin/

Otherwise you’d have to google how to enable a service using upstart which is the default daemon for ubuntu 14.04.


#10

Got my supernode up very easily, thanks :slight_smile:


#11

Thanks a lot for the good Tutorial! I had a bit difficulties in using vim, but I found a good help for me at http://netz10.de/2009/04/28/vi-crashkurs-fur-einsteiger/


#12

You’re not the first one to say that vim is a bit difficult to use, which is why I’ll add a comment that using nano is also an option.


#13

My Supernode already shows up, is there a NEM Account i can Tip you? I never would have done this alone…


#14

Awesome! I’ve also added your link to the German tutorial in my latest update. If you want to tip me: NCL5QL-N2GDBW-EUSIBP-7G7BMC-I6IAEN-G66YPX-B3MA


#15

is the Digital ocean $20/month droplet sufficient?


#16

Yes, that should be fine.


#17

My SN is still failing the computing power tests. Can you tell me where to find the servant log and how to copy it via ssh? Or do I have to activate logging first?


#18

You can download the log files via the terminal:

Current servant log:

scp [email protected]:nem/node-rewards/servant/logs/servant-0.log ~/Downloads/

Current nis log:

scp [email protected]:nem/nis/logs/nis-0.log ~/Downloads/

#19

hmm, it says “permission denied” but I´m logged in as root?

Edit: wrong command copy… now looks like it worked, (“100%, 20kb”) but I can´t find it in download directory.


#20

Do you use OSX? If yes the file will be in your download folder if not you’ll have to adjust ~/Downloads/ to something that makes sense on your system.