Running a NEM Node on a Raspberry Pi


#1

#Running a NEM Node on a Raspberry Pi

Introduction

Running a NEM node on the network does not require a huge amount of computational power. Because NEM uses POI rather than POW we can run a node on some of the most basic of hardware.

In this post I will show how to setup a NEM node on a Raspberry Pi 3.
By running a node we can contribute to the network and harvest from this node, you can even share the nodes address or name with your friends and they can harvest on it too.

Setting up the Pi

To get the Pi working and ready for the NEM software we will need to first prepare it by installing a few different preresiquites.

Depending on how you got your Pi you may have more or less steps. If you received it without a preloaded OS you will need to install Raspbian to get the Pi working. Link to setup reasbian

They main things we need are Java for NIS and IceWeasel if you intend to run Nanowallet on this Pi also.

Java Installation

The first thing we will need is Java. If you have the noobs os preloaded you will have this and can skip ahead, if not you will need to run the following commands into terminal:

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  
NIS installation

We have two options for installing the NIS client and this will depend on how you are accessing your Pi. I prefer to access mine via RDP and prefer that over SSH when the host comp can handle it. To accomodate those who prefer SSH I will list both ways with the RDP route being a better option if you prefer a GUI or if you dont like doing everything through terminal.

Installation through RDP

First we will need to set up with RDP itself as it does not come pre installed. To do this enter into your terminal :

apt-get install xrdp  

To connect to our Pi we will need an RDP client. I personally use Microsoft Remote Desktop but any RDP client will work.
Once you have your client of choice you will need to set up new credentials with RDP.

example setup

If all has gone to plan you should now be shown a GUI of your pi desktop on your other computer.

Now that we have access to the Pi you will want to download the latest package of NEM from Nem.io. The standalone client will be the best one for our Pi.

Before starting to sync the chain you may want to provide a name for your node and also set up harvesting. You can do this by navagating to the nis folder and editing the config.properties file. There are 2 important changes will will want to make

nis.bootkey =  
nis.bootName = 

Remove the # characters and provide the private key of our delagated harvester and also the name we will want to give our node for these values.

Continue to Preparing for delagated harvesting.

I would recommend you also set up SSH and try to ssh into your Pi to verify everything is working and you have the correct IP.

Installation through SSH

SSH allows us to modify and run tasks remotely on our Pi through the command line. If you are not running raspian/linux on your Pi you will need to install wget.

sudo apt-get install wget

Due to the NEM version changing now and again please insert the latest stable version inplace of the ‘v’.
The current version is 0.6.87.

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

Before starting to sync the chain you may want to provide a name for your node and also set up harvesting. You can do this by navagating to the nis folder and editing the config.properties file. There are 2 important changes will will want to make

nis.bootkey =  
nis.bootName = 

Remove the # characters and provide the private key of our delagated harvester and also the name we will want to give our node for these values.

Nanowallet Setup

Although not a requirement, the nanowallet is a very good choice for a low memory device like the Pi if you want to check your balance or do things with your XEM and doesnt require a full resync of the chain to do things.

To use Nanowallet you may need to install Iceweasel for Firefox in order to use it. If your Pi came with a copy of Noobs you may be able to use the wallet in the Chromium browser however you might see some performance issues.

You can download the nanowallet from this website

##Preparing for delagated harvesting
Before we set up our node fully we will want to set up delagated harvesting and have a delagated private key ready. This step can be done last however you will need to stop NIS, setup harvesting and restart NIS which will require loading the blocks again.

If you dont intend to set up harvesting and simply want to add a node to the network you can do so.

To start delegated harvesting firstly navagate to the nis/lightwallet folder and open the start.html. You can then add your normal NEM address to this using the private key.

Once in head to the Services and Manage delagated account, and from here you can activate delagated harvesting.
Select the mode activate and enter password to submit. Activating delagated harvesting will cost 6 XEM and will take 6 hours to complete.

After this, you may be able to see your delagated account key on the right hand side.
Copy the delagated private key which is just below the Delagated public key behind a password prompt.
We will be using this as the bootkey of our node rather than use the private key of the address which has our funds. (the beauty of delagated harvesting).

From here if you want you can start harvesting on another node if you if dont want to harvest on your own node.

Please see this article for more info on Delagated Harving

Starting a NEM Node

Before starting NIS please ensure you have entered the private key of your harvester if you are planning to harvest yourself. Delagated harvesting is recommended for better security of your funds.

Once you have named your node and added harvesting details you can run NIS and start to sync the chain by entering:

./nix.runNis.sh

If you like you can sync the chain manually but this will take quite some time. An easy way to get the chain faster is to navagate to this database store and load that instead of syncing the chain manually. To do this download the blockchain file and paste it in your nem/nis/data directory and this will help reduce the time needed to get up and running.

pic of nis loading
Once the NIS command has been run, the blocks from the DB will need to be loaded into memory and will initially see a lots of terminal commands showing the progress of the load. When this finished you node will be running and live!

