One-Click Hive Engine Witness

in #hiveengine4 years ago

One-Click Hive Engine Witness

<h2>Into <p dir="auto">I was excited to see <a href="https://peakd.com/hive-engine/@aggroed/hive-engine-upgrade-successful-witness-system-starts-in-12-hours" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">the announcment for Hive Engine Witnesses and I excitedly got to work! I've been pretty distant around here and looking for a project to jump back in with and this seemed perfect. <p dir="auto">Seemed. <p dir="auto">As you may have learned yourself, if you just <a href="https://github.com/hive-engine/steemsmartcontracts" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">follow these instructions as directed in the announcement, you likely didn't have a smooth and simple experience. I've been building servers for over 20 years so this is all second nature to me, and even with that head start this was anything but simple. <h2>Greater Community Participation <p dir="auto">With that in mind, I've taken everything I've learned and compiled it all here. Ultimately, I don't think we'll have very many witnesses at all if it is even half this hard, so my goal is to make it so simple literally anyone can launch a witness. I feel like this is as simple as absolutely possible so it is my hope that this will spur a <em>bunch of new witnesses. <p dir="auto">Again, I've been deploying servers for 20 years and I had trouble getting started here. That said, I expect this to be a continuing problem so my goal is to put something together that literally anyone can do. My larger goal is to make becoming a witness as simple as possible so we <em>double or even triple the number of active witnesses. Decentralization, by its very name, demands that more of us get on board, this only helps. <h2>Shell Script Server Deployment <p dir="auto">In four words, that's exactly what this is. Basically, I've scripted every single step you need to take to deploy your server. <p dir="auto">Now, you can open your terminal and paste in these commands one at a time, but this script was written to be executed completely. <p dir="auto">If you use <a href="https://m.do.co/c/ff91b96d744f" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">DigitalOcean they allow you to deploy a server using one of these scripts through <a href="https://www.digitalocean.com/docs/droplets/how-to/provide-user-data/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">User Data that allows you to fully automate your deployment. I will outline this approach here. <h2>Deploy Droplet <p dir="auto">Login to <a href="https://m.do.co/c/ff91b96d744f" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">DigitalOcean, click the Create button and select Droplets. <p dir="auto">I'm using Ubuntu 20.04 so select that: <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/PXj0QY9Y-ubuntu.png" alt="ubuntu.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/PXj0QY9Y-ubuntu.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/blervin/PXj0QY9Y-ubuntu.png 2x" /> <p dir="auto">I think the best option is the $15 2GB with 2 CPUs <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/NM4TJai4-plan.png" alt="plan.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/NM4TJai4-plan.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/blervin/NM4TJai4-plan.png 2x" /> <p dir="auto">And then check 'User data' and paste in the script. Be sure to update your account and key!! <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/9RfMgbTh-user_data.png" alt="user_data.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/9RfMgbTh-user_data.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/blervin/9RfMgbTh-user_data.png 2x" /> <p dir="auto">Set the remaining options to your personal preference and once you're ready click 'Create Droplet' <h2>Follow along <p dir="auto">The mongodb download and restore takes awhile, but fortunately it's all automated so you can just walk away! <p dir="auto">But if you want, you can watch everything as it happens. Just login and type this commend: <p dir="auto"><code>tail -f /var/log/cloud-init-output.log <p dir="auto">Now you can watch along as everything downloads and installs. Eventually you'll see something like this: <p dir="auto"><code>Cloud-init v. 20.4.1-0ubuntu1~20.04.1 finished at Fri, 05 Feb 2021 00:27:58 +0000. Datasource DataSourceDigitalOcean. Up 11.48 seconds <h2>Start it up <p dir="auto">Once everything has completed, the final step is to start the witness script! <pre><code>cd /var/witness pm2 start app.js --no-treekill --kill-timeout 10000 --no-autorestart --name engwit <p dir="auto">You can watch along with this command: <p dir="auto"><code>pm2 logs <p dir="auto">This does take quite awhile, but again, you can just walk away. The key that you're looking for is a line like this <p dir="auto"><code>2021-02-05 12:49:16 info: [Streamer] head_block_number 51065064 currentBlock 51065065 Hive blockchain is 0 blocks ahead <p dir="auto">The main thing is '0 blocks ahead' and once you've hit that, you're fully up and running! <h2>Register witness <p dir="auto">The last step is to jump over to <a href="https://tribaldex.com/witnesses" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Tribaldex <p dir="auto">Click the 'Register button' <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/6iYSykyX-register.png" alt="register.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/blervin/6iYSykyX-register.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/blervin/6iYSykyX-register.png 2x" /> <p dir="auto">Set your witness name, the IP of your server, and your <em>public 'STM...' active signing key. <p dir="auto">Toggle enabled, click 'Update Witness' and you're now a witness!! <h2>Conclusion <p dir="auto">I hope this makes deploying a witness much easier for some of you and that we can continue to grow this community even further! <p dir="auto">Decentralizing Hive Engine will be a major step forward for Hive and will only move us forward toward greater success. <p dir="auto">As I mentioned, I haven't been very active around here so now that I'm working on this I hope to touch base with frequent updates, and little scripts and stuff that I come write as I learn more about tweaking my witness. <p dir="auto">They also have a <a href="https://discord.gg/xWRYB9s" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Discord available and if you hit up one of the admins they'll put you in the witnesses profile and unlock another private witness channel. <p dir="auto">If you have any WORKERBEE staked, please consider voting for me at <a href="https://tribaldex.com/witnesses" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Tribaldex, I would really appreciate your support. <p dir="auto">Please let me know of any questions you have or touch base here if you run into issues, I'm happy to help troubleshoot. <h2>Full script <pre><code>#!/bin/bash ################### ## SET VARIABLES ## ################### SERVER_NAME="witness" GIT_REPO="https://github.com/hive-engine/steemsmartcontracts.git" GIT_TAG=master ################## ## INIT UPDATES ## ################## apt-get update -y apt-get upgrade -y #################### ## INSTALL BASICS ## #################### apt install git -y apt-get -y install npm apt install ufw -y ################ ## CLONE REPO ## ################ mkdir -p /var/$SERVER_NAME cd /var/$SERVER_NAME git clone --recursive --branch $GIT_TAG $GIT_REPO ./ git checkout heRelease1.1 ###################### ## INSTALL FAIL2BAN ## ###################### apt-get -y install 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 ##################### ## INSTALL MONGODB ## ##################### cd /var/$SERVER_NAME wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list apt-get update -y apt-get -y -o Dpkg::Options::="--force-confold" install mongodb-org sed -i '/replication/a \ \ \ replSetName: "rs0"' /etc/mongod.conf sed -i 's/#replication/replication/g' /etc/mongod.conf systemctl stop mongod systemctl start mongod ################ ## RESTORE DB ## ################ cd /var/$SERVER_NAME wget http://api2.hive-engine.com/hsc_20210203_b50993579.archive mongo --eval "rs.initiate()" mongorestore --gzip --archive=hsc_20210203_b50993579.archive ############## ## SET SWAP ## ############## fallocate -l 2G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile ################## ## INSTALL NODE ## ################## curl -sL https://deb.nodesource.com/setup_14.x | -E bash - apt-get install -y nodejs apt-get -y install npm ################# ## FINAL SETUP ## ################# cd /var/$SERVER_NAME npm install dotenv npm i npm i -g pm2 sed -i 's/"startHiveBlock": 41967000/"startHiveBlock": 0/g' config.json sed -i 's/"witnessEnabled": false/"witnessEnabled": true/g' config.json ufw allow 5001 ##################### ## SET WITNESS KEY ## ##################### cat > /var/$SERVER_NAME/.env << EOF ACTIVE_SIGNING_KEY=5K... ACCOUNT=youraccount EOF
Sort:  

