How-To:InstallNRSRaspberryPi

From Nxt Wiki
Jump to: navigation, search
Other languages:English 100%

Installing Nxt (and the NRS client) on Raspberry Pi

(Originally created by barbarosinciler at nextcoin.org . If this is of value to you, please donate some Nxt to him at address 7121642459245273749. The Java package that installs Nxt on your Pi was written by davethetrousers, at 14923118471272229432)

Raspbian and the NRS client for Nxt both run very well on a Raspberry Pi. CPU usage is approximately ~15-20% with the web client open and an account unlocked. Without the web client open (still unlocked) it is less than ~10% most of the time (it occasionally peaks higher and MAY occasionally spike to full load). Memory usage is about 100MB

Once this software is installed on your Raspberry Pi, it will start automatically on boot. You can administer it using remote desktop from another PC.

This tutorial makes the following assumptions; adjust accordingly!

  • your installation PC's is running Windows and has an IP of 192.168.1.20
  • your network router's IP is 192.168.1.1

Basic Raspbian install guide

  1. download and install Raspbian
    • Download the Raspbian image from [1]
    • Download diskimager for windows [2].
    • Install image on an SD Card, and boot the Raspberry from the card. You should see a config menu.
      • Expand filesystem and change your password.
      • Enable boot to desktop.
      • Set internationalisation options (language, keyboard and timezone)
      • Under advanced options enable ssh and set a hostname like "rpi".
      • Reboot. Now you should see a desktop and the system is running

Update the system

  1. open the bash commandline (LXTerminal), type the following, and follow the instructions:
    • sudo apt-get upgrade
      sudo apt-get dist-update
  2. Check your IP configuration
    • Your Pi should pick up an IP address from DHC, and this can be confirmed with the ifconfig command in a shell. To configure a static ip, open the bash commandline (LXTerminal) and type the following:
      • sudo nano /etc/network/interfaces
    • Change the following entry from:
      iface eth0 inet dhcp
      To:
      iface eth0 inet static
      address 192.168.1.10
      netmask 255.255.255.0
      gateway 192.168.1.1
      network 192.168.1.0
      broadcast 192.168.1.255
    • Press CTRL and O at the same time to save the file
    • Press CTRL and X together to exit
    • Reboot your Pi

Install XRDP (RDP server)

  1. Open the bash commandline (LXTerminal) and type the following, and follow the instructions:
    • sudo apt-get install xrdp
      sudo apt-get upgrade xrdp
  2. Now you can use Microsoft Remote Desktop and work remote on the Raspberry.
    • In windows go to start -> open -> and type "mstsc"
    • Enter your Raspberry's address (192.168.1.10), connect and sign in with your password


Router/firewall port forwarding

  1. Make sure to forward TCP port 7874 tcp on your network router to the IP your raspberry has (192.168.1.10)

Install NXT Client

