Page Contents:
- Prerequisites
- Machine Requirements
- Create Non-Root User
- Install Docker and Latest Klever Toolchain Image
- How To Run a Node
- How To Stop Node / Restart Node
- Run Node in the Background
- Backup DB Folder
- Upgrade Klever Docker Image
- Register and Become a Validator
- Freeze KLV for Self-Staking
- Delegate Frozen KLV in Bucket to Address
- Node Monitoring
***** Please Note: Following was written for the #KleverChain Testnet. please feel free to review Klever’s Official Node Documentation. The Node Monitoring may still apply to you, but please read carefully and change to use mainnet commands and not testnet. *****
1. PRE-REQUISITES
As a Klever Validator, or Stake Pool Operator, you must be competent with the following abilities:
- Operational knowledge of how to set up, run and maintain a Klever node continuously
- A commitment to maintain your node 24/7/365
- System operation skills
- Server administration skills (operational and maintenance).
2. MINIMUM MACHINE REQUIREMENTS
To run a node on KleverChain, you need the following minimum setup: Reference: Klever Docs
- A CPU with 4 cores.
- A RAM with 8GB.
- An SSD with 200 GB.
- An internet connection speed of at least 100 Mbps.
- Linux or MacOS.
3. CREATE NON-ROOT USER
SSH to your server
ssh username@server.public.ip.address # example # ssh myUsername@ipaddress
Create a new user of your choice
useradd -m -s /bin/bash <new user>
Set the password for the new user
passwd <new_user>
Add the new user to the sudo group
usermod -aG sudo <new user>
4. INSTALL DOCKER AND LATEST KLEVER TOOLCHAIN IMAGE
Follow instructions on https://docs.docker.com/engine/install to install Docker.
From your new users home directory, create a new klever folder to keep all your node files.
mkdir klever
Change directory into the new klever directory and download the latest Klever image.
cd klever docker pull kleverapp/klever-go-testnet:latest
While in the klever directory, make a wallet directory that will be used for your klever wallet info. If you do not pre-create this folder, you may run into permissions issues in a later command.
mkdir wallet docker run -it --rm --user "$(id -u):$(id -g)" \ -v $(pwd)/wallet:/opt/klever-blockchain \ --entrypoint=/usr/local/bin/operator kleverapp/klever-go-testnet:latest "create-wallet"
To check your wallet certificate and address, type the following:
docker run -it --rm --user "$(id -u):$(id -g)" \ -v $(pwd)/wallet:/opt/klever-blockchain \ --entrypoint=/usr/local/bin/operator kleverapp/klever-go-testnet:latest "getAddress"
5. HOW TO RUN A NODE
Create a folder where all the data will be stored:
mkdir -p $(pwd)/node/config $(pwd)/node/db $(pwd)/node/logs
Download latest config file (http://) and extract into your config directory
curl -k https://backup.testnet.klever.finance/config.testnet.100015.tar.gz \ | tar -xz -C ./node
Execute a command inside the docker container to create wallets for validators. The data is then forwarded to the directory created previously.
docker run -it --rm -v $(pwd)/node/config:/opt/klever-blockchain \ --user "$(id -u):$(id -g)" \ --entrypoint='' kleverapp/klever-go-testnet:latest keygenerator
Download a backup in case it exists. Every time the network is reset, files change as well. So, this backup is necessary.
curl -k https://backup.testnet.klever.finance/kleverchain.latest.tar.gz \ | tar -xz -C ./node
The command for running a node comes with a few settings: it includes mappings for cryptographic keys, data directories and logs, as well as network ports, the application that will run when the docker image is executed and the file of node validators signature.
docker run -it --rm \ --user "$(id -u):$(id -g)" \ --name klever-node \ -v $(pwd)/node/config:/opt/klever-blockchain/config/node \ -v $(pwd)/node/db:/opt/klever-blockchain/db \ -v $(pwd)/node/logs:/opt/klever-blockchain/logs \ --network=host \ --entrypoint=/usr/local/bin/validator \ kleverapp/klever-go-testnet:latest \ '--log-save' '--rest-api-interface=0.0.0.0:8080' \ '--display-name=<Your Node Name Here>'
With your node running, you should see something like the following. However, as your node is not registered as a validator yet you will not see Validator – Elected or a block proposed/accepted count. Your node at this point may only be an Observer.
6. HOW TO STOP NODE / RESTART NODE
Without forcibly killing the nodes, please open a new terminal window and type the following to stop the node:
docker stop klever-node
To do a restart of your Klever node, run the following:
docker restart klever-node
7. RUN NODE IN THE BACKGROUND
There are a few ways to run the node in the background on in another “window” within the same terminal session. You may start the node in the background with the following:
docker run -it -d \ --user "$(id -u):$(id -g)" \ --name klever-node \ -v $(pwd)/node/config:/opt/klever-blockchain/config/node \ -v $(pwd)/node/db:/opt/klever-blockchain/db \ -v $(pwd)/node/logs:/opt/klever-blockchain/logs \ --network=host \ --entrypoint=/usr/local/bin/validator \ kleverapp/klever-go-testnet:latest \ '--log-save' '--use-log-view' '--rest-api-interface=0.0.0.0:8080'
If you would like to only use one terminal window, you may use Tmux (There are others similar and one for docker). I used tmux.
For more information on Tmux, please visit this link.
8. BACKUP DB FOLDER
You may want to keep a backup every so often. If you do, please follow the following:
docker stop klever-node tar -czvf filename.tar.gz $(pwd)/node/db
9. UPGRADE KLEVER DOCER IMAGE
Stop Klever Node
docker stop klever-node
Upgrade Image
docker pull kleverapp/klever-go-testnet:latest
Delete the container if running in the background:
docker rm klever-node
Startup your node using the command found earlier in this document.
10. REGISTER AND BECOME A VALIDATOR
Registering node as a validator with the command below. Please pay attention to the format. The command follows this pattern: [BLS_KEY] [COMMISSION] [MAX_DELEGATION][LOGO][OWNER_ADDR][REWARD_ADDR][NAME]
If no [REWARD_ADDR]
is passed, the [OWNER_ADDR]
becomes the reward address.
If using a LOGO, that value must be a valid URL to an image: https://abc.com/image.png — At the time of writing, this feature did not work yet.
The BLS_KEY value is found in the ~/klever/node/config/validatorKey.pem file.
[NodeName] — At the time of writing, this feature did not work yet.
docker run -it --rm --user "$(id -u):$(id -g)" \ -v $(pwd)/wallet:/opt/klever-blockchain \ --network=host \ --entrypoint=/usr/local/bin/operator \ kleverapp/klever-go-testnet:latest \ --key-file=./walletKey.pem \ create-validator \ [BLS_KEY] \ 10 \ 100000000 \ [LOGO] \ klvxxxxxxxxxxx \ [REWARD_ADDR] \ [NodeName]
11. FREEZE KLV FOR SELF-STAKING
The following is the command to freeze KLV from the CLI
docker run -it --rm --user "$(id -u):$(id -g)" \ -v $(pwd)/wallet:/opt/klever-blockchain \ --network=host \ --entrypoint=/usr/local/bin/operator \ kleverapp/klever-go-testnet:latest \ --key-file=./walletKey.pem freeze 1500000
After successful completion from the command above, you will see the output with a Tx. Copy down this txHash.
txCount = 1 txHash = 4f788dfb3b674d07e30f834091a5dd2574ded795f100b234455251fed7acdb14
Before running the command to delegate, we need to find the BUCKET_ID to delegate the frozen KLV to. To do this, run the following command and
docker run -it --rm --user "$(id -u):$(id -g)" \ -v $(pwd)/wallet:/opt/klever-blockchain \ --network=host \ --entrypoint=/usr/local/bin/operator \ kleverapp/klever-go-testnet:latest \ --key-file=./walletKey.pem \ tx-by-id \ <Copied txHash from previous command that you copied>
The output should include a line similar to the following in the output: Your “bucketId” will be different than below.
“bucketId”: “0dc5bf4cb8a769909ba1961167382569ad362a131f7ca90f0b0f13efd93924a8”,
12. DELEGATE FROZEN KLV IN BUCKET TO ADDRESS
Delegate to an address [TO], pointing to the bucket [BUCKET_ID] where the frozen KLV is located. This can be found in the previous command above.
docker run -it --rm --user "$(id -u):$(id -g)" \ -v $(pwd)/wallet:/opt/klever-blockchain \ --network=host \ --entrypoint=/usr/local/bin/operator \ kleverapp/klever-go-testnet:latest \ --key-file=./walletKey.pem \ delegate \ [Wallet Address] \ [Bucekt_ID]
13. NODE MONITORING
1. Install prometheus and prometheus node exporter.
sudo apt-get install -y prometheus prometheus-node-exporter
2. Install grafana
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - sudo apt-get update && sudo apt-get install -y grafana
3. Install cAdvisor and execute in the background
Note: cAdvisor runs as a Docker Container used to gather metrics of additional containers, such as Klever-node. We will use port 8081 so we do not conflict with 8080. By default, cAdvisor uses 8080 so we must publish 8081.
docker run \ --volume=/:/rootfs:ro \ --volume=/var/run:/var/run:ro \ --volume=/sys:/sys:ro \ --volume=/var/lib/docker/:/var/lib/docker:ro \ --volume=/dev/disk/:/dev/disk:ro \ --publish=8081:8080\ --detach=true \ --name=cadvisor \ gcr.io/cadvisor/cadvisor
Check to be sure that cAdvisor and your Klever-Node containers are running.
docker container ls
4. Enable services so they start automatically
sudo systemctl enable grafana-server.service sudo systemctl enable prometheus.service sudo systemctl enable prometheus-node-exporter.service
5. Update prometheus.yml located in /etc/prometheus/prometheus.yml
# Sample config for Prometheus. global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: 'example' # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: ['localhost:9093'] # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 5s scrape_timeout: 5s # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] - job_name: node # If prometheus-node-exporter is installed, grab stats about the local # machine by default. static_configs: - targets: ['localhost:9100'] - job_name: Validator_Name_Here # If prometheus-node-exporter is installed, grab stats about the local # machine by default. # Override metrics with the below to access node metrics metrics_path: /node/metrics static_configs: - targets: ['localhost:8080'] - job_name: cAdvisor # If prometheus-node-exporter is installed, grab stats about the local # machine by default. static_configs: - targets: ['localhost:8081']
6. Finally, restart the services
sudo systemctl restart grafana-server.service sudo systemctl restart prometheus.service sudo systemctl restart prometheus-node-exporter.service
If everything is working as expected and you configured the prometheus.yml file correctly, you should be able to go to:
Prometheus: http://ipaddress:9090/targets
cAdvisor: http://ipaddress:8081/
and see something similar. If you do not, please be sure the ports required are open.
7. Setup Grafana Dashboard
NOTE: The Grafana Dashboards you see below are not perfect and are not intended to be a one and done setup. I created these dashboards as a base setup to help you get familiar with the panels and data. Feel free to use these and customize a dashboard to your liking with metrics that you want to see. Thank you.
- In your local browser, go to http://<ip address>:3000. You may need to open up port 3000 in your router and/or firewall if you are unable to access the login page.
- Login with admin / admin
- Change password
- Click the configuration gear icon, then Add data Source
- Select Prometheus
- Set Name to “Prometheus“
- Set URL to http://localhost:9090
- Click Save & Test
- Download and save the dashboard file of your choice: Klever-Dash1.jsonPlease Note: 1). Klever-Dash1.json dashboard makes use of the Clock Plug-In for the clock. It may or may not show correctly. 2). Klever-Dash1.json dashboard reports the Klever-node uptime for the Docker container. This is achieved by installing cAdvisor as noted in the above steps in this Monitoring section and allowing prometheus node-exporter to pull those metrics. This metric may show No Data if cAdvisor is not configured.3). Klever-Dash1.json make use of custom scripts to gather and report extended metrics. Script will be provided in time.
- Click Create + icon > Import
- Add dashboard by Uploading JSON file
- Ensure you select Prometheus as the datasource
- Click the Import button.