Updated EDITED Raspberry pi Masternode setup


#1

Extra notes:
download the x32 arm version for a raspberry pi

blockchain snapshot:
http://178.254.23.111/~pub/PIVX/Daily-Snapshots-Html/PIVX-Daily-Snapshots.html


setup a swap file to increase the ram for your RP:

You have two options in doing this.
You can setup swap as seen below OR setup swap using zram.
I would recommend using zram. Setting up a normal swap on your sd card, which will be used 24/7 will most likely limit the life of your sd card on your raspberry pi.
ALSO, if you can afford the investment, I would recommend getting an A1 rated sd card. A normal SD card should be good enough with the zram, but the A1 card should work even faster These cards are made for running apps on them and can handle the swap much better than a regular sd card. Unfortunately setting up a swap in needed. The newer versions of PIVX are more memory intensive than what a RP can handle.

To create a swapfile on your Raspberry Pi you can use the following commands:

  1. sudo su -c ‘echo “CONF_SWAPSIZE=2048” > /etc/dphys-swapfile’
  2. sudo dphys-swapfile setup

After creating the swapfile, you have to activate it once by using this command:

  1. sudo dphys-swapfile swapon

EDIT 4/28/17: I have had to make some tweeks recently to make sure my MN is stable while on a Raspi. Against my own guide, I wouldn’t recommend running the masternode on a Raspberry pi with PIVX-QT. Having the raspberian GUI OS running takes up a lot more RAM than running the pivxd program in headless mode (or just having the RP terminal running).

I had the problem of my pivx-qt program just shutting down randomly on my RP. This was due to lack of ram. Highly recommended that you run the MN in headless mode or terminal only (with the raspberian GUI disabled and only the terminal running). You can switch over to having the raspberry pi running only in terminal by running the code “sudo raspi-config”. Go down to boot options and selecting desktop/cli, then select console.

Another tweek I made is setting the max connections = 8 in the raspberry pi. The original guide by AdminPIVXmasternode recommends 24, I have been told by support that even 8 is fine. This will help ensure that you do not get so many connections that it will eat up your RAM and crash your MN server.

If you are having this same problem of your PIVX prog randomly shutting down and you don’t know why. Highly likely that it is due to RAM shortages in your rasp pi. Raspi3 had 1gb of ram and that is fine, but it is just barely enough if you have the pixel GUI also running or other programs running. To check your memory usage, run the command “free” in your terminal before starting pivx and after running pivx for awhile. You will most likely see your mem being nearly full, and possibly seeing the swap starting to get used. If the swap is used at all, your RAM is full.

In short, the few edits I’ve made to this guide include:

  1. Towards the bottom on my guide i added a section that shows you how to start your RP in terminal only mode
  2. Set maxconnection on the pivx.conf file on the RP to 8.

I have made these changes and my MN has been running smoothly for 10 days now without any problems. I will happily update this guide again if I experience any issues.


This guide is a edited version of “Raspberry pi masternode setup” written by AdminPIVXmasternode. See the original guide by AdminPIVXmasternode here:
Ht tps:// pivxmasterno de.or g/2017/03/14/rasp berry-pi-masternode-setup/

(there are multiple spaces where the links are at because new users can only post 2 links max)

I have written this edited guide to:

  1. Consolidate multiple guides.
  2. Remove the need for an SSH client
  3. Fix small errors and holes in the guide.
  4. Make it more noob friendly :slight_smile:

This is an effort and attempt to pull together the guides and consolidate them into a complete guide (at least for raspberry pi masternode). I’d love feedback so we can add it into this guide and bring the PIVX masternode community an easy to follow complete guide. Some of this guide is a copy and paste from AdminPIVX masternodes’ guide.

This guide is intended for people that understand at least some computer/networking basics. To begin this guide you must have already imaged an sd card with raspbian and have it connected to your router via ethernet. You may use wireless as well but you will need to connect it to your wireless network first as this guide will not cover that. This also currently only deals with setting up the raspberry pi masternode from a Windows computer. All commands that are to be entered will be surrounded by “ “ be sure to not include them when typing in commands. This is a work in progress, use at your own risk.

Before starting, this guide already assumes you have downloaded and installed the PIVX wallet on your windows machine.


A) Funding your masternode

