Installing a Full API server with HF version 0.23.1 with MIRA

in #witness-category4 years ago (edited)

Yesterday for some reason our private API server collapsed for some reason we could not trace back to and hampered overall steem auto performance for a while . With the help of ther api endpoints provided by @ety001 @justyy and @symbionts we redirected all transactions broadcast to these servers .

However i almost forgot how i did the setup the Node a year back and could not do it for some reason . I was looking for a guide line and got very few resources regarding implementation . So i decided to write this post as a tutorial on how to setup steem api node using docker image provided by @ety001 and backup files provided by him as well.

The server i am using is pretty Ok and i got in on server auction in hetzner .

Specifications are as follows

Processor : Intel Xeon E5-1650V3
2x SSD SATA 960 GB Datacenter Grade
8x 16 GB DDR4 ECC registered Memory

Server is running on Ubuntu 20.10 Groovy

I will write this tutorila step by step and please forgive me for language mistakes as English is not my Native Language .

Provided that the server has the OS already installed lets begin with updating the packages in the server

[apt get update -y] --> this ill update the server with latest packages

after the update is finished lets start my installing required packages that might not be installed already

[apt install wget git lz4 docker.io] ---> this will install docker wget lz4 manage and git

Now we shall download the steem-docker-ex package originally created by someguy123 and modified by @ety001

