Difference between revisions of "Easily deploy your Linux NKN node by yourself"

From NKN Community Wiki
(Created page with "📌 This guide will help you to configure and start a NKN Linux node using SSH. === NKN Node VS NKN Commercial === The first concept you need to understand is the difference...")
 
(Remove < > in the url of All in one deploy script)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
📌 This guide will help you to configure and start a NKN Linux node using SSH.
📌 This guide will help you to configure and start a NKN Linux node using SSH.


=== NKN Node VS NKN Commercial ===
=== NKN Node VS NKN Commercial ===
Line 9: Line 10:
==== NKN Commercial ====
==== NKN Commercial ====
A NKN Commercial node is basically a NKN node with other software embedded in such as nConnect. Running a NKN Commercial node will allow you to get mining reward from your node activity but also "nano payments" from users using the embedded software. NKN Commercial are easier to keep up to date as an auto-update system is included.
A NKN Commercial node is basically a NKN node with other software embedded in such as nConnect. Running a NKN Commercial node will allow you to get mining reward from your node activity but also "nano payments" from users using the embedded software. NKN Commercial are easier to keep up to date as an auto-update system is included.


=== Install ===
=== Install ===
In order to simplify the install the NKN community have build an "auto install" script called "[https://github.io/no112358/ALLinOne-nknnode ALLinOne-nknnode]"  , '''it is highly recommend to use this script to install your node unless you are comfortable with Linux, bash, GoLang''', ...!  You can otherwise follow the line by line install instructions.
In order to simplify the install the NKN community have build an "auto install" script called "[https://github.io/no112358/ALLinOne-nknnode ALLinOne-nknnode]"  , '''it is highly recommend to use this script to install your node unless you are comfortable with Linux, bash, GoLang''', ...!  You can otherwise follow the line by line install instructions.


==== ALLinOne nkn node ====


==== ALLinOne nkn node ====




Line 20: Line 22:


<code>sudo su -</code>
<code>sudo su -</code>




Start the script in terminal with this command:
Start the script in terminal with this command:


<code>wget -O nkndeploy.sh '<<nowiki>https://raw.githubusercontent.com/no112358/ALLinONE-nknnode/main/nkndeploy.sh</nowiki>>'; bash nkndeploy.sh</code>
<code>wget -O nkndeploy.sh '<nowiki>https://raw.githubusercontent.com/no112358/ALLinONE-nknnode/main/nkndeploy.sh</nowiki>'; bash nkndeploy.sh</code>
 




Follow the instruction on the screen.
Follow the instruction on the screen.