Starting on your windows machine

  1. Open up notepad

  2. Open your wallet and make sure it is fully synced

  3. Go to Tools > Debug Console

  4. Type the following commands and execute separately:
    a. “masternode genkey”
    (This will be a long string of letters and numbers, copy it to notepad and label it MASTERNODEPRIVKEY)
    b. “getaccountaddress NAME”
    (Replace NAME with whatever you want to call this address i.e. MN01)

  5. Send 10,000 PIVX to the address you just created
    (It must be EXACTLY 10,000 PIVX so send it as Zero fee and disable any fees it has to be exactly that amount)

  6. Now is a good time to make sure your wallet is encrypted and create a backup of your wallet

  7. After the transaction has been confirmed go back to the debug console and run
    a. “masternode outputs”
    b. Copy the result to your notepad and call it Masternode Output


B) Networking

– To begin you must have your Raspberry Pi plugged into your router (or connected via wireless) and powered on.

  1. From your computer open the cmd prompt and type “ipconfig”

  2. You are looking for Gateway in the results
    (For most people this will be 192.168.0.1 or 192.168.1.1)

  3. Open up a web browser and type the IP address for your gateway

  4. Log in to your router
    (The username and password might be on a label on your device, otherwise you can google what the default credentials are)

  5. Find the menu for DHCP
    (Typically this may be under a section called LAN)

  6. You will need to find the IP address of your Raspberry Pi
    (Make a note of this IP as it will be needed to access the device)

  7. Look for an option to add a DHCP reservation and create one for the Raspberry PI using its existing IP address

  8. Find the menu for Port Forwarding
    (htt ps:// portfo rward. co m/ Find your router make and model on this site and it will tell you how to forward a port)

  9. Add a rule for port 51472 going to the IP of your Raspberry Pi

  10. Log out of your router

  11. Go to ht tp://w ww.whats myi p.o rg/ to find your external IP address, save this in your notepad with everything else
    a. A note about external IP addresses, many ISPs set residential modems to a dynamic address so there is a chance the address you have now could be something different after a period of time. If it does change you will need to update the pivx.conf file that is created later on otherwise your wallet will not be able to communicate with your masternode if it changes.


C) Raspberry Pi configuration

  1. On your Raspberry Pi, go into the command terminal (at the top of your raspberry pi desktop screen)

  2. Type “sudo raspi-config”

  3. Go into “boot options” then “Wait for Network at Boot”
    (Make sure this is enabled)

  4. Go into “advanced options” then “Expand Filesystem”
    a. This will reboot your pi once it’s complete (NOTE: if you are already running NOOBs on your raspberry pi, this option is already done for you).

  5. Reboot your raspberry pi.

  6. Back in the command terminal: run “sudo passwd” to change the root user password
    (Pick something long and complex)

  7. Reboot your raspberry pi and this time with the following credentials:
    a. Username: root
    b. Password:

  8. Now we will change the pi username to something different, replace NAME with whatever you pick
    a. “sudo usermod -l NAME -d /home/NAME -m pi”
    b. “sudo chown NAME /home/NAME”

  9. Reboot raspberry pi and connect again this time with your new username

  10. Run the following commands:
    a. “sudo apt-get update”
    b. “sudo apt-get upgrade”
    c. “sudo apt-get dist-upgrade”
    d. “sudo apt-get install libtool autotools-dev autoconf libdb-dev libminiupnpc-dev dh-autoreconf libdb+±dev libboost-all-dev libssl-dev pkg-config joe ufw protobuf-compiler libprotobuf-dev libqt4-dev”

  11. Now we will configure the firewall to only allow ports 22 for SSH and 51472 for the masternode (if you dont want to use SSH, im not entirely sure if this is necessary).
    a. “sudo ufw allow ssh/tcp”
    b. “sudo ufw limit ssh/tcp”
    c. “sudo ufw allow 51472/tcp”
    d. “sudo ufw logging on”
    e. “sudo ufw enable”
    f. “sudo reboot”

  12. After a few minutes, reboot the raspberry pi and check the status of the firewall
    a. “sudo ufw status”

  13. It should say active

  14. On your raspberry pi, download the Raspberry Pi wallet from pivx.org
    a. Extract the files from the ZIP

  15. Create a new folder on the Raspberry Pi called .pivx. Create this folder ideally in the /home/YOURUSERNAME folder
    a. Open the .pivx folder so you can copy files into it

  16. Open the folder that you just extracted from the ZIP

  17. Copy all files from the ZIP folder into the .pivx folder (that you just created)

  18. We will need to run a few commands in the command terminal:
    a. “cd .pivx” (changes the directory from home/YOURUSERNAME to home/YOURUSERNAME/.pivx folder)
    b. “chmod 777 ./pivxd”
    c. “chmod 777 ./pivx-cli”
    d. “chmod 777 ./pivx-qt”

  19. Now in your raspberry pi open up notepad and paste the following:

rpcuser=XXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
rpcallowip=127.0.0.1
listen=1
server=1
daemon=1
maxconnections=8
masternode=1
externalip=XXX.XXX.XXX.XXX
bind= XXX.XXX.X.X:51472
masternodeaddr= XXX.XXX.XXX.XXX
masternodeprivkey=XXXXXXXXXXXXXXXXXXXXXXX

  1. rpcuser and rpcpassword need to be replaced with a long string of ONLY letters and numbers, make it something long and random

  2. masternodeprivkey will be the string that was generated from your wallet

  3. externalip AND masternodeaddr is your external IP address (wha tsmyip.o rg)

  4. bind is the local address of your raspberry pi on your network based on STEP 6-7 of the “networking” section above”, also remember to add the port # 51472. (example: 192.168.X.X:51472)

  5. Save this notepad file. We will need it later. (it will be the pivx.conf file)


D) Starting PIVX

  1. Before starting your pivx-qt program (on your raspberry pi) in your .pivx folder, first we will need to download the latest blockchain files (for the quickest results).

  2. You can download the “pivx_blockchain_backup-xxxx.zip from here: htt p://gi th ub.c om/PIVX-Project/PIVX/releas es

  3. Download this zip file and extract the files. You should have a “blocks” and “chainstate” folder from the zip file. Copy and paste these folders into your .pivx folder.

  4. Start your pivx-qt program in the .pivx folder and it will start the sync the blockchain. Wait until this entire process is done.

  5. Go to your .pivx folder and open pivx.conf file in notepad.

  6. Copy and paste everything from the notepad file you created in the raspberry pi configuration section (step 19-20) into this pivx.conf file.
    (Be sure all of the X’s have been replaced)

  7. Back on Windows computer we will now need to edit the masternode.conf file

  8. Open up %appdata%\PIVX\ to find masternode.conf and then open the file to edit it (or where ever you have all your pivx files at). Add the following line at the bottom:

LABEL IP:PORT MASTERNODEPRIVKEY TRANSACTIONHASH INDEX

i. LABEL : can be whatever you want to label this masternode
ii. IP : the external IP address that you put into the pivx.conf file (the same ip as externalip and masternodeaddr in the other file).
iii. PORT : 51472
iv. MASTERNODEPRIVKEY : the same private key you put into the pivx.conf file
v. TRANSACTIONHASH and INDEX : This was saved earlier when you ran masternode outputs in the wallet (the index number is usually a single digit number, usually 0 or 1 to my knowledge).
(Save the file)

  1. Go to the pivx.conf file on your windows computer and open it in notepad.
    Type the following into the file and save (the RPC user and password should be the same as the other pivx conf file you made on your raspberry pi):

rpcuser=XXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXX
rpcallowip=127.0.0.1
listen=0
server=1
daemon=1
logtimestamps=1
maxconnections=256

  1. Restart your wallet if it is currently open

  2. Back on your Raspberry Pi, open your PIVX-QT program and let it sync and fully open. In the command terminal of the raspberry pi, we will check the status of the masternode sync
    a. “cd .pivx” (to get into the .pivx folder)
    b. “./pivx-cli mnsync status”

i. “IsBlockchainSynced” : should have a value of True, if it says False you will need to wait until the results of mnsync status say True
ii. Depending on your internet connection this may take a few hours or overnight but you will need to wait for it to finish before moving on
iii. Just rerun the command to check the sync status

  1. Once the blockchain is synced you can go to the Masternodes tab of your wallet on your windows computer and you should see your new masternode in there.

  2. In your windows controller wallet, go to the debug console (tools>debug console) and type in (startmasternode “many” lockwallet) without the ()s. This will start your masternode. It should say “result” : “successful” if it worked.

  3. check the status of your masternode as well in your raspberry pi by typing the command:
    a. “./pivx-cli masternode debug” (need to “cd .pivx” first).
    b. The result should say Masternode successfuly started
    NOTE: sometimes there is a lag from when you remote activate and when masternode debug will confirm that it successfully started. Wait 5-10 minutes and usually it will say started.

