Jump to content
Sign in to follow this  
J3ll3

Setting up multiple PAWS masternodes on one VPS

Recommended Posts

INTRODUCTION

This is not something that is commonly supported by teams and projects, also not in this case. It is not part of the standard install script and not something we want to use time on supporting. And besides that, the general idea of the blockchain is also to have many masternodes spread out over the network, that are independant from each other to make the network as resilient as it can be through decentralisation. Combining masternodes on 1 VPS and even with one provider will introduce a centralisation to the network that in principle is unwanted and not good for the stability of the network and the blockchain. Imagine that 1 provider lost internet, taking 50 masternodes down. If that network only had 100 masternodes to begin with, it would mean that with 1 event 50% of the masternodes would go down. In that case the network is not very centralised and very easy to target with a denial of service attack. That becomes even worse, when you start combining masternodes on the same server. One software update could render a whole stack of masternodes useless, which is bad for the network and bad for the investor loosing rewards.

Having said that... it is possible to run multiple masternodes on 1 VPS or server. The common approach to this, is by ordering extra IP addresses for the VPS from the hosting provider. Each masternode service can then be attached to an IP address. An extra IP address is often cheaper that getting an additional VPS and will therefore make a difference for those of your that have many masternodes.

This document is provided as is and for the sake of proving that it can be done. Questions can be asked in Discord or here in the forum, but since it is not our supported method of installing a masternode we can choose to limit the amount of time supporting this.

1. ADDING ADDITIONAL IP ADDRESSES

I'm assuming that the first masternode is running already on the primary IP address that the vps was created with. The first masternode can be installed using the standard installation script. The masternode will be running under the root user and the data directory will be placed in /root/.paws. I'm assuming this a Ubuntu 16.04 distribution, which is also required for our installation script.

  1. The first step is to order an additional IP address from your VPS provider. Lets assume for this document you got 1.1.1.2 255.255.255.0
     
  2. Find out what your network interface is called. Execute the following command: ip a

    The output might be as follows:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2:
    ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 52:54:44:af:14:c1 brd ff:ff:ff:ff:ff:ff
        inet 1.1.1.1/24 brd 1.1.1.255 scope global ens3
           valid_lft forever preferred_lft forever


    Make a note of the name of the network interface, in this case "ens3".
     
  3. Open the following file in the nano text editor: nano /etc/network/interfaces

    IMPORTANT: STEP 4 and 5 are for generic Ubuntu 16.04 systems. Use sted 6 and 7 instead if you are using Vultr as a VPS provider!!
     
  4. [SKIP IF ON VULTR] Now you will probably see something like this:

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    source /etc/network/interfaces.d/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    allow-hotplug ens3
    iface ens3 inet static
            address 1.1.1.1/24
            gateway 1.1.1.1
            # dns-* options are implemented by the resolvconf package, if installed
            dns-search test.com

  5. [SKIP IF ON VULTR] Add the following lines and close and save the file by pressing Control-X, followed by Y (as in Yes):

    iface ens3 inet static
            address 1.1.1.2/24

  6. [FOR VULTR] You will probably see something like this:

    source /etc/network/interfaces.d/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto ens3
    iface ens3 inet dhcp
    iface ens3 inet6 dhcp

  7. [FOR VULTR] Change it so it looks like this. This configuration was taken from the Vultr website and appears to work:

    source /etc/network/interfaces.d/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto ens3
    iface ens3 inet static
      address
    <your primary ip>
      netmask <your netmask>
      gateway <your gateway>
      dns-nameservers 108.61.10.10
      post-up ip route add 169.254.0.0/16 dev ens3

    auto ens3:1
    iface ens3:1 inet static
      address
    <secondary ip>
      netmask <netmask same as above>

    Correct the test marked in red. In the Vultr dashboard, you should have a section where you can see IP addresses.

     

  8. The easiest thing to do now, is reboot the VPS. Once it returns, make sure that you primary masternode is running again:

    paws-cli getmasternodestatus

    As usual, it should indicate a status 4!!

  9. Confirm if the new IP address has been added to the server, by repeating the following command: ip a

    The output should now look as follows:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 52:54:00:af:14:c1 brd ff:ff:ff:ff:ff:ff
        inet 10.0.30.177/24 brd 10.0.30.255 scope global ens3
           valid_lft forever preferred_lft forever

        inet 10.0.30.178/24 brd 10.0.30.255 scope global secondary ens3
           valid_lft forever preferred_lft forever


