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