How To Deploy A Klaytn Node on Linux

How To Deploy A Klaytn Node on Linux
How To Deploy A Klaytn Node on Linux

Nodes are the power that strengthens the Klaytn network. Our guide provides a step-by-step process to set up a Klaytn node on a Linux system, enabling easy integration with the Klaytn blockchain network.

What is a Klaytn Node?

There are 3 types of nodes on the Klaytn network:

  • Endpoint nodes (ENs): ENs are responsible for accepting and processing transactions. They also broadcast blocks to the network. ENs are the most accessible type of node, and they are the only type of node that can be used to interact with the Klaytn network directly.
  • Proxy nodes (PNs): PNs are responsible for relaying transactions from ENs to CNs. They also help to improve the performance of the network by reducing the load on CNs.
  • Consensus nodes (CNs): CNs are responsible for validating transactions and creating blocks. They play a vital role in ensuring the security and stability of the network.

Our article will focus solely on setting up an Endpoint node.

Klaytn Endpoint Node Requirements

Running a Klaytn Endpoint Node (EN) demands relatively higher hardware specifications compared to Ethereum or other blockchains since ENs are tasked with validating blocks generated by full-fledged Consensus Nodes equipped with enterprise-grade hardware.

H/W Specification - Cloud VM:

Optimal performance with Cloud VMs that meet the recommended requirements below:

  • vCPU: 8
  • Memory (GiB): 64
  • Storage (GiB): >3,000
  • Disk Bandwidth (Mbps): 3,500
  • Network Bandwidth (Gbps): Up to 10

H/W Specification - Bare-metal Machine:

  • No specific physical machine specification provided for ENs.
  • Any physical machine with hardware configuration similar to the Cloud VM section is sufficient.

Storage Requirements:

  • Assuming an average of 100 transactions per second (TPS).
  • Average transaction size: 300 bytes.
  • 1-second block latency.
  • Expected daily storage requirement for an EN: 2.5 GB/day (= 300 x 100 x 86400).

Operating System:

  • Recommended environment: Amazon Linux 2.
  • Klaytn binaries fully tested on Amazon Linux 2, but should also work on other Linux-based environments.
  • macOS binaries provided for development purposes.

Check out Klaytn Docs for the latest updates on System Requirements.

How To Deploy A Klaytn Node

Step 1: Pre-Installation

Get the latest version of the ken from the download page.

1.1. Linux Archive Distribution:

The archive file structure includes the executable binary and the configuration file organized as follows. Be cautious not to modify the file structure or names as it might result in improper functioning of the node.

  • bin
    |- ken
    |- kend
  • conf
    |- kend.conf

File Names and Descriptions:

  • bin/ken: Executable EN file.
  • bin/kend: Start/termination script for EN.
  • conf/kend.conf: Configuration file for EN.

Install the Package

Extract the downloaded package into your chosen installation location.

$ tar zxf ken-vX.X.X-linux-amd64.tar.gz

Or,

$ tar zxf ken-baobab-vX.X.X-linux-amd64.tar.gz

Note: It's recommended to add the path to the ken-linux-amd64/bin directory (from the extracted package) to the $PATH environment variable for global access to ken and kend.

-> Example: $ export PATH=$PATH:~/downloaded/path/ken-linux-amd64/bin

The subsequent sections assume that the path has been added to the variable.

1.2. RPM Distribution (RHEL/CentOS/Fedora)

Install Downloaded RPM:

You can install the downloaded RPM file using the following yum command.

$ yum install kend-vX.X.X.el7.x86_64.rpm

Or,

$ yum install kend-baobab-vX.X.X.el7.x86_64.rpm

Install from Klaytn Yum Repo:

Alternatively, you can install kend from the Klaytn Yum repository with this command:

$ sudo curl -o /etc/yum.repos.d/klaytn.repo https://packages.klaytn.net/config/rhel/7/prod.repo && sudo yum install kend

Installed Location:

After installation, the files are located as follows:

  • ken: /usr/bin/ken
  • kend.conf: /etc/kend/conf/kend.conf

Step 2: Configure your node

Configuring the EN (Endpoint node) involves creating a data directory and setting up environment variables within the kend.conf configuration file.

2.1. Creating the EN Data Directory

Given the expanding size of the Klaytn blockchain data, it's recommended to allocate ample storage. You must establish the directory in your preferred path.

$ sudo mkdir -p /var/kend/data

2.2. Updating the Configuration File

Configuration File Location:

For the archive distribution, the configuration directory is located at $INSTALL_PATH/ken-linux-amd64/conf/.

For the package distribution, the configuration directory is located at /etc/kend/conf/.

Adding the Data Directory

You need to update the environment variable $DATA_DIR in the kend.conf configuration file to point to the data directory you created.

DATA_DIR=/var/kend/data

2.3. Fast Sync (Optional)

Each EN maintains a local copy of the network's chain data. If a node falls out of sync, it can retrieve this data from other nodes in the network, a process known as syncing. When a new EN is initially launched, it must download the entire chain data from the network.

To expedite this process, you can perform a fast sync by downloading a snapshot of the chain data prior to initiating the EN. This significantly reduces the time required for the EN to synchronize during its initial startup.

  1. Download the latest chaindata snapshot from either the Cypress chain or the Baobab chain.
  2. Before starting kend, extract the snapshot within the DATA_DIR you configured in kend.conf. For example:

$ tar -C ~/kend_home -xvf klaytn-cypress-chaindata-latest.tar.gz

Or,

$ tar -C ~/kend_home -xvf klaytn-baobab-chaindata-latest.tar.gz

\Once the data is extracted, you can launch the EN as usual.

Step 3: Launch your node

Start and stop your EN using the following commands:

  • Start: $ kend start Starting kend: OK
  • Stop: $ kend stop Shutting down kend: Killed

Read more