Merge pull request #1611 from hunicus/refine-prod-readme

Refine production deployment doc
This commit is contained in:
wiz 2022-05-09 15:19:49 +09:00 committed by GitHub
commit 953f9405fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,18 +1,22 @@
# mempool enterprise production instance # Deploying an Enterprise Production Instance
These instructions are for setting up a serious production mempool website for Bitcoin mainnet, testnet, signet, Liquid mainnet and testnet, and Bisq. For home users, you should use one-click installation methods instead, and for advanced manual deployments of mainnet only see the top-level installation instructions. These instructions are for setting up a serious production Mempool website for Bitcoin (mainnet, testnet, signet), Liquid (mainnet, testnet), and Bisq.
Again, this setup is no joke—home users should use [one of the other installation methods](../#installation-methods).
### Server Hardware ### Server Hardware
Mempool V2 is powered by blockstream/electrs, which is a beast. I recommend a beefy server: Mempool v2 is powered by [blockstream/electrs](https://github.com/Blockstream/electrs), which is a beast.
* 20C CPU (more is better) I recommend a beefy server:
* 64G RAM (more is better)
* 20-core CPU (more is better)
* 64GB RAM (more is better)
* 4TB SSD (NVMe is better) * 4TB SSD (NVMe is better)
### HDD vs SSD vs NVMe ### HDD vs SSD vs NVMe
If you don't have a fast SSD or NVMe backed disk, that's fine. What you do is, go online and buy some fast new NVMe drives and wait for them to arrive. After you install them, throw away your old HDDs and then proceed with the rest of this guide. If you don't have a fast SSD or NVMe-backed disk, that's fine—go online and buy some fast new NVMe drives. When they arrive, install them, throw away your old HDDs, and then proceed with the rest of this guide.
## FreeBSD 13 ## FreeBSD 13
@ -29,7 +33,7 @@ nvm 3.62T 1.25T 2.38T - - 2% 34% 1.00x ONLINE
nvd1p3 1.81T 646G 1.18T - - 2% 34.8% - ONLINE nvd1p3 1.81T 646G 1.18T - - 2% 34.8% - ONLINE
``` ```
For maximum flexibility of configuration, I recommend partitions separately for each data folder: For maximum flexibility of configuration, I recommend separate partitions for each data folder:
``` ```
Filesystem Size Used Avail Capacity Mounted on Filesystem Size Used Avail Capacity Mounted on
nvm/bisq 766G 1.1G 765G 0% /bisq nvm/bisq 766G 1.1G 765G 0% /bisq
@ -76,9 +80,9 @@ You'll probably need these:
pkg install -y zsh sudo git screen curl wget neovim rsync nginx openssl openssh-portable py38-pip py38-certbot-nginx boost-libs autoconf automake gmake gcc libevent libtool pkgconf mariadb105-server mariadb105-client pkg install -y zsh sudo git screen curl wget neovim rsync nginx openssl openssh-portable py38-pip py38-certbot-nginx boost-libs autoconf automake gmake gcc libevent libtool pkgconf mariadb105-server mariadb105-client
``` ```
### NodeJS / npm ### Node.js + npm
I recommend to build nodejs / npm from source using nvm: Build Node.js v16.10 and npm v7 from source using `nvm`:
``` ```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh
source $HOME/.zshrc source $HOME/.zshrc
@ -88,14 +92,14 @@ nvm alias default node
### Rust ### Rust
I recommend to build rust from latest source: Build Rust from latest source:
``` ```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
``` ```
### Tor ### Tor
Install tor, add Bitcoin to _tor group: Install Tor add Bitcoin to the `_tor` group:
``` ```
pkg install -y tor pkg install -y tor
pw user mod bitcoin -G _tor pw user mod bitcoin -G _tor
@ -134,7 +138,7 @@ Build [Bitcoin Core](https://github.com/bitcoin/bitcoin) from source. Alternativ
pkg install -y bitcoin-daemon bitcoin-utils pkg install -y bitcoin-daemon bitcoin-utils
``` ```
Configure your bitcoin.conf like this: Configure your `bitcoin.conf` like this:
``` ```
datadir=/bitcoin datadir=/bitcoin
server=1 server=1
@ -173,12 +177,12 @@ Build [Elements Core](https://github.com/ElementsProject/elements) from source:
``` ```
./autogen.sh ./autogen.sh
MAKE=gmake CC=cc CXX=c++ CPPFLAGS=-I/usr/local/include \ MAKE=gmake CC=cc CXX=c++ CPPFLAGS=-I/usr/local/include \
./configure --with-gui=no --disable-wallet ./configure --with-gui=no --disable-wallet
gmake -j19 gmake -j19
gmake install gmake install
``` ```
Configure your elements.conf like this: Configure your `elements.conf` like this:
``` ```
server=1 server=1
daemon=1 daemon=1
@ -218,7 +222,7 @@ addnode=liquidtestnet.com:18891
addnode=liquid.network:18444 addnode=liquid.network:18444
``` ```
Start elementsd and wait for it to sync the Liquid blockchain. Start `elementsd` and wait for it to sync the Liquid blockchain.
### Electrs ### Electrs
@ -240,7 +244,7 @@ You'll need one instance per network. Build and run them one at a time:
### MariaDB ### MariaDB
Import historical mempool fee database snapshot: Import the historical mempool fee database snapshot:
``` ```
mysql -u root mysql -u root
create database mempool; create database mempool;
@ -263,29 +267,29 @@ Build bisq-statsnode normally and run using options like this:
./bisq-statsnode --dumpBlockchainData=true --dumpStatistics=true ./bisq-statsnode --dumpBlockchainData=true --dumpStatistics=true
``` ```
If bisq is happy, it should dump JSON files for Bisq Markets and BSQ data into /bisq that the mempool backend will use. If Bisq is happy, it should dump JSON files for Bisq Markets and BSQ data into `/bisq` for the Mempool backend to use.
### Mempool ### Mempool
After all 3 electrs instances are fully indexed, install your 3 mempool nodes: After all 3 electrs instances are fully indexed, install your 3 Mempool nodes:
``` ```
./mempool-install-all ./mempool-install-all
./mempool-upgrade-all ./mempool-upgrade-all
``` ```
Finally, start your 3 mempool backends: Finally, start your 3 Mempool backends:
``` ```
./mempool-start-all ./mempool-start-all
``` ```
### Nginx ### Nginx
Get SSL certificate using certbot: Get an SSL certificate using `certbot`:
``` ```
certbot --nginx -d mempool.ninja certbot --nginx -d mempool.ninja
``` ```
Make a symlink from /usr/local/etc/nginx/mempool to /mempool/mempool, and copy the nginx.conf and edit as necessary. You probably only need to edit the top-level nginx.conf file. Make a symlink from `/usr/local/etc/nginx/mempool` to `/mempool/mempool`, copy the `nginx.conf`, and edit as necessary. You probably only need to edit the top-level `nginx.conf` file.
``` ```
cd /usr/local/etc/nginx cd /usr/local/etc/nginx
ln -s /mempool/mempool ln -s /mempool/mempool
@ -293,11 +297,11 @@ cp /mempool/mempool/nginx.conf .
vi nginx.conf vi nginx.conf
``` ```
Restart nginx Restart `nginx`:
``` ```
service nginx restart service nginx restart
``` ```
### Done ### Done
Your site should look like https://mempool.space/ If everything went well, your site should look like the one at https://mempool.space/.