Masternode on Raspberry Pi 2 Model B

  • 2 Replies
  • 1154 Views
*

chris

  • Globaler Moderator
  • Full Member
  • *****
  • 154
  • +11/-0
    • View Profile
Masternode on Raspberry Pi 2 Model B
« on: 09. March 2016, 07:56:31 »
NOOBIES GUIDE GETTING A MASTERNODE TO RUN ON A RASPBERRY PI 2 MODEL B

This Guide is a rewrite from a DASH User. Regard Christian


WHY?
A week, ago my Raspberry pi 2 arrived and was delighted to finally get a masternode run on it, instead of hosting it at a VPS(thx for that Flare).
It all went well and its running as i write this. With help of various people by mail and on the forums I decided to contribute to write a howto tutorial with all the new stuff i have learned.


NEEDED KNOWLEDGE?
Almost no prior knowlegde. As a windows-boy i know my way around pc's except hardcore coding n stuff. Ive been playing around in Ubuntu as well in a virtual machine just to see what it means to run a linux distro. Im classify myself as a linux noob. So if i can do it, you can do it too ;)

This guide can be written way more more compact but didnt do that on purpose for you to follow easily. I made it the most no-brainer i could.

"Like warm raspberry pi"

MY SOURCES?
I grabbed different sources to make this tut. Mainly TAO's tut for some shameless copy paste (THX!), some forum posts for the basic setup of the pi2 (THX!)


SPEED OF THE PI2?
The compiling of the needed file for the master node takes about 1.5/2h until done. The PI2 has an ARM kernel. So just downloading the 32bit/64bit version just doesnt cut it....

We have to compile it ourselfs on the PI2.

There is the possibility to crosscompile on your desktop but that is beyond the scope of this tut. In this tut We will do the 1.5h waitinggame. Compiling is long but not that long.
One you built your first, there is the possibility to leave the Masternode running while compiling the next version. That way you dont have to take it offline for long and miss your valuable BSD.


PREREQUISITES?
1. A raspberry Pi 2 model B, (duh!)
2. >5000 BSD
3. I did this on windows so its written as such
4. Unlimited data from your ISP
5. A stable highspeed internetconnection with a fixed IP address
6. Know your way around your router OR learn how to
7. SDcard class 10
8. Cardreader
9. Basic nerdskills
10. An girlfriend/wife who understands what you are doing at night and why its so awsome. (I failed at this one, girlfriend yes, understanding? Nah)/


ISP TEST (Do both tests before continuing)

Test 1:
go to whatismyipaddress.com and take note of your IP. Then pull the plug on your modem, wait a bit and replug. Check the page again. If the same then good!

Test 2:: Take note of IP address and wait 24h and check again. If the same then good!


DISCLAIMER
Running a Masternode on a PI2 is hardly tested for a longer period of time. Besides, they just got out. Mine is running 24/7 at this moment with no issues, but i cannot guarantee yours will too. So i will take no responsibility for what ever happens to yours. As with the crypto-scene, its highy experimental! At your own risk.



HERE WE GO!

1. Grab gear

Take a grab in your hardware box and take out a micro SHcard class 10 and a cardreader, or buy these. These puppies are cheap so grab a large one. I got a 32gb, for lateral future use also. Even cameras take these. Be sure it fits in your cardreader, else dont forget an SD-adapter. They are usually in the package of the product.


2. Grab Operating System

Head to http://www.raspberrypi.org/downloads/ to download the latest RASPBIAN image. Unpack the file to whatever dir you like. Dont use older ones because they dont run on the PI2.


3. Flash OS to sdcard

Head to http://www.raspberrypi.org/documentation/installation/installing-images/ and follow the tutorial to get the downloaded and unpacked image (.img file) on the sdcard. I did the Windows tutorial. After you have flashed the IMG-file to the card put it in your pi2. Be gentle, its a delicate slot.


4. Booting

Hook up the Pi2 to your router with an ethernet cable. We do want a stable connection so no wifi (i tried it and worked flawlessly, but eventually i moved it to my router with a 1.5m cable, besides wifi needs tinkering with files on the PI2 and im not gonna bother you with it atm).

