#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.
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.
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