You have two possible options here:

  1. Use your Raspberry Pi with the standalone package Oracle JRE included (all credits to the author: davethetrousers )
    1. Download the tar.gz file from davethetrousers' mirror with wget and extract it:
      • wget http://109.230.224.65/../~nxt/nxt_rasppi.tar.gz
        tar -xf nxt_rasppi.tar.gz
      • To start NRS automatically on raspberry reboot edit the run_nxt.sh file in nxt folder:
        • nano nxt/run_nxt.sh
      • Edit the run_nxt.sh file to look like this:
        • #!/bin/bash
          #
          # A script to run the NXT server on a Raspberry Pi, using the provided standalone JRE
          #
          # created by davethetrousers
          #
          cd /home/pi/nxt/
          /home/pi/nxt/ejre1.7.0_45/bin/java -Xms320m -Xmx450m -jar /home/pi/nxt/start.jar STOP.PORT=11111 STOP.KEY=123456 > nxtout.txt 2> nxterr.txt
      • Press CTRL and O at the same time to save
      • Press CTRL and X together to exit.
      • Enter: crontab -e
      • Insert the code at the end of the file:
        @reboot /home/pi/nxt/run_nxt.sh
      • Press CTRL and O at the same time to save
      • Press CTRL and X together to exit.
    2. Now the raspberry should be able to load the NRS software on boot#Step by step installation from devs mirror with build in raspbian java
    3. Download the NRS client (current version: 0.5.8) http://download.nxtcrypto.org/../nxt-client-0.5.8.zip
    4. Unzip the file:
      unzip nxt.zip
    5. Now the NRS client is in your home folder (/home/pi/nxt/)
    6. Make a new file in the [i]/home/pi/nxt/[/i] folder and name it something like "[i]run_nxt.sh[/i]":
      nano nxt/run_nxt.sh
    7. Insert the following code:
      #!/bin/bash
      cd /home/pi/nxt/
      /usr/bin/java -Xms320m -Xmx450m -jar /home/pi/nxt/start.jar STOP.PORT=11111 STOP.KEY=123456 > nxtout.txt 2> nxterr.txt</code>
    8. Press CTRL and O at the same time to save, Press CTRL and X together to exit.
    9. Enter: crontab -e
      • Insert the code at the end of the file:
        @reboot /home/pi/nxt/run_nxt.sh
      • Press CTRL and O at the same time to save
      • Press CTRL and X together to exit.
    10. Now the raspberry should be able to load the NRS software on boot

Stop script for the Nxt software

  1. Create a new file in the [i]/home/pi/nxt/[/i] folder and name it something like "[i]stop_nxt.sh[/i]":
    nano nxt/stop_nxt.sh
    1. If you are using davethetrousers' Java package, enter this code:
      /home/pi/nxt/ejre1.7.0_45/bin/java -jar /home/pi/nxt/start.jar STOP.PORT=11111 STOP.KEY=123456 --stop
    2. If you downloaded the Nxt software directly:
      /usr/bin/java -jar /home/pi/nxt/start.jar STOP.PORT=11111 STOP.KEY=123456 --stop
  2. Press CTRL and O at the same time to save
  3. Press CTRL and X together to exit.

Now you can stop the client on bash command line with the following command:
sudo bash nxt/stop_nxt.sh Before reboot your Pi, you should use this script to prevent a blockchain error!

Now you can reboot the system with:
sudo reboot

Connecting from your PC instead of localhost

  1. Edit web.xml to connect with your browser from another pc instead of localhost:
    nano nxt/webapps/root/WEB-INF/web.xml
  2. After [i]<param-name>allowedUserHosts</param-name>[/i] add:
    <param-value>127.0.0.1; localhost; 192.168.1.20; 0:0:0:0:0:0:0:1;</param-value>
  3. Press CTRL and O at the same time to save
  4. Press CTRL and X together to exit

Manually start forging with the NRS client

To start forging you will need to be logged in with your web browser once.

  1. Open https://192.168.1.10:7875
  2. Confirm the SSL notification
  3. Click on the padlock
  4. Unlock your account with your passphrase (unlocking an address takes a few seconds).

If the client is unlocked you can close the browser and the system will begin forging.

Handling NRS and Java errors

You can check the java logfiles (nxtout.txt and nxterr.txt) in the nxt folder for errors!

Having issues?

Check the FAQ and the "common problems and resolutions" pages!

Additional useful commands and tools

Mount your local windows hard drive remotely, for Raspberry Pi data sharing

sudo mount -t cifs //192.168.1.20/c$ /mnt -o user=myusername Where:

  • x = The IP address of your Windows PC
  • myusername = your username on the windows PC

Start the menu changing raspbian settings (language, keyboard, timezone, hostname etc.)

sudo raspi-config

Check the built-in Java configuration

sudo update-alternatives --config java (The standard location is marked with a star, and the path is something like [i]/usr/lib/jvm/jdk-7-oracle-armhf/jre/bin/java[/i]/ The defaults are [i]priority = 317[/i] and [i]auto-modus[/i]. If that is ok, confirm by pressing Enter.

Remote administration with putty

You can manage your raspberry with the tool "putty" through a command line SSL connection. Download the tool from [3]