Then hookup it up to a powersupply (i got it running on a 1,5Amps phonecharger. Just dont go hooking all sorts of USB on it because then you might need more amps. Im using mine as a decicated mastenode box.

Your pi2 is now booting the operating system you just flashed to the SDcard.


5. Fetching the IP

On Windows press windowsbutton+R. type 'cmd' and press enter. You enter a DOS box. type IPCONFIG and press enter. Scroll up a bit till you see Standard Gateway. Take note of the IP. 99% of the time it starts with 192.168.1.xxx or 192.168.0.xxx


6. Config your router

Start your browser and enter that IP. You will now see your router's website. Enter login + password (sticker on router?)
In the menu's somewhere there is a list of connected devices. They all have a IPaddress. Take note of the one called RASPBERRY.

Somewhere in the menus of your router you can do a DHCP reservation for the IP address of the PI2. This means everytime the PI2 boots it gets the same IPaddress. Thats what we want. We dont want it to change. Dunno your router so cannot help on this one :( Check manual or do a search on it. You should find some other tut.)

Now also somewhere in the menu of the router there is a NAT or PORT FORWARD menu. Enter the IPaddress of the PI2 and open port 8886. Usally by just filling all portboxes with 8886. IN / OUT etc. Maybe you just have one box to put it in.

Save the config of the router and reboot it. (also in the menus somewhere)

You are now re-routes internet traffic on port 8886 to your Pi2.

Check http://www.yougetsignal.com/tools/open-ports/ and fill in port 8886 to find it open.


7. Putty for a terminalconnection

No head to you desktop and download putty @ www.chiark.greenend.org.uk/~sgtatham/putty/download.html. Take the top one Intel x86 is fine.

Drag it to your desktop and start it. Enter the IPaddress of the pi at the Host Name, fill Masternode or whatever at Saved Sessions and press Save. That way you can easily load it again. Press Open.

Now you see a black box with a prompt. Enter 'pi' as login and 'raspberry' as password. You then see a green with blue prompt.


8a. Setup the PI2

Now we are gonna setup the PI2 just a little bit before continuing. From now on, whenever you see a RED line then thats a command. Type it and hit enter.

sudo raspi-config


You are shown a simple menu. We are gonna do options 1 2 and 3. Use the arrows and tab to navigate.
1. Expand the filesystem so it uses the whole 32gb of the SDcard
2. Change the password of the user pi. Make a strong password like you do so your Dash wallet.
3. Make it boot to command-line. So that way we safe some ram by not loading the desktop enviroment we will not be using at all.

I forgot if it reboots automaticly or manually. If manual, then:

sudo reboot

Putty will give an error it has lost connection. Reopen Putty and log in again after 1min. Remember you got a new password for the user 'pi'.


8b. Change root password and change username pi

Next we change to root password to something strong as well. Choose a long one:

sudo passwd

Close putty and login with user 'root'

Change username 'pi' to your loginname

sudo usermod -l NEW -d /home/NEW -m pi
sudo chown NEW /home/NEW


Close putty and login with your new login name.


9. Download and install the needed packages

At the prompt type the following commands in this order to fully update the pi and get it ready for compiling. Press yes to all when asked.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade


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

Just copy the whole thing and rightclick mouse in the putty screen. If it fails do one by one as written down here:

# sudo apt-get install libtool autotools-dev autoconf
# sudo apt-get install libdb-dev
# sudo apt-get install libminiupnpc-dev
# sudo apt-get install dh-autoreconf
# sudo apt-get install libdb++-dev
# sudo apt-get install libboost-all-dev
# sudo apt-get install libssl-dev
# sudo apt-get install pkg-config
# sudo apt-get install joe
# sudo apt-get install ufw
# sudo apt-get install protobuf-compiler libprotobuf-dev


there is maybe one too much in the list but this does the job for sure (maybe somebody can tell me which one is not needed, I grabbed them from different tuts.)


10. Config the Firewall

We are going to configure the firewall on the PI2 you just installed to block all ports except port 22(for putty) and 8886(for masternode):

sudo ufw allow ssh/tcp
sudo ufw limit ssh/tcp
sudo ufw allow 8886/tcp
sudo ufw logging on
sudo ufw enable


Again reboot and again use putty to get back:

sudo reboot

Check your firewall's status by entering the following command:

sudo ufw status


It should say active.


11. Preparing the build

ls

You will see a directory 'python-games' which in my eyes its clutter because the directory you are seeing now is your 'home' directory we will be using. Remove the dir:

sudo rm -R python-games

We are now gonna download the newest whole 1:1 BSD source from which we will compile the file needed to run the masternode, BSDD

git clone https://github.com/LIMXTEC/LIMX

(yes, its still at this address although darkcoin is rebranded to BSD
When done type check if directory darkcoin folder is there:

ls


12. Delete

13. DA BUILD! 2 hours of teethgrinding, nailbiting, checking and rechecking

We are now gonna compile darkcoin and use just the one file called BSDD to run the masternode. Enter the directory, config the build and compile it typing subsequently:

cd darkcoin
./autogen.sh
./configure --with-incompatible-bdb
make


Go outside and do something healthy and check back in 2h.

NOTE1: This will take lots of time and gives errors about arm6 and arm7. Ignore it, let it run. Be aware that closing Putty stops the build so leave it open. ( i got a headless server running so i do it from there. You can expiriment with the command 'screen' www.tecmint.com/screen-command-examples-to-manage-linux-terminals/ but im not bothered atm. Dunno how yet).


14. Checking stuff 'n setting up

You are still in the darkcoin folder. Enter the src folder of darkcoin and check if BSDD is there with:

cd src
ls


Now we are gonna move that file to the home dir where you start everytime with putty.

mv bitsendd ../..

Which moves it 2 dirs up to your home dir. At this stage you should have the directory darkcoin and the file bitsendd in the dir. Check with:

ls

The bitsendd file cant be run yet so we need to make it executable:

chmod +x ./bitsendd

To preset some settings to make it work we make a directory called .darkcoin and enter it with:

mkdir .bitsend
cd .bitsend


NOTE: this is the workingdirectory of the masternode. Its there, but hidden.

We need to make a configfile in there with an commandprompt file-editor Joe, which you installed earlier:

joe bitsend.conf

Type the following in the empty editor or paste this with just a rightmousebuttonclick in the putty screen.

rpcuser=RANDOMSTRINGOFLETTERSANDNUMBERS
rpcpassword=LONGERRANDOMSTRINGOFLETTERSANDNUMBERSHAVEFUN
rpcallowip=127.0.0.1
listen=1
server=1
daemon=1
logtimestamps=1
maxconnections=256
masternode=0
masternodeprivkey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
promode=1
addnode=107.170.2.241
addnode=45.58.51.22
addnode=104.207.131.249
addnode=68.197.13.94
addnode=109.30.168.16
addnode=31.41.247.133
addnode=37.120.190.76


Hit CONTROL - K then CONTROL - X to save and exit Joe.
For added security, it is recommended to make this file "Read Only" so no one can change it:

chmod 444 bitsend.conf


NOTE1: rpcuser and rpcpassword can be anything, you DONT have to remember them later. Only use letters and numbers.

NOTE2: Check and recheck. it usually goes wrong here with a typo.

Leave the dir one up back to your home directory:

cd ..


14. Lets fire it up for the first time

Run your darkcoind daemon for the first time:

./bitsendd

You will see the message like "Server Starting". It will now startup and configure itself. Also it will go download the blockchain. This will take plenty of time, and only happens once. Check if files are being made with:

cd .bitsend
ls

(check if there is more then that config file you made earlier made)
cd ..

Fire up another putty and at prompt check its progress with:

top

The CPU is 100% all the time. When its done it is just about 10%:

When done, close the second putty and return to the first one and check stats:

./bitsendd getinfo

Check the blockcount and check if its the same @https://chainz.cryptoid.info/bitsend/ See blockheight. If its the same and cpu bitsendd is max 10% all the time you know its done.


15. Linking it to your local wallet on your desktop pc.

32. We are now gonna make a private key so your masternode and local wallet can talk to eachother:

bitsendd masternode genkey

NOTE: Dont worry, this is not a key to get to your 5000bitsend. They are still safe in your local wallet protected with its own privatekey.

Select the generated string with your mouse. You dont need to copy it. Dragging mouse copies it automaticly.

Stop the the masternode and enter the hidden .darkcoin directory again and edit the configfile:

./bitsendd stop
cd .bitsend
joe bitsend.conf

Delete the long XXXXXXX-string and paste the string with a right mousebutton click on the putty screen. Also change masternode=0 to masternode=1 and save n quit with CONTROL - K then CONTROL - X

After leave the dir again to your home directory.

cd ..

Also copy paste the string to a notepad editor on your desktop pc. We need it later.


16. Starting your masternode permanently!

Restart the deamon and wait for it to idle (remember, you can check with another putty with command 'top' remember?, again takes a bit of time)

./bitsendd



Useful commands to check if your masternode is running ok:

# ./bitsendd getinfo
Check version number and block count vs website

# ./bitsendd masternode debug
It should say: masternode started remotely. If anything else its NOT working ok. use this only if you end this tutorial.

./bitsendd masternode list | grep YOUREXTERNALIPADDRESS
Check if your ip is red and the line ends with a 1 like: "YOUREXTERNALIPADDRESS:8886" : 1. Then you know its connectes and seen on the network.


CONGRATS SO FAR! THE HARD WORK IS DONE!


17. Updating & configuring your local wallet on your desktop to get the payments rolling in

Download the latest wallet from http://www.bitsendpay.io/ and replace the version with the one you already have on your pc. ( I assume you already have your wallet running, else you are not here)

The Local(wallet on your desktop) and Remote(Masternode on PI2) version should always be the same.

Dont start it yet. We are now gonna make another bitsend.conf and put it in the datadirectory of the wallet. This should be here unless you moved it on purpose:

C:\Users\username\AppData\Roaming\Dash

Now open notepad and paste this:

masternodeaddr=XXX.XXX.XXX.XXX:8886
masternode=1
masternodeprivkey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Change the first XXX with you external IP address.
Change the second long XXX with your masternode private key i asked you to save somewhere.

Save the file as bitsend.conf in C:\Users\username\AppData\Roaming\bitsend

Start up the wallet and let it sync until you see a green checkmark in the bottom right corner.

*

chris

  • Globaler Moderator
  • Full Member
  • *****
  • 154
  • +11/-0
    • View Profile
Re: Masternode on Raspberry Pi 2 Model B
« Reply #1 on: 09. March 2016, 07:56:52 »
18. Moving you 5000bitsend to a masternode address

Unlock your wallet in the settings menu. If you dont have it encrypted yet do it NOW!

Again, choose are very strong password. Not the name of your pet, but preferably a sentence you can remember easily. Make it weird swapping a with @, s with a $ etc.

Anyway you should have it unlocked before continuing....

In the wallet head to Tools-->Debug console

Now to generate your new Masternode's receiving address type:

getaccountaddress 0


This will output your special masternode payment enabled public address!

Next up is dumping the private key of that new address:

dumpprivkey YOURADDRESCOPYPASTEIT


Copy both strings to a notepad editor and print it. Store is somewhere safe.
For now, save the notepad file to your desktop temporarily. We will encrypt it later in chapter 20.

From wherever you currently hold your 1,000bitsend (exchange, another bitsend wallet, even a different address in the same wallet), send your bitsend to your freshly generated "0" Masternode receiving address in your wallet. Make sure the "Darksend" checkbox is unchecked.
You must send exactly 1,000bitsend to this address, no more, no less, to be eligible to run a Masternode! Once you have initiated the transaction, you must wait for a minimum of 15 confirmations so your address is eligible to be associated with your new Masternode.


19. Starting your mastenode.

Now after you 15 conformations are through you can start your PI2 masternode. Again do this from the debug-console and enter:

masternode start YOURWALLETPASSWORD

Enter "debug masternode" You receive now a feedback.



CONGRATS SO FAR! YOUR MASTERNODE IS RUNNING!


20. Storing your precious files to a USB

Grab a thumbdrive you can spare and empty it because you will loose all data.. Head over to

https://www.grc.com/misc/truecrypt/truecrypt.htm

and install Truecrypt 7.1a

Next follow the graphical tutorial on:

https://kb.wisc.edu/page.php?id=18301

You end up with an encrypted USBthumbdrive you can unlock with a password using truecrypt.

Save the notepad file with the public and private key to the openend USBthumbdrive. Delete the file from your desktop and empty the desktop trashcan.

Close Your Dash Wallet and wait untill its done closing. Head over to your datadir C:\Users\username\AppData\Roaming\Dash

and copy your wallet.dat and your bitsend.conf to your usbthumbdrive as well. Then close the drive and store the drive in the house somewhere.

<BLINK> NOTE: NEVER COPY/MOVE THE WALLET.DAT FILE WHILE YOUR WALLET IS OPEN. IT WILL GET CORRUPTED! </BLINK>

Note: You can also make a truecrypt container file and save it on your desktop but, you know.... Harddisks fail...... (and if you are like me, tinkering with hardware, you might just drop a screwdriver in a running pc

Alternatively you can make that truecrypt containerfile and save that to the thumbdrive. In that way you can save some more files on it unencrypted. You choose your flavor.

Remember you can loose both the sheet of paper AND the thumbdrive by fire, if both held at home. So you can also email a containerfile to yourself with a weird name. Zip it also, again with a strong password (other one then the walletfile).


21. Updating your running masternode

You can compile the next version while the masternode is running and swap the file quickly.

Putty into the PI2

Check where you are and see the directory darkcoin. Then remove the darkcoin directory:
(Yes, although we are called BSD now the dir is still called Darkcoin)

ls
sudo rm -R darkcoin

NOTE Dont remove the hidden folder .bitsend

Download the newest source from github, enter the directory and compile the next version like you did before.(Yes, although we are called BSD now the dir is still called Darkcoin)

git clone https://github.com/LIMXTEC/LIMX
cd darkcoin
./autogen.sh
./configure --with-incompatible-bdb
make

NOTE: Remember to leave putty open, or learn otherwise.

Check if the new darkcoind file is there and ready to be used:

cd src
ls

Now we stop the masternode and replace it with the new one. So head back two up to the main dir and stop and remove the file.

cd ../..
./bitsendd stop
(wait a minute)
rm bitsendd

Now we move the new one in the darkcoin/src dir to the current dir you are in atm. And make it executable, and run it!: (Yes, although we are called BSD now the dir is still called Darkcoin)

mv ~/darkcoin/src/bitsendd .
chmod +x ./bitsendd
./bitsendd

There you go! Its updated and started. Starting will take some time again. Check cpu with:

top

Start the masternode in your local wallet again (not always needed but i do it anyway for good measures)

Remember you can check if its running correct with:

./bitsendd getinfo
Check version number and block count vs website

./bitsendd masternode debug
It should say: masternode started remotely. If anything else its NOT working ok. use this only if you end this tutorial.

./bitsendd masternode list | grep YOUREXTERNALIPADDRESS
Check if your ip is red and the line ends with a 1 like: "YOUREXTERNALIPADDRESS:8886" : 1. Then you know its connectes and seen on the network.

ENDNOTE: DONT OPEN PORT 22 IN YOUR ROUTER SO YOU CAN LOGIN WHEN AWAY FROM HOME. YOU BECOME MORE EASILY HACKABLE. JUST PORT 8886.

*

Erkallys

  • Regular
  • Newbie
  • *
  • 13
  • +2/-0
    • View Profile
Re: Masternode on Raspberry Pi 2 Model B
« Reply #2 on: 14. March 2016, 20:37:08 »
Nice job ! Now I have no reason to start my own masternode ;) !

 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14