[git clone https://github.com/ssdc-chain/steem-docker-ex.git]
move to the folder by changing directory
[cd steem-docker-ex]

once you are in the folder download the latest docker build from docker hub (Note this is mira enabled build )

[docker pull ety001/steem-full-mira:0.23.1]
[docker tag ety001/steem-full-mira:0.23.1 steem]

Once these files are downloaded we shall now download the recent blockchain data that will save us from replaying the chain since the replay takes a lot of days (probably 7 days or more )

assuming you are inside the same directory

copy the link from https://files.steem.fans/ which is again provided by @ety001 .
At the time of writing the recent file is dated 2021/05/06

there are multiple options to download this file

option A : Using axel tool
option B : using wget

As wget took me a lot of time to download this file i will do it via axel tool

to isntall axel [apt get install axel] will do the job .
[axel https://files.steem.fans/data/steem_api-20210506.tar.lz4]

this will take a quite of a time so i will suggest to download in a screen session just in case your ssh session gets disconnected and you will have to redownload again , Go grab some coffee.

.

option B is quite easy as well which was suggested to me by @dr-frankenstein but this took me a lot of time

[wget -c -qO- https://files.steem.fans/data/steem_api-20210506.tar.lz4 | lz4 -d | tar x] --> thi will somehow save you form extracting the lz4 and then the tarball by directly extracting to blockchain folder

Assuming option A is what we did
to extract the file
[lz4 steem_api-20210506.tar.lz4] - this will extract the file to a tar file .
Once the tar file is created we can delete the lz4 file to free us some space

to extract tar file we [tar -xvf steem_api-20210506.tar.lz4]

Once the process completes a folder will be visible with the name blockchain , here we are delete the tar file as well .

Once we have the blockchain folder we need to move it inside the steem-docker-ex data folder , to do so hit the below in the terminal
[rm -rf data/witness_node_data_dir/blockchain] --> this will delete the existing blockchain folder
then
[mv blockchain data/witness_node_data_dir/] --> this will move the downloaded data to the required directory

Once the move is finished assumimg you are inside the steem-docker-ex folder we need to update the config.ini file
I'll Suggest uing the standard configuration file @ety001 provided
[nano data/witness_node_data_dir/config.ini] and paste the content avilable here

https://hackmd.io/dp-ZAySaQVe1KlxOxXekkA

its time to start the chain
[./run.sh start] ---> this will start the docker container with name seed. Give it a moment to start . to view the progress you can do [./run.sh logs]

By this time your setup will have started syncing the blockchain .

we will leave this to sync while we do additional setup


To be able to provide API finctions directly on hhtps link without having the requirement of using ports we will now use jussi multiplexer and nginx .

Setting us jussi is quite easy

[cd ..] --> to get out of the existing socker directory

to clone the jussi repo

[git clone https://github.com/steemit/jussi.git]

once the clone is finished change directory to jussi [cd jussi]

to initaite jussi do this is a screen session
[screen -R jussi ]

then

[docker run -it --env JUSSI_UPSTREAM_CONFIG_FILE=/app/config.json -v /root/jussi/DEV_config.json:/app/config.json -p 8080:8080 steemit/jussi:latest]

once jussi has started you can detach from the screen by doing ctrl + A + D

to check if jussi is working or not
[
curl -s --data '{"jsonrpc":"2.0", "method":"condenser_api.get_block", "params":[8675309], "id":1}' http://localhost:8080]

if you get a response like transactions ID's and witness names, jussi configuration is okay . but we are still pointing jussi to https://api.steemit.com and our reuests are only being forwarded to steemit api . To allow jussi to communicate to our local node we need to stop jussi and do some changes .

[screen -r jussi] --> to goto jussi screen
hit Ctrl + C to stop jussi

then edit the config file [nano nano DEV_config.json]

file lines that will say https://api.steemit.com and replace with your docker ip which you can find by doing
[docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' seed

now once this part is finished we will head over and install nginx and ssl certificate

[apt install nginx]

once nginx is installed we will create a server block and use domain api.steemdb.online (whenver you see this domain name please change this to yourdomain.com)

create a new file called api.steemdb.online.com.conf in /etc/nginx/sites-available/

[nano /etc/nginx/sites-available/api.steemdb.online.conf]

paste the below configuration

server {
listen 80;
server_name api.steemdb.online;

location / {
proxy_pass http://localhost:8080;
}
}

once the file is ready change directory to /etc/nginx/sites-enabled/

and palse the below command
[ln -s ../sites-available/api.steemdb.online.conf .]

once it is done test the nginx configuration by doing [nginx -t ]
this command should show you

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

now our http server is ready

you can test api calls by going to https://fullapis.herokuapp.com/

the langugage is in chinese but you will understand most of the part .
to make the test short you can only test block_api at the moment

now lets install ssl certificate and automate it as well

[apt install certbot python3-certbot-nginx]

then once it is installed issue the below command to install ssl

[certbot --nginx -d api.steemdb.online] (dont forget to change your domain and also this domain should be pointed to your IP )

once the above steps are completed we shall have a fully working api server

few notes

  1. this configuration worked on only 2 servers out of 3 and one had some issues with jussi which i am figuring out and i also opened an issue on the jussi repo https://github.com/steemit/jussi/issues/230 --> if you know what it is please comment below
  2. sorry about the language
  3. jussi can be built and ran without screen . --> https://developers.steem.io/tutorials-recipes/jussi-multiplexer

cheers


Group 11.png


Group 14.png

vote me as a witness

https://steemconnect.com/sign/account-witness-vote?witness=steem-supporter&approve=1

Vote @justyy as a witness
https://steemconnect.com/sign/account-witness-vote?witness=justyy&approve=1

Vote @xpilar as a witness
https://steemconnect.com/sign/account-witness-vote?witness=xpilar.witness&approve=1

vote @ety001 as witness
https://steemconnect.com/sign/account-witness-vote?witness=ety001&approve=1

vote @symbionts as a witness
https://steemconnect.com/sign/account-witness-vote?witness=symbionts&approve=1

CC
@steemcurator01

Sort:  

I did not understand anything, what is this for?

if you don't understand this ,, then this is not for you
thanks
steem on

Hi bro. Steemdb.online doesn't work anymore today.

hello bro . i think it is working however , if it is not working for you , please join our discord and we can discuss further regarding your problem
https://discord.gg/K8kgym4ZXC

good posting!@

thanks .. hope it helps