Great to see another hive engine witness join.

Thanks, I'm excited to see many more!

I was really hoping someone would do a script for it, nice work! !HYPNO !WINE


0.100 WINECheers, @dannychain You Successfully Shared With @blervin.
You Earned 0.100 WINE As Curation Reward.
You Utilized 1/3 Successful Calls.

wine-greeting


WINE Current Market Price : 1.200 HIVE

Thanks so much, I appreciate that!

Hey @blervin, here is your HYPNO ;)

Thats a real smart way to install everything. Bash are awesome :)

Haha, I agree, thanks!

Thanks for the guide @lassecash is now a HE witness. I voted for you, I might buy some workerbee within a few weeks.

Well thanks! My vote isn't worth much right now, but I did just bump you up above zero so you'll have a chance to produce some blocks now.

Thanks, btw my normal account is @lasseehlers, it was a mistake I wrote from @lassecash

Thanks for sharing. What spec machine would i need to run a witness node?

At least 2GB of memory, but in my testing I'd say go for 4GB, it hasn't proven reliable yet at 2GB. And a little less than 30GB of storage.

That's the way my friend !! @blervin

--

@frankbacon ☝️ can it be that easy!? 🤣🤣

Highly likely... I hope you and @frankscoms will find out the hard way... by doing it yourselves and seeing.

Screenshot 2021-02-09 at 12.41.08 PM.png

Hiya mate, anyway to contact you on discord?

Yup, hit me up at blervin#9759