-
Notifications
You must be signed in to change notification settings - Fork 15
Mainnet Fullnode Set Up Instructions v0.18.13
This document explains how to download and setup a OneLedger Fullnode for the Mainnet.
There are 4 ways to setup OneLedger Mainnet Fullnode:
This document is drafted based on Ubuntu 18.04,
- Set timezone to UTC
sudo timedatectl set-timezone UTC
- Download the binaries
wget https://github.com/Oneledger/protocol/releases/download/v0.18.13/olclient
wget https://github.com/Oneledger/protocol/releases/download/v0.18.13/olfullnode
chmod +x olclient
chmod +x olfullnode
- Check the executable path
echo $PATH
-
if you want to add any preferred path into the executable path:
Add this line at the beginning of
/home/YourUserName/.bashrc
:export PATH=$PATH:YourPreferredPath
And source it:
source /home/YourUserName/.bashrc
put these binaries under any place of your executable $PATH
- Verify the binary md5
md5sum olfullnode gives some similar output like this
should get
41a3a8210a2938c95bf91cf9489be1f7 olfullnode
md5sum olclient gives some similar output like this
should get
e2acde2b1e776a2e09bbc13dd68c0cc9 olclient
- Initialize the node
export OLDATA="any place that you want to run the node"
cd $OLDATA
wget https://raw.githubusercontent.com/Oneledger/mainnet-genesis/master/genesis.json
wget https://raw.githubusercontent.com/Oneledger/mainnet-genesis/master/config.toml
olfullnode init --genesis genesis.json --node_name "your preferred name" --root ./
rm $OLDATA/consensus/config/genesis.json && sudo wget https://raw.githubusercontent.com/Oneledger/mainnet-genesis/master/genesis.json -O $OLDATA/consensus/config/genesis.json
- P2P configuration
Configure your config.toml
file
This will let your node to be connectable by others through p2p
# Main address for P2P connections
p2p_address = "tcp://<your-internal-ip>:26601"
# Address to advertise for incoming peers to connect to
external_p2p_address = "tcp://<your-external-ip>:26601"
- Run the node
There are two ways to do this, either of them works
- Directly run the node
olfullnode node --root $OLDATA >> $OLDATA/fullnode.log &
or
- Run the node in background
- Now run the olfullnode in the background by creating systemd service file.
cd /etc/systemd/system
-
First run "which olfullnode" result will be "/SOME_PATH/olfullnode", Keep the result copied over to a notepad.
-
Now run "which $OLDATA" you will get "/SOME_PATH/", Keep the result copied over to a notepad.
-
Now create the service file.
sudo vi fullnode.service
- Now press "i" it will go to insert mode. (add below content)
[Unit]
Description=fullnode
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
#User=alertmanager
#Group=alertmanager
ExecStart=/PATH/TO/olfullnode node --root /PATH/TO/OLDATA >> /PATH/TO/OLDATA/fullnode.log &
#Restart=on-failure
[Install]
WantedBy=multi-user.target
-
Replace
/PATH/TO/olfullnode
with "/SOME_PATH/olfullnode" and Replace/PATH/TO/OLDATA
with "/SOME_PATH/" in the above file. -
press "Esc" , now press ":wq!" to save your file.
-
Enable the service file
sudo systemctl enable fullnode.service
- start the service file and check the process.
cd $OLDATA
sudo service fullnode start
olfullnode status
the result will be similar to below(ip and ports may be different, we are looking for Looks all good
)
2020/12/09 14:39:42 Profiling listen to: [::]:32883
RPC Port: 26604 on 10.142.0.3 ✓
P2P Port: 26605 on 10.142.0.3 ✓
SDK Port: 26606 on 10.142.0.3 ✓
✓ Looks all good ✓
- Validate node status
- Go to Mainnet explorer, check out the current block height
- Use
olclient validatorset
command to see the block height showing on this node
The node will take some time to catch up to Mainnet current height, wait until two heights are same or with only 1~2 block difference
- After fullnode setup, Now to become validator please follow this validator setup
If you want to hide the full node from external traffic, you can do that with a sentry node(You will need at least two nodes running on different machines to perform following procedures, one acts as sentry node, the other one is the fullnode you want to protect)
Your nodes only establish private connections to the sentry node and the sentry node connects to the outside world.
To set up the Sentry node, follow steps from 1 to 5 above, then follow the steps below:
get node id with
olfullnode show_node_id --ip
you will get id like
[email protected]:26601
configure the sentry and protected node like following
In the config.toml
of sentry node:
# List of peers to maintain a persistent connection to
persistent_peers = ["<protected-node-id>@<protected-node-ip>:26601"]
# List of peer IDs to keep private (will not be gossiped to other peers)
private_peer_ids = ["<protected-node-id>"]
In the config.toml
of protected fullnode:
# List of peers to maintain a persistent connection to
persistent_peers = ["<sentry-node-id>@<sentry-node-ip>:26601"]
After configuration is done, run the nodes as introduced in step 7 and 8 above.
-
Run a node on Google Cloud Marketplace now by clicking here
-
Deploy OneLedger Mainnet Fullnode
* Choose the name from your OneLedger instance
* Choose a machine type with suggested configurations
* You can choose a zone which costs you less money and keep all other fields set to default values
* Click Deploy
-
Now you are up and running. Click on SSH to run your node.
-
Check the Fullnode service and check the status
cd $OLDATA
sudo olfullnode status
the result should be similar to below:
2020/12/14 20:05:31 Profiling listen to: [::]:41721
RPC Port: 26604 on 10.168.0.5 ✓
P2P Port: 26605 on 10.168.0.5 ✓
SDK Port: 26606 on 10.168.0.5 ✓
✓ Looks all good ✓
- Validate node status
- Go to Mainnet explorer, check out the current block height
- Use
sudo olclient validatorset
command to see the block height showing on this node
The node will take some time to catch up to Mainnet current height, wait until two heights are same or with only 1~2 block difference
- Check your node name The node name is setup automatically, to see your node name:
cat config.toml | grep node_name
you will see similar to below:
node_name = "xxx"
- After node is completely sync up with Mainnet current height, please run below commands to setup logrotation. This logrotation prevents your consensus log file growing size and free up your disk space
cd $OLDATA && sudo wget https://raw.githubusercontent.com/Oneledger/mainnet-genesis/master/logrotate-setup/logrotate.sh && sudo chmod +x $OLDATA/logrotate.sh && sudo $OLDATA/logrotate.sh && sudo rm $OLDATA/logrotate.sh
cd $OLDATA && sudo wget https://raw.githubusercontent.com/Oneledger/mainnet-genesis/master/logrotate-setup/clean_log_files.sh && sudo chmod +x $OLDATA/clean_log_files.sh && sudo $OLDATA/clean_log_files.sh
- After fullnode setup, Now to become validator please follow this validator setup
Setup fullnode through docker please follow this docker-setup
- Set timezone to UTC.
sudo timedatectl set-timezone UTC
- Install Kubernetes cluster with one master node. First, login as ‘sudo’ user because the following set of commands need to be executed with ‘sudo’ permissions. Then, update your ‘apt-get’ repository.
$ sudo su
# apt-get update
- Turn off swap space, otherwise kubernetes will start throwing random errors.
swapoff -a; sed -i '/swap/d' /etc/fstab
- Now update sysctl settings for Kubernetes networking.
cat >>/etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
- To set your Virtual Machine with static IP modify the network interfaces file. Run following command to open the file:
# nano /etc/network/interfaces
Now enter the following lines in the file:
auto enp0s8
iface enp0s8 inet static
address <IP-Address-Of-VM>
Then press ‘Ctrl+X’, then press ‘Y’ and then press ‘Enter’ to Save the file.
After this, restart your machine.
- Install openssh-server
# apt-get install openssh-server
- Now we have to install docker because docker images will be used for managing containers in the cluster. Run the following commands:
# apt-get update
# apt-get install -y docker.io
- Next we have to install three essential components(kubeadm, Kubelet and Kubectl) for setting up Kubernetes environment. 'Kubelet' is responsible for what's running on the machine. 'Kubeadm' is used for administrating the kubernetes cluster. 'Kubectl' is used for controlling configurations on nodes inside the cluster. Run the following commands to setup Kubernetes environment.
# apt-get update && apt-get install -y apt-transport-https curl
# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
# apt-get update
# apt-get install -y kubelet kubeadm kubectl
- Update kubernetes configuration file, Run the below command:
# nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
This will open a text editor, enter the following line after the last “Environment Variable”:
Environment=”cgroup-driver=systemd/cgroup-driver=cgroupfs”
Now press Ctrl+X, then press Y, and then press Enter to Save.
- Now Initialize Kubernetes Cluster, Update the below command with the ip address of your machine.
kubeadm init --apiserver-advertise-address=<IP-Address-Of-VM> --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors=all
- After you initialize kubernetes cluster you will get the below output:
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join <IP-Address-Of-VM>:6443 --token 4v1bct.fcgl0wao43bg0vcu \
--discovery-token-ca-cert-hash sha256:a28cdb5bd3e2727b05c3286c96ca2d341eca055fc0b29a6246fdb322218d1ce5
- Now Deploy Calico network.
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
- If you want to be able to run kubectl commands as non-root user, then as a non-root user perform these:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
- Our Kubernetes control-plane has initialized successfully, Now run the following command to make our master node ready:
kubectl taint nodes --all node-role.kubernetes.io/master-
- 'kubectl get nodes' result will be similar to below:
NAME STATUS ROLES AGE VERSION
<Your-machine-name> Ready control-plane,master 22h v1.21.1
- Now to setup Oneledger Mainnet fullnode, First we create a 'PersistentVolume' which is a storage resource in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes and 'PersistentVolumeClaim' is a request for storage by a user to consume PV resources. This PVC volume store your node data.
cd $HOME (You can use your preferred path)
Run the below command:
nano fullnode-pv.yaml
This will open a text editor, enter the following lines:
apiVersion: v1
kind: PersistentVolume
metadata:
name: fullnode-pv
spec:
capacity:
storage: 60Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: fullnode-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 60Gi
- Now run 'kubectl apply -f fullnode-pv.yaml' it will create volumes.
'kubectl get pv' result will be similar to below:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
fullnode-pv 60Gi RWX Retain Bound default/fullnode-pvc 22h
'kubectl get pvc' result will be similar to below:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
fullnode-pvc Bound fullnode-pv 60Gi RWX 22h
- Now we create pod yaml to start our fullnode. Run the following commmand:
nano Mainnet-fullnode.yaml
This will open a text editor, enter the following lines:
apiVersion: v1
kind: Pod
metadata:
name: Mainnet-fullnode
labels:
app: Mainnet-fullnode
spec:
containers:
- name: kratos-fullnode
image: oneledgertech/mainnet:v0.18.13
imagePullPolicy: "Always"
volumeMounts:
- mountPath: /home
name: fullnode-pv
#readOnly: true
volumes:
- name: fullnode-pv
persistentVolumeClaim:
claimName: fullnode-pvc
#readOnly: true
- Now run 'kubectl apply -f Mainnet-fullnode.yaml' it will start fullnode.
'kubectl get pods' result will be similar to below:
NAME READY STATUS RESTARTS AGE
Mainnet-fullnode 1/1 Running 0 3s
- Now connect to the container, container_name can be found in the above result
kubectl exec -it Mainnet-fullnode /bin/bash
cd /home/node/go/data
- Validate node status
- Go to Mainnet explorer, check out the current block height
- Use
olclient validatorset
command to see the block height showing on this node
The node will take some time to catch up to Mainnet current height, wait until two heights are same or with only 1~2 block difference
- After fullnode setup, Now to become validator please follow this validator setup
© OneLedger 2018-2020 Contact Information