Setting up Hive-Engine node at home, part 1

avatar
(Edited)

For the fun of it, I embarked on a journey to set up a Hive-Engine node at my home computer. Since this is a Windows 10 machine, I used Oracle VM VirtualBox to install the Ubuntu Linux system.

Will it work?


Initial parameters of the virtual machine are:

  • Ubuntu 20.04.3 LTS
  • 8 GB of RAM
  • 1 core - I'll change this dynamically depending on what task the VM will be doing and see how it performs
  • two VDIs serving as disk images
  • first with 20 GB ext4 partition - for OS and node app
  • second with 120 GB xfs partition - for MongoDB data files; it is supposedly better to have the database files on an xfs filesystem

Both disks reside on an old HDD drive, I'll try it out first this way and then probably move the VM images to NVMe drive ...


After installing Ubuntu in a minimum desktop configuration the real fun starts.

I used my old notes/scripts when setting up the production node for my Hive-Engine witness and bits of two existing tutorials:


1. Additional system update and installing essential stuff

sudo apt-get update -y 
sudo apt-get upgrade -y 
sudo apt install git -y 
sudo apt install screen -y 
sudo apt install ufw -y
sudo apt install curl -y

2. Installing Fail2ban

I installed Fail2ban as an additional security measure. Maybe it's not needed on a home machine behind the firewall yet essential on a server.

sudo apt-get install -y fail2ban
touch /etc/fail2ban/jail.local
echo "[DEFAULT]" >> /etc/fail2ban/jail.local
echo "bantime = 3600" >> /etc/fail2ban/jail.local
echo "banaction = iptables-multiport" >> /etc/fail2ban/jail.local
echo "ignoreip = 127.0.0.1/8" >> /etc/fail2ban/jail.local
echo "[sshd]" >> /etc/fail2ban/jail.local
echo "enabled = true" >> /etc/fail2ban/jail.local
systemctl start fail2ban
systemctl enable fail2ban

3. Installing Node.js and related stuff

I went with v16 to see if/how it performs. Here are links to Ubuntu/Debian files for various versions.

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

Checking the versions installed.

# node -v
v16.13.1
# npm -v
8.1.2

4. Installing and preparing MongoDB

I currently use version 4.4.3. Let's try to install the same minor version. The steps are adding the public key, adding Mongo repo to apt, updating apt, fetching and installing the community edition, and enabling replication.

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list 
sudo apt-get update 
sudo apt-get install -y mongodb-org
sed -i '/replication/a \ \ \ replSetName: "rs0"' /etc/mongod.conf
sed -i 's/#replication/replication/g' /etc/mongod.conf
sudo systemctl stop mongod
sudo systemctl start mongod

What did I end up with?

# mongo --version
MongoDB shell version v4.4.10
Build Info: {
    "version": "4.4.10",

# systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-12-02 20:18:47 GMT; 1min 44s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 12621 (mongod)
     Memory: 62.3M
     CGroup: /system.slice/mongod.service
             └─12621 /usr/bin/mongod --config /etc/mongod.conf

Looking good.


5. Getting Hive-Engine node code and installing it

Since we already installed git we can now fetch the latest production code of the node software and install it along with its dependencies. I put it into the /he directory.

mkdir /he
cd /he
git clone https://github.com/hive-engine/steemsmartcontracts.git 
cd steemsmartcontracts/
git checkout hive-engine
npm i
sudo npm i -g pm2

After a while, it will download and install all the needed modules, including pm2 process manager for Node.js applications.


Next steps:

  • setting up firewall - both inside the VM and on the local network
  • moving MongoDB files to /mongo as a default - I hope this will go smoothly
  • fetching database image and restoring it - this takes time
  • setting up node app's .env file - witness account and public key
  • editing config.json - determining network, start block
  • starting the app and catching the head
  • enabling the witness and crossing fingers that the node will cooperate in block signing
  • managing log files, specifically node_app and mongo logs)

Most probably the node will be a part of the testnet for a while.


Better and better



0
0
0.000
14 comments
avatar

Are there any rewards to setting up the Hive Engine node?

0
0
0.000
avatar

Yes, in a way. You are rewarded with the $BEE token for your service.

As for how much, it depends on your witness ranks. As with the Hive witnesses where you vote with your HP, here you vote with your staked $WORKERBEE tokens.

Yet, you need to be in the top twenty to really feel the rewards.

Are you interested? Join the party :)

!invest_vote

0
0
0.000
avatar

This post has been manually curated by @bala41288 from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share 100 % of the curation rewards with the delegators.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

Read our latest announcement post to get more information.

image.png

Please contribute to the community by upvoting this comment and posts made by @indiaunited.

0
0
0.000
avatar

I tried to run hive-engine node in docker images some time ago. Worked like a charm, only problem was that it would take months or years to replay everything till blockchain head :)

0
0
0.000
avatar
(Edited)

Yes, restoring the database image is the bottleneck, a huge one. I hope too that some other approach will be created. Like continuing from the point in time aka from a specific block onward.

With the restore process itself, IOPS is the key. I don't think that parallelization has any impact. Disk speed is far more important.

With docker images and VMs you have additional layers between the process and the hardware that throttle it even further. I'll see how it will go with this setup above. And then when I move the whole VM to a NVMe disk :)

Have a great day.

0
0
0.000
avatar

In my case the problem was with CPU. I ran it on some mobile AMD with multiple weak cores, but the process simply can't use more than one core. So it was processing like 20 blocks per second at best which was nothing in terms of iops.
I'm very interested to see how it will work for you

0
0
0.000
avatar

That's great input, thank you. I'll see whether I'll need to increase the number of cores.

Have a great weekend.

0
0
0.000
avatar

Missed this one... 🤦‍♂️

Suggestion: Use npm ci instead... to comply with the package-lock.json. So we have all the same environment.

0
0
0.000
avatar

Thanks for your keen eye.

In the meantime, I dropped this particular project since the VB environment was too unstable. It has to be some sort of server.

0
0
0.000
avatar

Yeah, it needs a lot of IO nowadays.

0
0
0.000