Jump to content
Sign in to follow this  
buzzkillb

ElectrumX Server Setup Guide [Docker]

Recommended Posts

267

420 posts
24 BF$

I think this is an easier way to setup an electrumx server. It's not that bad once you go through the steps. Trying to be thorough.

Install docker

My github for this.
https://github.com/buzzkillb/docker-electrumx

We will end up running denariusd in a container and electrumx in a container.

First create a folder on your server or vps to store the denarius blockchain. This can be anywhere, but lets make this easy.

cd ~
mkdir .denarius
cd .denarius
nano denarius.conf

Sample denarius.conf, pay attention as we will need the rpcuser and rpcpassword.

rpcuser=denariusrpc
rpcpassword=MAKEUPSOMEPASSWORD
maxconnections=125
rpcport=32369
port=33369
daemon=0
listen=1
server=1
discover=1
txindex=1
bind=127.0.0.1:33369

We either sync from block 0 or use chaindata. You decide.

Now we can run the denariusd docker container.

docker run \
  --net=host \
  --name=denariusd \
  -t -d \
  -p 33369:33369 \
  -p 32369:32369 \
  -v ~/.denarius:/data \
  -P buzzkillb/denariusd:latest

To check the sync

docker logs denariusd -f

ctrl+c to exit out of that whenever

Now to run electrumx server (wait to be fully sync'd).

docker run \
  --name=electrumx \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://denariusrpc:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:latest

To watch these logs.

docker logs electrumx -f

Once running check it can be found.

openssl s_client -connect electrumx1.denarius.pro:50002

Working on an easy way to do the compaction.

If you stop the container and then run

docker run \
  --name=electrumx-compact \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://denariusrpc:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:dcompact

This will compact the database using Denarius environment variables.

With both containers electrumx and electrumx-compact both up, we can now add a cronjob to stop server, start compact, and restart server.

crontab -e

Run daily, this is overkill. Best to run every 14 days or less.

0 0 * * * docker stop electrumx >/dev/null 2>&1
1 0 * * * docker start electrumx-compact >/dev/null 2>&1
6 0 * * * docker start electrumx >/dev/null 2>&1

 

  • Like 2

If you enjoy my content please consider donating to the Denarius creator - https://www.patreon.com/carsenk
Join Denarius Discord - https://discord.gg/JQEmXwb

Share this post


Link to post
Share on other sites
267

420 posts
24 BF$

Updated dockerhub to latest v1.14.

To use rocksdb instead of leveldb add this to the run command for latest and dcompact under -e COIN=Denarius \

-e DB_ENGINE=rocksdb \

If in doubt do this to start over

docker stop electrumx
docker stop electrumx-compact
docker rm electrumx
docker rm electrumx-compact
rm -rf ~/electrumx

Then rerun the 2 run commands. Basically run the first, wait for full sync, then stop, run dcompact, stop and then run the first electrumx. Cronjob should take care of the rest from there.

  • Like 1

If you enjoy my content please consider donating to the Denarius creator - https://www.patreon.com/carsenk
Join Denarius Discord - https://discord.gg/JQEmXwb

Share this post


Link to post
Share on other sites
267

420 posts
24 BF$

What I wanted was to just run certbot without a webserver to get the signed keys and then stick them into the docker. Its very similar but with a couple extra steps.

First generate your certbot TLS key for your domain. You should already have changed your A record on whatever site you are using for domain records to match up to your vps IP. Cloudflare, godaddy, namecheap, afraid, etc.

Use certbot to install a standalone key without running nginx or apache.

https://certbot.eff.org/lets-encrypt/ubuntubionic-other

After this is done your keys will be in directories like this. Take note of the full path and filenames as this is what we are going to link in the docker run command.

/etc/letsencrypt/live/electrumx1.denarius.pro/fullchain.pem
/etc/letsencrypt/live/electrumx1.denarius.pro/privkey.pem

The docker run command looks like below. Basically linking the 2 host pem files directly into the container. And also passing an environment variable to pick those locations up. Original latest tag is being used.

docker run \
  --name=electrumx \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://rpcusername:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/fullchain.pem:/data/fullchain.pem \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/privkey.pem:/data/privkey.pem \
  -e SSL_CERTFILE=/data/fullchain.pem \
  -e SSL_KEYFILE=/data/privkey.pem \
  -e REPORT_SERVICES=ssl://electrumx1.denarius.pro:50002 \
  -e SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc:// \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:latest

Then the compaction one do something similar. Also updating this container so the compaction is just for rocksdb

docker run \
  --name=electrumx-compact \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://rpcusername:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/fullchain.pem:/data/fullchain.pem \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/privkey.pem:/data/privkey.pem \
  -e SSL_CERTFILE=/data/fullchain.pem \
  -e SSL_KEYFILE=/data/privkey.pem \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:rocksdbcompact

mental note: Using carsens pull request while we wait for official electrumx github to update to latest tribushashm.

to renew certbot in a cronjob

crontab -e

and put this line in at the end

52 0,12 * * * root /usr/bin/certbot renew

 

  • Like 1

If you enjoy my content please consider donating to the Denarius creator - https://www.patreon.com/carsenk
Join Denarius Discord - https://discord.gg/JQEmXwb

Share this post


Link to post
Share on other sites
267

420 posts
24 BF$

For some reason the SERVICES environment variable wasn't being passed through from the Dockerfile. So I set that in the docker run itself.

  -e REPORT_SERVICES=ssl://electrumx1.denarius.pro:50002 \
  -e SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc:// \

You can remove the tcp://:50001 to only allow ssl. Need to figure out tor next.

  • Like 1

If you enjoy my content please consider donating to the Denarius creator - https://www.patreon.com/carsenk
Join Denarius Discord - https://discord.gg/JQEmXwb

Share this post


Link to post
Share on other sites
267

420 posts
24 BF$

To test if TLS letsencrypt certificate is working. Samples below for a bash script. listunspent is using a scripthash from the D address, I will leave that up to the user's imagination how to get that.

(echo '{"method" : "blockchain.block.header", "params": ["1"], "id": "msg_id"}'; sleep 1) | ncat --ssl electrumx1.denarius.pro 50002
(echo '{"method" : "blockchain.scripthash.listunspent", "params": ["15617fccc9fd5379e5166108e217c55b54b6d9428f8a2f222221323982fe3537"], "id": "msg_id"}'; sleep 1) | ncat --ssl electrumx1.denarius.pro 50002 | jq '.'

 


If you enjoy my content please consider donating to the Denarius creator - https://www.patreon.com/carsenk
Join Denarius Discord - https://discord.gg/JQEmXwb

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...