Skip to content

Setting up a Hub

Alex Grin edited this page Jan 11, 2023 · 37 revisions

Server Setup

create a VPS

We recommend a server running Ubuntu 20.04 LTS with 16 vCPU, 32G RAM, and a 500GB SSD drive. As a benchmark, on Jan 2023 this setup costs about $100 a month and uses about 400GB of disk space.

For the setup below we used a c5.4xlarge AWS instance, but we've also used this same setup on OVH servers. Most providers should work.

create lbry user

sudo adduser lbry --disabled-password --gecos ""
sudo -H -u lbry bash -c 'mkdir -p /home/lbry/.ssh && echo "YOUR-SSH-KEY" >> /home/lbry/.ssh/authorized_keys'
sudo -H -u root bash -c 'echo "lbry ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers'

logout and log in as lbry user

install docker

https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo service docker start
sudo usermod -aG docker $USER
newgrp docker
sudo systemctl enable docker.service
sudo systemctl enable containerd.service

create lbcd and rocksdb volumes

mkdir -p /home/lbry/docker-volumes/lbcd /home/lbry/docker-volumes/rocksdb
# sudo chown -R 999:999 /home/lbry/docker-volumes  ## not needed unless you encounter problems 
docker volume create --driver local --opt type=none --opt device=/home/lbry/docker-volumes/lbcd --opt o=bind lbry_lbcd
docker volume create --driver local --opt type=none --opt device=/home/lbry/docker-volumes/rocksdb --opt o=bind lbry_rocksdb

LBCD

download lbcd snapshot

sudo apt install -y zstd
cd /home/lbry/docker-volumes/lbcd
wget -c https://snapshots.lbry.com/blockchain/lbcd_snapshot_1238238_v0.22.116_2022-10-07.tar.zst -O - | tar --zstd -x
sudo chown -R 999:999 .
cd ~

download docker-compose.yml

https://github.com/lbryio/hub/wiki/docker-compose.yml

remember to remove markdown if downloading directly from that url

start lbcd first and let it catch up

docker compose up -d lbcd

wait for it to sync fully (how will they know?)

Scribe

download scribe snapshot

cd /home/lbry/docker-volumes/rocksdb
wget -c https://snapshots.lbry.com/hub/block_1288882/lbry-rocksdb.tar -O - | tar -x
sudo chown -R 999:999 .
cd ~

start scribe and let it sync

scribe sync takes about a week if you sync from scratch, or an hour or two if you use a recent snapshot

docker compose up -d scribe

wait for it to sync

Elastic Sync

then start elastic sync and wait for that

docker compose up -d scribe_elastic_sync

wait for it to sync

Herald

Monitoring

start prometheus and grafana

do this to check that everything is working

Federation

Clone this wiki locally