c. You can also check the status of the masternode on your raspberry pi by typing “./pivx-cli masternode status”.
15. You can close out of your wallet at this point on windows, it doesn’t need to stay open for the masternode to run.
NOTES – It will take anywhere from 3 – 5 days before you start to see payouts from the masternode, the more masternodes on the network the longer it will take for a payout.


Now to setup the raspberry pi so it only runs in terminal mode (therefore saves ram from the GUI pixel OS running)

  1. go to the RP terminal and type in “sudo raspi-config”

  2. Choose “boot options” --> “desktop/cli” --> “console”

  3. exit and save. Reboot.

4.You will now start your RP in terminal mode only.


In the future if you ever want to start your masternode, just:

a. turn on your raspberry pi

b. “cd .pivx” (to get into the .pivx folder)

c. “./pivxd” ( to start the client and get the blockchain to start syncing.

d. “./pivx-cli mnsync status” to check the status of the blockchain sync.

e. “IsBlockchainSynced” : should have a value of True, if it says False you will need to wait until the results of mnsync status say True .Depending on your internet connection this may take a few hours or overnight but you will need to wait for it to finish before moving on. Just rerun the command to check the sync status

f. Once the blockchain is synced you can go to the Masternodes tab of your wallet on your windows computer and you should see your new masternode in there.

g. In your windows controller wallet, go to the debug console (tools>debug console) and type in (startmasternode “many” lockwallet) without the ()s. This will start your masternode. It should say “result” : “successful” if it worked.

h. check the status of your masternode as well in your raspberry pi by typing the command:
“./pivx-cli masternode debug” (need to “cd .pivx” first).

i. The result should say Masternode successfuly started.
NOTE: sometimes there is a lag from when you remote activate and when masternode debug will confirm that it successfully started. Wait 5-10 minutes and usually it will say started.

j. You can also check the status of the masternode on your raspberry pi by typing “./pivx-cli masternode status”.

No need to have the wallet open on your windows computer.

For real time help or questions, I would recommend going to the PIVX slack channel.

Hope this guide is a little easier and clears up some confusion that others are having when setting up a masternode. Let’s build a community that helps each other and grows together as one.


#2

Hey,

first of, thanks for your guide!
I’ve been running a masternode with raspbian and pivxd for a few days and suddenly it stops working.
I pretty much followed your old guide.

When it has crashed once, I cannot start the node again… After I enter ./pivxd and do something like ./pivx-cli masternode debug I get :“error, couldn’t connect to server”. The external and LAN IP of my pi hasn’t changed. Also the pi is running just fine otherwise.

You mentioned the memory error… but is there any workaround? Is the qt solution more stable? In my country energy is very expensive, so I’d really like to run it on a Pi3.

Thanks!


#3

Hey! That is a very common problem. It usually has to do with the blockchain being corrupt. I would recommend looking at other forums to see what people do when the blockchain becomes corrupt. From my experience, what I do if that happens is:

  1. Delete the blocks and chainstate folders in my pivx folder.
  2. Search online or on the forums to download the latest blockchain files and replace them in your folder.
    The other option is to let the blockchain resync, but that takes along time.

Hope this helps and go on the pivx slack channel for real time help. They are very responsive and this is a very common problem. I will be updating my guide in a couple weeks when I figure out if my changes work.

As mentioned in my edit, the qt version really won’t work on the rasp pi. Qt + the graphic user interface (gui) of raspberian takes up too much ram and will eventually keep crashing.

I’ll update when I work out and test everything myself.


#4

Hey, thanks again for your reply.

I figured out that renewing the blockchain data does help. But this is a lot of manual maintenance and puts my Pi3 out of business for too long. I’ve run it several times for ~3 days now and then it got stuck so I never received a reward :(.

I will try my luck on slack and come back here too.

Keep it coming.


#5

Exactly. I’ve been having the same problem. If your MN keeps crashing and then when you start it back up and theres this problem again, its highly due to lack of RAM. Please see my edits in the beginning of this post to check if lack of RAM is the issue. I have a RP3 and running the GUI +QT is not enough RAM. If you have the RP GUI running at all, usually that is eating up most of the RAM. the RP GUI takes up around 200mb of ram more than just running in headless mode. I will help more and update my guide in a week or two when I know if my fixes work or not. Right now, I’m in the same process as you trying out fixes and seeing if they work or not. Pretty sure lack of ram was my problem though.


#6

Have you thought about simply rebooting the Pi like every day? I think the node keeps on running and will be valid if it is offline for a minute.

I just upgraded the software to 2.2.0 (Rpi2). Rpi3 won’t run for some reason on my Pi3 Model B.

Let’s see how it works…


#7

That definitely would solve the problem, but is a chore to do. I want to get to the point where I set my Rp3 and leave it /forget it, as I’m sure most people want that too because not everyone has access to their rp3 everyday.

Patience, I’ll update in a week or two. Ram is the problem for sure but testing ways to fix that.


#8

Im have problems even installing the wallet on the raspberry. i have never installed an app outside of ubuntu software center before, care to detail how to do it? i have downloaded and opened the tar.gz file for raspberry pi 3. I would highly appreciate any help


#9

Also, yeah, from my understanding the rp3 version won’t work if you’re running raspbian. The rp2 version of 2.2.0 will work with raspbian though. I’m running that version too :slight_smile:

@soundrejp I’d recommend going on the pivx slack channel for someone to help you in real time. If you’re using raspbian, no need to install anything. I unzipped the folder and ran the PIVX-qt for the wallet.


#10

@xwmgsdbzwx and @soundrejp, I got the daemon to work on my RP3, but when I verify my Masternode status, it still says “false”. Now I’m wondering if I need to completely rebuild from scratch my Masternode blocks and chainstate (similar to how I needed to on my PC controller wallet when we changed from version 1.6 to 1.7. It took about 40 hours).
Did you guys need to completely rebuild your Masternode wallet blocks and chainstate? And, if so, is it possible to simply cut and paste the blocks and chainstate from my PC over to my RP3 wallet? Thanks for any input you can provide!


#11

Hello! Yes, sometimes you will need to delete the blocks and chainstate folders. I’m not sure where to find them, but I usually just download those folders online then it takes very little time to resync. That usually solves many problems people sometimes have of opening the wallet.


#12

Also 2.2.0 is out. Its a mandatory update


#13

Hey guys,

I just got an ASUS Tinkerboard (Rpi clone with a better CPU and 2GB RAM) and just started running the masternode there. I’ll come back to you with results in a few days.


#14

Nice! I think that should be plenty of ram for the job. I just got back from the weekend and checked my MN, still up and running, but I’m starting to see my swap being used in my memory. I’ll wait until the end of the week to see if my MN stays up before I update my guide, but I’m pretty sure my tweeks are working or at least helping alot because this is the longest ive had my MN up and running.


#15

Hey all,

Updated the guide. Please read the top of the guide for the couple edits I have made. With these changes of setting the max connections to 8 AND running my raspberry pi in terminal only mode, the pivx program has been stable for the past 10 days. I will update if I experience any more issues, but it looks like my problems have been fixed.


#16

Hey,

want to give some feedback on the Tinkerboard. I’m now running 2.2.1 and the Tinkerboard keeps on destroying the blockchain so you have to sync all over again. I wouldn’t recommend the Tinkerboard as it’s software is way more clunky than the Pi3’s and you’ll run in to all kinds of trouble. I’ve given up at this point and I am running my node with a windows computer. Such a shame that the pivx client is buggy as hell. In comparison, Decred staking runs super smooth on a Pi for months.

I’m currently retrying the max connections 8 guide from xwmgsdbzwx.
Is your node still running?


#17

@xwmgsdbzwx I have followed the guide to the letter, but i am receiving an error message reading “invalid IP address” in my PIVX wallet on my windows machine. The masternode is synced on the pi, but i’m unable to “start alias” on my windows machine due to the connection issue. I have a TP-Link TC-W7960 modem router which might be the culprit since it seems DHCP reservations cant be made. I tried to circumvent this problem by assigning my pi a static IP address but that didnt work either!!! ANY SUGGESTIONS???


#18

Hey :slight_smile: yep, node still running, haven’t had any issues


#19

Ah, I’m not too sure. I don’t know networking enough to know if there’s a work around and i’ve only tried this guide down to each detail. If anyone else that knows networking could help him out or provide an answer, it would be much appreciated!


#20

thanks for the response