Welcome to the Dash Forum!

Please sign up to discuss the most innovative cryptocurrency!

Multiplexing masternodes on single VPS

Discussion in 'Masternode Guides' started by xkcd, Mar 14, 2020.

  1. xkcd

    xkcd Member
    Masternode Owner/Operator

    Feb 19, 2017
    Likes Received:
    Trophy Points:
    Dash Address:
    This guide will attempt to show you how you can run more than one Masternode (MN) on a single VPS a technique I call multiplexing. To save space due to data redundancy the masternodes will share a common blockchain. The guide assumes you have setup your masternode as per guide https://www.dash.org/forum/threads/...e-setup-with-systemd-auto-re-start-rfc.39460/ and uses the VULTR hosting provider, because they offer additonal IPs for your hosting.

    Starting with your existing running masternode created from my guide, goto your admin panel on VULTR and add another IPv4 IP.


    Next as the dashadmin user click on 'networking configuration' on vultr and copy and paste the text for the latest Ubuntu build as described on thatpage for your OS.


    After updating /etc/netplan/10-ens3.yaml with your new IP apply the changes and reboot the VPS.

    sudo netplan apply
    sudo reboot
    ssh back into the machine and test the new network by trying to ssh on it, eg.

    ssh [email protected]<new IP>
    You should see a prompt asking you to confirm the security fingerprint of the server (yes/no). If you see that, then your IP is working correctly, otherwise you need to troubleshoot your VPS before continuing with this guide....

    Next we create some new users, one for the second DASH MN and the other for the common files (blocks) that both MNs will share.

    As dashadmin,

    sudo useradd -m -c dash02 dash02 -s /bin/bash
    sudo useradd -m -c dash-common dash-common -s /usr/sbin/nologin
    sudo usermod dashadmin -a -G dash02,dash-common
    sudo usermod dash -a -G dash-common
    sudo usermod dash02 -a -G dash-common
    Now we set a hard password for the new users, you do not have to write these down, you will never need them.

    < /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo
    sudo passwd dash02
    < /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo
    sudo passwd dash-common
    Next, we create directories and set permissions.

    sudo mkdir -p /home/dash-common/.dashcore/blocks
    sudo chown -v -R dash-common.dash-common /home/dash-common/
    sudo chmod -v -R g+wxr /home/dash-common/
    Next, shutdown the running dashd and move the common files to the shared user, create a few links back to these files and restart the node...

    Run the below as the dashadmin user
    sudo systemctl stop dashd
    Sudo to the dash user and run the rest.

    sudo su - dash
    # Creates a variable of the list of files (blocks) we need to copy over, excluding the current block, which is still being written into.
    files=$(ls /home/dash/.dashcore/blocks/blk*dat|head -$(($(ls /home/dash/.dashcore/blocks/blk*dat|wc -l)-1)))
    # Move the blocks over to the common location
    for f in $files;do mv -v $f /home/dash-common/.dashcore/blocks/;done
    # Now the dash user will create symlinks back to those files to replace the moved ones.
    cd ~/.dashcore/blocks/
    for f in /home/dash-common/.dashcore/blocks/*;do ln -vs $f $(basename $f);done
    Now, while the dashd is still down, we need to change the dash.conf file slightly.
    Ensure the externalip is set like normal, but also set a new parameter called
    bind= to the same IP, this is your orginal node. Then add a new parameter like below

    nano ~/.dashcore/dash.conf
    As the dashadmin user, update the file permisssions once more.

    sudo chown -v -R dash-common.dash-common /home/dash-common/
    sudo chmod -v -R g+wrx /home/dash-common/.dashcore/blocks/
    Restart the dashd as the dashadmin user....

    sudo systemctl start dashd
    Verify that the dashd has restarted successfully before moving on, otherwise troubleshoot your changes.

    Initialise, the second masternode, this will be a clone of the other masternode, but we will update the details in the dash.conf shortly.

    Stop the dashd daemon once more and copy the files over. :)
    Remove some stale cache files that would conflict with the original node, these will be rebuilt. note the below rm command will remove wallets, you should not have any dash stored on a MN anyway, but make sure that is the case before proceeding. o_O

    sudo systemctl stop dashd
    sudo cp -va /home/dash/.dashcore /home/dash02
    sudo chown -v -R dash02.dash02 /home/dash02/
    sudo rm -fr /home/dash02/.dashcore/{.lock,d*.log,*.dat} /home/dash02/.dashcore/backups/

    Now that the data has been copied over, you can again restart the orginal node as the dashadmin user....
    sudo systemctl start dashd
    Since, the dash02 is a clone of the first node, we need to enter the specifics for this node, edit the dash.conf file like so.

    sudo nano /home/dash02/.dashcore/dash.conf
    and the things you need to change are listed below.


    Change the RPC port to 9997, although you can choose another number larger than 1024 that the system is not currently using... Make sure the bind and externalip are both set to your new (second) IP and that rpcuser/password are set to something different than the original node, also place the bls key for the new masternode too.

    Now we setup up a systemd unit file for this second node so it starts and shuts down automatically.
    The below should be run as the dashadmin user.

    sudo mkdir -p /etc/systemd/system&&\
    sudo bash -c "cat >/etc/systemd/system/dashd02.service<<\"EOF\"
    Description=Dash Core Daemon (2)
    After=syslog.target network-online.target
    ExecStart=/opt/dash/bin/dashd -pid=/home/dash02/.dashcore/dashd.pid
    ExecStop=/opt/dash/bin/dash-cli stop
    I have removed the comments from the above file to condense it, but it is very similar to the one used to start/stop the other dashd.

    Next, we register the file with systemd and start the daemon.

    sudo systemctl daemon-reload &&\
    sudo systemctl enable dashd02 &&\
    sudo systemctl start dashd02 &&\
    echo "Dash02 is now installed as a system service and initializing..."
    #1 xkcd, Mar 14, 2020
    Last edited: Mar 14, 2020
  2. xkcd

    xkcd Member
    Masternode Owner/Operator

    Feb 19, 2017
    Likes Received:
    Trophy Points:
    Dash Address:
    Make sure you install sentinel :mad:

    run the below as the dash02 user !

    sudo su - dash02

    cd &&\
    git clone https://github.com/dashpay/sentinel &&\
    cd sentinel &&\
    virtualenv venv &&\
    venv/bin/pip install -r requirements.txt &&\
    venv/bin/py.test test &&\
    venv/bin/python bin/sentinel.py
    # Add a crontab entry.
    echo "*/10 * * * * { test -f ~/.dashcore/dashd.pid&&cd ~/sentinel && venv/bin/python bin/sentinel.py;} >> \
     ~/sentinel/sentinel-cron.log 2>&1" \
    |crontab -&&echo "Successfully installed cron job."

    Verify the daemons are running in top, also at this time, make sure you have executed the protx 3-part shuffle to register your new MN on the DASH network.


    Let's check the nodes are bound to the correct IPs.
    As the dashadmin user...
    echo "dash....."
    sudo grep "Bound\|AddLocal" /home/dash/.dashcore/debug.log
    echo "dash02....."
    sudo grep "Bound\|AddLocal" /home/dash/.dashcore/debug.log
    What you should see is the second node is bound to a different (secondary) IP.

    On my system I have the folowing disk space being used.


    Notice that there is 14GB which is common to both installations, so I effectively saved 14GB of disk space, if I were to spin up a third node, I would only need another 5 GB to do so.


    I still have 45 GB to go, plenty for growth and another node. o_O

    RAM usage is looking fine too, if I run low, I would increase the swap space rather than adding costly RAM. :cool:


    DASH is generally not a CPU bound app, it tends to be memory hungry and disk hungry.

    I hope you've enjoyed the guide!
    Leave a like and a comment. :D
    #2 xkcd, Mar 14, 2020
    Last edited: Mar 14, 2020
    • Like Like x 2