==== Line by line instructions ====
==== Line by line instructions ====
Connect to your node using SSH
<code>ssh username@instance-ip-address</code>
Switch to root user of not root yet
<code>sudo su -</code>
Apply update, upgrade and auto remove
<code>apt update && apt upgrade -y && apt autoremove -y</code>  
Install the required packages
<code>apt install sudo make curl git</code>
Create the NKN user and add it in the sudo group
<code>adduser nkn && usermod -aG sudo nkn</code>
Switch to newly created user
<code>su - nkn</code>
Download GoLang
<code>url=curl <nowiki>https://golang.org/dl/</nowiki> | grep linux-amd64 | sort --version-sort | tail -1 | grep -o -E "<nowiki>https://dl.google.com/go/go</nowiki>[0-9]+\.[0-9]+((\.[0-9]+)?).linux-amd64.tar.gz" && wget ${url}</code>
Install GoLang
<code>sudo tar -C /usr/local -xvf echo ${url} | cut -d '/' -f5</code>
Now that our installation has been finished, we need to make sure that go is present in the path so anyone can access go from anywhere without pointing to go directory. For that, we will add those path into rc file and resource it.
<code>cat >> ~/.rc << 'EOF'</code>
After you enter above command, next line will be >> only, expecting input from user till user enters EOF.
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
Re-source your rc file
<code>source ~/.rc</code>
and verify if go is correctly installed
# go version
go version go1.12.7 linux/amd64
It's now time to install your node from the NKN Github
<code>mkdir -p ~/go/src/github.com/nknorg && cd ~/go/src/github.com/nknorg</code>
Clone the repository
<code>git clone <nowiki>https://github.com/nknorg/nkn.git</nowiki></code>
Now that we have our code, let’s change the directory to nkn and fire up build command
<code>cd nkn && make</code>
At this stage your node is compiling, you can now take care of its configuration
<code>cp config.mainnet.json config.json && nano config.json</code>
In the config file modify the beneficiary address ( you can create a wallet on https://wallet.nkn.org/ )  
{
"BeneficiaryAddr": "YOUR-NKN-WALLET-ADDRESS-HERE",
"SeedList": [
"<nowiki>http://mainnet-seed-0001.nkn.org:30003</nowiki>",
"<nowiki>http://mainnet-seed-0002.nkn.org:30003</nowiki>",
"<nowiki>http://mainnet-seed-0003.nkn.org:30003</nowiki>",
"<nowiki>http://mainnet-seed-0004.nkn.org:30003</nowiki>",
"<nowiki>http://mainnet-seed-0005.nkn.org:30003</nowiki>",
....
Create a local wallet for your node
<code>./nknc wallet -c</code>
⚠️ '''This password will be used to run nkn service and miner, so don’t forget it.'''
It's now time to see if your installation is working !
<code>./nknd -p YOUR-WALLET-PASSWORD</code>

Latest revision as of 08:10, 3 November 2021

📌 This guide will help you to configure and start a NKN Linux node using SSH.


NKN Node VS NKN Commercial

The first concept you need to understand is the difference between the NKN node and a NKN node Commercial.

NKN node

A NKN node is a message relayer in the network. Its only purpose is to store the information in the chain and relay messages through nodes. Running this type of node will allow you to get "mining rewards" only. As the NKN node is an open-source software you will need to download it from the NKN official Github account and keep it updated by yourself.

NKN Commercial

A NKN Commercial node is basically a NKN node with other software embedded in such as nConnect. Running a NKN Commercial node will allow you to get mining reward from your node activity but also "nano payments" from users using the embedded software. NKN Commercial are easier to keep up to date as an auto-update system is included.


Install

In order to simplify the install the NKN community have build an "auto install" script called "ALLinOne-nknnode" , it is highly recommend to use this script to install your node unless you are comfortable with Linux, bash, GoLang, ...!  You can otherwise follow the line by line install instructions.

ALLinOne nkn node

Switch to root user if not root yet:

sudo su -


Start the script in terminal with this command:

wget -O nkndeploy.sh 'https://raw.githubusercontent.com/no112358/ALLinONE-nknnode/main/nkndeploy.sh'; bash nkndeploy.sh


Follow the instruction on the screen.


Line by line instructions

Connect to your node using SSH

ssh username@instance-ip-address


Switch to root user of not root yet

sudo su -


Apply update, upgrade and auto remove

apt update && apt upgrade -y && apt autoremove -y  


Install the required packages

apt install sudo make curl git


Create the NKN user and add it in the sudo group

adduser nkn && usermod -aG sudo nkn


Switch to newly created user

su - nkn


Download GoLang

url=curl https://golang.org/dl/ | grep linux-amd64 | sort --version-sort | tail -1 | grep -o -E "https://dl.google.com/go/go[0-9]+\.[0-9]+((\.[0-9]+)?).linux-amd64.tar.gz" && wget ${url}


Install GoLang

sudo tar -C /usr/local -xvf echo ${url} | cut -d '/' -f5


Now that our installation has been finished, we need to make sure that go is present in the path so anyone can access go from anywhere without pointing to go directory. For that, we will add those path into rc file and resource it.

cat >> ~/.rc << 'EOF'


After you enter above command, next line will be >> only, expecting input from user till user enters EOF.

export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF


Re-source your rc file

source ~/.rc

and verify if go is correctly installed

# go version
go version go1.12.7 linux/amd64


It's now time to install your node from the NKN Github

mkdir -p ~/go/src/github.com/nknorg && cd ~/go/src/github.com/nknorg


Clone the repository

git clone https://github.com/nknorg/nkn.git


Now that we have our code, let’s change the directory to nkn and fire up build command

cd nkn && make


At this stage your node is compiling, you can now take care of its configuration

cp config.mainnet.json config.json && nano config.json


In the config file modify the beneficiary address ( you can create a wallet on https://wallet.nkn.org/ )  

{
"BeneficiaryAddr": "YOUR-NKN-WALLET-ADDRESS-HERE",
"SeedList": [
"http://mainnet-seed-0001.nkn.org:30003",
"http://mainnet-seed-0002.nkn.org:30003",
"http://mainnet-seed-0003.nkn.org:30003",
"http://mainnet-seed-0004.nkn.org:30003",
"http://mainnet-seed-0005.nkn.org:30003",
....


Create a local wallet for your node

./nknc wallet -c

⚠️ This password will be used to run nkn service and miner, so don’t forget it.


It's now time to see if your installation is working !

./nknd -p YOUR-WALLET-PASSWORD