At this point you may see messages saying harvesters are attempting to harvest a block , this will be an indicator that you set up harvesting successfully.

Getting the most from your pi

Initially I had some doubts I would be able to get both NIS and NCC running on the Pi. NIS by default uses 1gb of ram however we can change this value if we are slightly limited or want to run NCC by its side. Right click the nix.runNis.sh file and open it in a text editor and changing the

flag to something like

While this will work , it will be a little slow so it is recommended to just run NIS as is in order to keep heat low and avoid a possible crash of NIS while your not monitoring it.

Seeing your node live

While this wont happen straight away, after your node has synced and is live for some time it will then show up on the nem nodes website with the node name you provided in the config.properties file.

NOTE to have your node public and on the nodes list you will need to log into your router and enable port forwarding on port 7870, if you do not do this the node will still work but it will not show on the node list.

Conclusion

The Pi was a really good resource for setting up the Node and I am suprised at how well it is handling the strain. On average I am seeing 4-17% CPU usage while the node is running and the Pi harvests 24/7.

The pi is suprisingly cool while it is running, it did get hot while syncing the chain but this is to be expected, now that it is synced and running it has been going for a few days now with minimal heat.

It is definetly a viable option for a NEM node and offers possibly the most cost effective option for a ‘roll-your-own’ nem node.

References

For this tutorial I have referenced some parts from the supernode command line tutorial as it is what I used myself when stuck
link to supernode tutorial


How to setup a node on Raspberry
#2

Reserved


#3

Great stuff! I’ve just recently set up a Pi 3b node too, so I hope you don’t mind my adding a couple of notes.

I was initially having issues with the launch script starting NIS with too much RAM given over to it, which resulted in the JVM processes being killed by the kernel after a few hours (as logged in /var/log/kern.log), but reducing the max memory flag to -Xmx768M seems to have done the trick. htop shows RAM maxing out at about 856MB after running the node for ~6 hours (though it does also seem to use a little of the swapfile).

I’ve also dropped the amount of shared graphics RAM down to 16MB using the raspi-config tool, from the default 64MB, as I run it headless with no special graphics requirements/environments.

Finally, I’m a fan of using the process manager Supervisor to daemonise and automatically start/restart NIS, as it also gives you a web panel to manage processes. Handy to be able to see this on the network without needing to ssh in to the Pi.


#4

Thank you for your guide. I’m still not understanding everythin though.

What do you do after “downloading the standalone client package from NE.io/install” and before “starting to sync the chain”

Seems like some missing steps. Do I put the folder somewhere? Do I need to open a specific file? How do you start syncing?

Thank you again.


#5

Let’s suppose I had delegated harvesting turned on for some remote node, not on my network. Now I want to switch from the remote node to an instance of .nis running within my local network.

How would I do that?

Do I have pay 6 NEM to deactivate the original remote harvester?

I really dislike NEM because it is needlessly complicated and obscure. And it just chews up fees.

And yes, I have scoured for guides and they are all pretty mediocre and incomplete.


#6

The 6 XEM is a one-time fee. You pay nothing to deactivate and switch to your own node.


#7

Turns out, that is not the case. I was running NIS and NCC and when I went to NCC to deactivate, I was indeed charged 6 NEM (as of yesterday, Sunday). Now if that isn’t the case under the Nano light wallet, fine and dandy. But that is not how it worked with NCC. Your information is inaccurate, but I don’t really blame you for that.

I would also note that while NIS 0.6.93 worked just fine (after changing the path environment for Java, which is not really covered in any NEM tutorial that I have seen), NCC 0.93 refused to work at all. Sure, it was “deprecated” in early July, I guess. So I had to go back to NCC 0.6.87 - and you cannot switch delegated remote nodes without paying a fee in NCC 0.6.87.

And why did I use NCC at all?

Well, one has to convert one’s NCC wallet in a convoluted process into a new format recognized the NanoWallet. I"ve owned NEM for about 10 months and during that time it has changed radically, the documentation has not kept up, and it remains way too complicated for most people to adopt. I delegated mining for over 12,000 NEM back in April. As of yesterday, not a fraction of one reward earned, which is why I wanted to cancel the delegated harvesting.

The entire NEM model seems doubtful. They have moved away from local mining rewards to pushing delegated mining. And who benefits the most from that?


#8

I’ve only ever used Nano, but a quick search shows that due to the difference in the wallet systems between NCC and Nano, you do indeed need to spend 6 XEM to deactivate via NCC before restarting with Nano.

Did you see these posts?


#9

hi, i am getting the following error

./nix.runNis.sh no such file or directory

i am running this at the command prompt

[email protected]:~ $ ./nix.runNis.sh

Could you do an updated version of this As the file types seem to have changed see below list: which on should I use.