Congratulations. You have now added a second IP address to the VPS.

2. INSTALLING THE SECOND PAWS MASTERNODE

Since the installation script was not made to install a second masternode, we will have to do this one by hand. The prerequisites are already on the VPS, since we used the script to install the first masternode, so this should not be very hard.

The important thing here, is that we need to keep the data directories for all the PAWS masternodes separate to avoid them from overwriting each others files. We can do this by making a separate user for each PAWS masternode process, or alternatively we run all users as the root user and specify different data directories on the command-line when we execute the "pawsd" and "paws-cli" commands. In my experience, this is a personal preference. With regards to scripting, it will be easier to have it all running under 1 user... my personal preference is to have each process running under a separate user. That way we can use the usual commands without specifying the correct data directory, we simply have to remember to connect to the correct user. This setup will therefor create a new user for the new PAWS masternode instance.

  1. Create a new user: adduser paws2

    You will have to enter information for this new user, starting by entering the password for this user twice, the remainder of the questions can be answered by pressing enter. The final question will be if all information was correct, press Y or Enter

    The output will look as follows:

    Enter new UNIX password: 
    Retype new UNIX password: 
    passwd: password updated successfully
    Changing the user information for test
    Enter the new value, or press ENTER for the default
        Full Name []: 
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
    Is the information correct? [Y/n]


    A new user is now created. That user has it's own home directory which is located here:

    /home/paws2

     
  2. We will now change to that user and start setting the new masternode up. The software was already installed by the script when we setup the first masternode. So... we change user as follows:

    su - paws2

    We are now placed inside the users home directory, /home/paws2, which is exactly what we want.
     
  3. There is no need to install the software, as it was already installed earlier. We simply need to create a paws.conf file for configuration and start the masternode as "paws2" user. This will make the software detect that no ".paws" data directory exists, and will start downloading the blockchain. It is important to note, that each masternode installed on this VPS, will use diskspace to store its own copy of the blockchain.

    The first thing we do, is create the data directory for the new instance:

    mkdir .paws
     
  4. Before we configure, we need to collect some information we need in the next step:

    - Create or generate a password that is NOT the same as on the first masternode. Not something you need to remember.
    - Find and note down your secondary IP address
    - Generate a genkey in the local wallet in the next step and have it ready for step 7.
     
  5. In your local wallet, open Tools - Debug Console and type the following:

    masternode genkey

    it will produce a key in the following format: 7iHZk6GdTCn45BCj7fnAnxwHyue3RtWQFfi174iopFpnRGHikWn

    Make a note, we need it in step 7 on the VPS.

     
  6. And create the the configuration file. Open an editor:

    nano .paws/paws.conf
     
  7. Copy the following contents in the file:

    rpcuser=rpcuser
    rpcpassword=
    <password_mn2>
    rpcport=34126
    rpcallowip=127.0.0.1
    listen=1
    server=1
    daemon=1
    port=34120
    logintimestamps=1
    maxconnections=256
    bind=
    1.1.1.2
    masternode=1
    externalip=
    1.1.1.2:34120
    masternodeprivkey=
    <genkey_created_in_local_wallet>

    #ADDNODES
    addnode=155.94.152.168:52362
    addnode=155.94.152.168:52636
    addnode=167.99.212.248:34120
    addnode=173.199.115.155:34120
    addnode=185.127.48.126:56534
    addnode=192.3.162.117:58934


    Items in red, need to be modified. The password is random, the IP address is the secondary IP address and the masternodeprivkey is the string generated in step 5.

    After you have made the modifications you exit and save the file by pressing Control-X, followed by Y
     

  8. The next step involves creating a statup file as root, to make sure that the second masternode automatically starts after a reboot. We exit from the "paws2" user and return to being "root":

    exit

  9. The prompt should now indicate that your are the root user again (prompt looks like root@myvps:/)

  10. We open a file called PAWS2.services in /etc/systemd/system as follows. The first masternode is started by a file called PAWS.services. We will add a file like that for each masternode we want to start on this VPS:

    nano  /etc/systemd/system/PAWS2.service

  11. Add the following contents in the file:

    [Unit]
    Description=PAWS2 service
    After=network.target
    [Service]
    User=paws2
    Group=paws2
    Type=forking
    #PIDFile=/home/paws2/.paws/PAWS.pid
    ExecStart=/usr/local/bin/pawsd -daemon -conf=/home/paws2/.paws/paws.conf -datadir=/home/paws2/.paws
    ExecStop=/usr/local/bin/paws-cli -conf=/home/paws2/.paws/paws.conf -datadir=/home/paws2/.paws stop
    Restart=always
    PrivateTmp=true
    TimeoutStopSec=60s
    TimeoutStartSec=10s
    StartLimitInterval=120s
    StartLimitBurst=5
    [Install]
    WantedBy=multi-user.target

    Notice text in red... it will have to be modified for this particular instance we are installing. It tells the system to start this masternode from the instance in /home/paws2 and run it as user "paws2" and not as root.

    Once you have done that... press Control-X, followed by Y to save and exit.

  12. We now tell the system, to start this process automatically at reboot:

    systemctl enable PAWS2
     

  13. We are now very close to starting the second masternode for the first time, by issuing the following command:

    systemctl start PAWS2
     

  14. The second masternode should now be synchronising. Change user to "paws2" as follows:

    su - paws2

    All the commands we are used to, we execute as the "paws2" user now which sees the world relative to its own home directory. So as long as we are user "paws2" we will be looking at and talking to the second instance of the masternode that is attached to the second IP address (see step 7).

  15. Lets start by making sure the masternode synchronises:

    paws-cli getblockcount

    Keep repeating this command, until the number it displays is the same as the current blockheight on our explorer: http://chain.paws.fund

  16. Right... you don't continue here, before the blockchain is fully synchronised 🙂 We now restart the process, by stopping it. The service will automatically make sure the masternode instance is started again quickly after. Issue the following command:

    paws-cli stop
     

  17. Wait for 1-2 minutes... then issue the following command:

    paws-cli getmasternodestatus

    It should return the following:

    error: {"code":-1,"message":"Masternode not found in the list of available masternodes. Current status: Not capable masternode: Hot node, waiting for remote activation."}

  18. You should now return to the local wallet, and add a line to the masternode.conf file as you would have done for any new masternode. Make sure you have another 1000 PAWS in your wallet and that you have a txid available. This is not specific to this guide and you should look at the masternode installation guide when you are in doubt. Add the following line. The genkey is the one generated in step 5. txid and index should come from the local wallet. The IP address is the secondary IP you have configured on the VPS:

    MN2
    1.1.1.2:34120 <genkey> <txid> <index>

  19. Once this is done... restart the local wallet. And once it is back, start the masternode from the masternode tab. If you face the invalid IP error, the start the masternode from the debug console as follows: Tools - Debug Console and type:

    startmasternode alias 0 MN2

  20. Now return to the VPS (still logged in as paws2) and issue the command:

    paws-cli getmasternodestatus

    It should return a status 4, for the second instance of the masternode.

 

You have now completed the setup of the second masternode on the same VPS, using a secondary IP address.
 

Now remember to be logged on as the relevant user for each masternode. The above setup has left the first masternode in the "root" account, meaning that you can communicate with it as usual.

When you want to look at the status and manipulate the second masternode, you need to switch user to the user we created to run that second masternode:

su - paws2

will be the command you are looking for. Now, when you run the usual commands, you will be referring to and manipulating the second masternode. Needless to say, that you could add a 3rd IP address, and if there is enough RAM and diskspace, you could create a 3rd user (paws3) and do the same thing again.

Good luck!

Share this post


Link to post
Share on other sites
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.