Skip to content

Instantly share code, notes, and snippets.

@esell
Last active December 7, 2017 04:11
Show Gist options
  • Select an option

  • Save esell/fdf7050cf49db15550fcd433ee5ef8fe to your computer and use it in GitHub Desktop.

Select an option

Save esell/fdf7050cf49db15550fcd433ee5ef8fe to your computer and use it in GitHub Desktop.
Setup a multi-node private etherum cluster

PRE-REQs

  • VMs should be ubuntu
  • your boot node should have the hostnamne "bootnode".
  • create at least 3 VMs, one boot node, one member node and one miner node

Setup boot node

The boot node will be the brains and what the other nodes talk to in order to find members of your cluster. The below steps will set it up so that you can use it later.

sudo apt-get update

sudo apt-get -y upgrade

sudo apt-get install software-properties-common

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo apt-get update

sudo apt-get install ethereum

mkdir bootstrap && cd bootstrap

wget https://raw.githubusercontent.com/esell/ethcluster/master/bootstrap/genesis.json

geth init bootstrap/genesis.json

bootnode -genkey bootstrap/boot.key -writeaddress

bootnode -nodekey bootstrap/boot.key -writeaddress > bootstrap/boot_address

bootnode -nodekey bootstrap/boot.key

Setup member and miner nodes

Instead of doing the steps manually, below is a script you can use. If you are setting up a member node you'll do script.sh member. If you don't pass a node type it'll assume you want a miner node.

In order for this to work automagically you will need the boot_address file from your boot node. This will be in $HOME/bootstrap

#!/bin/bash

sudo apt-get update
sudo apt-get -y upgrade
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install -y ethereum

wget -s https://raw.githubusercontent.com/esell/ethcluster/master/bootstrap/genesis.json
geth init genesis.json

export BOOTNODE=`cat boot_address`
export BOOTNODE_IP=`getent hosts bootnode | cut -d" " -f1`

if [ $1 == "member" ]; then
    echo "#######################"
    echo "Starting Member Node..."
    echo "#######################"
    geth --networkid=123454 --bootnodes="enode://$BOOTNODE@$BOOTNODE_IP:30301" --rpc --rpcaddr "0.0.0.0" --ws --wsaddr "0.0.0.0"
else
    echo "#######################"
    echo "Starting Miner Node..."
    echo "#######################"
    geth --networkid=123454 --bootnodes="enode://$BOOTNODE@$BOOTNODE_IP:30301" --mine --minerthreads=1 --etherbase="0x0000000000000000000000000000000000000001"

fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment