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:
- https://www.hetzner.de/ot/hosting/produkte_vserver/cx10
- https://hostus.us/openvz-vps.html
- https://lowendbox.com/blog/hostus-7month-2gb-openvz-leb-exclusive-in-hong-kong-and-sydney-and-more/
- https://www.digitalocean.com/pricing/
1. Installation
You will need to access your server as the root user:
ssh root@YOUR-SERVER-IP
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 root@YOUR-SERVER-IP
. 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.97.tgz
tar -xvzf nis-0.6.97.tgz
rm nis-0.6.97.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 root@YOUR-SERVER-IP
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 root@YOUR-SERVER-IP
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.97.tgz
tar -xvzf nis-0.6.97.tgz
rm nis-0.6.97.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.