Name Last Modified Size Type
Parent Directory/ - Directory
.well-known/ 2017-Jul-06 20:10:57 - Directory
beta-testnet/ 2017-Jul-06 19:59:33 - Directory
bin/ 2016-Jan-29 12:06:37 - Directory
docs/ 2017-Mar-20 20:37:38 - Directory
installer/ 2017-Jul-30 16:40:10 - Directory
last-ncc/ 2017-Jul-30 16:40:10 - Directory
org.nem.core/ 2017-Jul-30 16:35:20 - Directory
README.txt 2014-Jul-28 23:15:37 1.8K text/plain
lightwallet-standalone-1.8-cdn-nginx1.8.zip 2016-May-16 20:33:09 1.3M application/zip
lightwallet-standalone-1.8-cdn-nginx1.8.zip.sig 2016-May-16 20:33:11 0.2K application/pgp-signature
nis-0.6.93.tgz 2017-Jul-30 16:35:18 25.1M application/x-gtar-compressed
nis-0.6.93.tgz.sig 2017-Jul-30 16:35:18 0.1K application/pgp-signature
nis5_mainnet-1002k.h2.db.zip 2017-Feb-28 19:19:56 290.0M application/zip
nis5_mainnet-1002k.h2.db.zip.sig 2017-Feb-28 20:51:20 0.1K application/pgp-signature
nis5_mainnet-1129440.h2.db.zip 2017-May-28 17:53:42 332.1M application/zip
nis5_mainnet.h2-1252k.db.zip 2017-Aug-22 18:46:22 398.2M application/zip
servant_0_0_4.zip 2016-Jun-01 11:02:45 10.0M application/zip
servant_0_0_4.zip.sig 2016-Jun-01 11:03:31 0.2K application/pgp-signature
test.json 2015-Apr-21 22:32:29 0.1K application/json
version.json 2017-Jul-30 16:35:20 0.1K application/json
version.txt 2017-Jul-30 16:35:20 0.1K text/plain
version_p.js


#10

Did you use the right directory ?
It should be… "~NEM/0.6.93/package/ " on your prompt. Then run " ./nix.runNis.sh " .

You download the " nis-0.6.93.tgz " and go in the directory(only NIS).

Only for the wallet use the NanoWallet from the NEM Website.

When you use “nis-0.6.93.tgz” and you will load the db faster use " nis5_mainnet.h2-1252k.db.zip 2017-Aug-22 18:46:22 398.2M " and after unpacking , copy(change) the db in your home/…~/nem/nis/data/…


#11

HI thanks for the reply. I have downloaded nis-0.6.93.tgz to the downloads folder - where should this folder go?

I dont have ~NEM/0.6.93/package either and I dont see where you created the ~NEM

not sure if i have nix/ either

UPDATE:

solved,

wget https://bob.nem.ninja/nis-0.6.93.tgz

tar -xvzf nis-0.6.93.tgz

rm nis-0.6.93.tgz

mkdir nis

mv package nis/package

Then before I could type the comand:

./nix.runNis.sh

I had to type at the command prompt

[email protected]:~ $

cd / home/pi/nis/package

then I could type

./nix.runNis.sh

oddly enough after runing the code I went back to file manager and the NEM folder appeared - I could also see the database file. weird?

hope this helps others.

one final note.

nis.bootkey =

in the config file it is written as

#nis.bootkey = #delegated private key

If we are NOT harvesting can this be left as it is.

if we DO harvest - Then both # have to be removed?


#12

Hi,
sorry, when I ask. What is the reason for you to run this NIS ?
Your own NIS for your NanoWallet ?

The “nis.bootkey” is for harvesting run directly in your running NIS. Then you remove " # " and provide your delegated privat key in this field.
And then you should give your NIS an Name(nis.bootname), so you can see your NIS in nembex after a short time…

PS: We all have a bit different ways(folders) to install software.


#13

hi, I am only providing a node at the moment to help verify transactions on the network. I am aware about putting my private key and node name in for harvesting. my nano wallet is run on a different pc. I’d not have got this far without your initial guide thou.


#14

Not your privat key…your delegated private key ------it´s different and very important


#15

Did you open the port 7890 ?


#16

Yeah…Delegated private key.


#17

Yes port opened. Node is off at the moment planning on running tomorrow.

Out of interest opening port 7890 does mot leave the rest on my home network at risk does it?


#18

Everyone see your IP, have a look at nembex. Every Node with IP.


#19

Your own risk.


#21

HI, I am looking to get the node to run from Boot up. I am using systemctl to run the command to do this but I don’t understand the file structure of ./nix.runNis.sh I can point the the file location upto /packages but getting stuck after this.I have tried:

 packages ./nix.runNis.sh
 packages/nix/runNis.sh
 packages/runNis.sh
 packages ./nix/runNis.sh

neither of these formats seem to work, I don’t know if the file structure is too deep. But some examples or using the systemctl seem to work when the extension is /filename.sh. and not ./filename.othername.sh