Mining Pool Setup
- Pool files are released as is with no guarantees and we do not provide support for anybody using them.
- Running a pool is tough and requires some systems administration skills.
- Yiimp based pool files are here: https://github.com/npq7721/gr_pool
Video Guide
Video Guide - credit @timy_gProcedures:
1. Begin Pool Setup
Add a sudo user
adduser yerbas
Add user to sudo group
sudo usermod -aG sudo yerbas
Switch to user
su - yerbas
Run system update
sudo apt update -y
sudo apt upgrade -y
sudo reboot
Get yerbasd and get it syncing while we do the rest of the setup:
wget https://github.com/The-Yerbas-Endeavor/yerbas/releases/download/v2.1.1.4/https://github.com/The-Yerbas-Endeavor/yerbas/releases/download/v2.1.1.4/yerbas-ubuntu20-2.1.1.4.tar.gz
tar -xvf yerbas-ubuntu20-2.1.1.4.tar.gz
mv yerbas-build yerbas_live
Create yerbas data directory and .conf file
mkdir ~/.yerbascore
nano ~/.yerbascore/yerbas.conf
Add these lines changing the user and password:
rpcuser=yerbas420
rpcpassword=ehu489fkndc
rpcallowip=127.0.0.1
rpcport=8777
daemon=1
listen=1
Start up yerbasd:
~/yerbas_live/./yerbasd
Get the pool:
wget https://github.com/josajosjos/EasyNOMP_RTM && tar xzvf rtm_easynomp.tar.gz
2. Install Redis
apt repo is usually far behind the latest stable version of Redis so we will compile from source as well as do a little tweaking.
sudo apt install build-essential tcl pkg-config -y
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
cd redis-stable
make -j2
-j2 tells make how many cpu cores to use, default is 1 and it is slow, change it as needed depending on your available cores. Not sure how many cores? Do:
lscpu | grep 'CPU(s):'
make -j2 test
make install
sudo mkdir /etc/redis
sudo cp redis.conf /etc/redis
nano /etc/redis/redis.conf
Change supervised no
to supervised systemd
Change dir ./
to dir /var/lib/redis
Create systemd file
sudo nano /etc/systemd/system/redis.service
add the following:
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
Create a system user and group for redis user:
sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis
sudo chown redis:redis /var/lib/redis
sudo chmod 770 /var/lib/redis
Start Redis
sudo systemctl start redis
Check Redis Status:
sudo systemctl status redis
If status is good, enable redis so it automatically starts on a reboot:
sudo systemctl enable redis
3. Tweaking Redis
Switch to root user
sudo su
Run command
sudo echo 1024 > /proc/sys/net/core/somaxconn
The return should be just an empty line as if you had just hit enter. If so do the following:
nano /etc/sysctl.conf
Add these lines exit and save:
#Redis tweak
net.core.somaxconn=65535
vm.overcommit_memory=1
While we are root lets make a swap file of 2GB size:
dd if=/dev/zero of=/swapfile bs=2048 count=1048576
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
nano /etc/fstab
Add this:
/swapfile swap swap defaults 0 0
Reboot the server.
4. Install dependencies
Install node, npm, and pm2
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs -y
Verify nodejs version:
node --v
This will also have installed npm. Now install PM2:
sudo npm i -g pm2
5. Quick Pool Configuration
Create config file:
cp config_example.json config.json
Edit pool_configs/yerbas.json as needed, make sure user and password matches what you have in ~/.yerbascore/yerbas.conf
.
Install certbot and set good paths to certs in config.json:
Make sure you have the a-record / sub-domain you will be using pointed at the pool server IP. If using cloudflare make sure the connection is not proxied yet (orange cloud > white in DNS).
Install dependencies and certbot:
sudo add-apt-repository ppa:certbot/certbot
sudo apt update -y
sudo apt upgrade -y
sudo apt install certbot -y
Before we go any further lets make sure we have UFW installed / enabled and setup correctly. I will assume here that ufw is not installed:
sudo apt install ufw -y
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 3008/tcp
sudo ufw allow 19979/tcp
sudo ufw enable
Run certbot:
sudo certbot certonly --standalone -d your.pooldomain.here
Copy the paths to your shiny new certs, mine in this guide looked like:
/etc/letsencrypt/live/dpool.yerbas.org/privkey.pem
/etc/letsencrypt/live/dpool.yerbas.org/fullchain.pem
Update the existing paths in config.json to match these.
Start pool from inside EasyNOMP directory:
sudo pm2 start init.js --name "pool"
Confirm it started
sudo pm2 list
If you really don't want to run it as root there are ways around it but I am not going to cover them here. Easiest might be to change the https/http port to unprivledged ports (above 1023) and then proxy with nginx to the normal 443/80.
6. Secure SSH With Fail2Ban
Install
apt install fail2ban -y
Configure
nano /etc/fail2ban/jail.local
Add the following
[sshd]
enabled = true
port = 22
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
Restart Fail2ban:
systemctl restart fail2ban