Ethereum AWS Ubuntu Miner Node Installation and Setup

in linux •  8 years ago  (edited)

Ethereum AWS Miner Node Installation and Setup




Ethereum

For more information on Ethereum, visit ethereum.org


Description:

Ethereum is a decentralized platform that runs smart contracts using a custom built blockchain. The platform uses a cryptocurrency also called Ethereum (Ether/ETH). This tutorial will walk through all of the necessary steps, required to get a mining rig set up to mine the Ethereum cryptocurrency.


This tutorial will use an AWS g2.8xlarge image which has 4 Nvidia Cuda GPUs. As of the writing of this tutorial, this rig will chomp through around 34 MH/s. Although much more expensive, I have also tested this setup on a p2.8xlarge (120 MH/s) as well as a p2.16xlarge (280 MH/s)


Using AWS to mine ETH can be expensive and non profitable. Please consult the AWS pricing docs to see the current pricing on the g2/p2 family of instances before spinning up anything. g2/p2 instances can be extremely expensive, and following this guide on an AWS instance will incur hourly EC2 usage charges.


Pre-Requisites:

COMPATABILITY NOTICE:
These instructions are only compatible with Ubuntu 15.10 or newer  
Although other OS's are supported, this tutorial is built on the Ubuntu platform. The reason that Ubuntu was chosen was simply due to the ease of finding the right ethereum PPA repositories.


1.    Perform an update:

sudo apt-get -y update
sudo apt-get -y upgrade   


2.   Install the Build Essentials:

sudo apt-get -y install build-essential


3.   Ensure we have wget, screen, git and we also need software-properties:

sudo apt-get -y install sudo wget vim screen git software-properties-common


4.    Install the Nvidia Cuda Drivers:

cd /media
sudo wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.44-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_8.0.44-1_amd64.deb


Install Ethereum:


1.    Install the Ethereum repos:

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


2.    Install Ethereum required dependancies:

sudo apt-get -y update
sudo apt-get -y install cmake libcryptopp-dev libleveldb-dev libjsoncpp-dev libjsonrpccpp-dev libboost-all-dev libgmp-dev libreadline-dev libcurl4-gnutls-dev ocl-icd-libopencl1 opencl-headers mesa-common-dev libmicrohttpd-dev cuda


3.    Install Ethereum:

sudo apt-get -y install ethereum


Install the C++ Ethereum miner:

1.    Clone the repo:

cd /media
sudo git clone https://github.com/Genoil/cpp-ethereum/"


2.    Compile the miner:

sudo mkdir /media/cpp-ethereum/build
sudo sh -c 'cd /media/cpp-ethereum/build; cmake -DBUNDLE=miner ..'
sudo sh -c 'cd /media/cpp-ethereum/build; make -j8'


3.    Export GPU settings:

sudo echo 'export GPU_FORCE_64BIT_PTR=0' | sudo tee --append /media/set_env.sh
sudo echo 'export GPU_MAX_HEAP_SIZE=100' | sudo tee --append /media/set_env.sh
sudo echo 'export GPU_USE_SYNC_OBJECTS=1' | sudo tee --append /media/set_env.sh
sudo echo 'export GPU_SINGLE_ALLOC_PERCENT=100' | sudo tee --append /media/set_env.sh
sudo echo 'export GPU_MAX_ALLOC_PERCENT=100' | sudo tee --append /media/set_env.sh


Sync the blockchain:


The next few steps we will run in a screen session, so that they will continue to run even after we close the terminal.

1.    Start a screen session:

screen


2.    Allow the blockchain to sync:

cd ~
geth --rpc console


This will start the blockchain synchronization. Depending on the size of the blockchain, this could take up to a few hours to complete.


We can tell that the synchronization is complete when the number field in the geth output, matches the LAST BLOCK value found on etherscan.io


geth


geth    etherscan


3.    Disconnect from the screen session:

Once the blockchain has completed it's initial syncronization, you can safely detach from the screen session by hitting ctl A, ctl D. This should put you back to your original shell.


4.    Verify screen is still running:

screen -ls


root@localhost~ # screen -ls
There is a screen on:
    2637.pts-0.ip-10-179-4-150  (06/01/2017 08:37:00 AM)    (Detached)


Run the compiled miner:

1.    Start another screen session:

screen


2.    Run the miner:

cd /media/cpp-ethereum/build/ethminer
./ethminer -G


Running ethminer with ./ethminer -G will start a solo mining process. It could take weeks/months to find a block on your own, especially if your MH/s rate isn't at least a few hundred. In order to make it more profitable, we will use an ethereum pool. With a pool such as nanopool, you generally don't have to register or pre-create an account, simply start a miner process, and once a single block has been confirmed and submitted, nanopool will create an account for your wallet address automatically. Other pools such as miningpoolhub.com do require a re-registration.


Miningpoolhub:

After a 24 hour run, I determined that miningpoolhub distributes more shares, more quickly and only have a 0.9% fee instead of a 1% fee. Running on nanopool for 24 hours yielded approximately 0.05 ether, running on miningpoolhub for 14 hours yielded approximately 0.19 ether!!


1.    Create a miningpoolhub.com account:

Go to https://ethereum.miningpoolhub.com, and in the left side menu choose Sign Up

Fill in your username (you will need this later), your password, email and choose a 4 digit pin. Once complete, click on the Register button.


Register


Once registered, you will see a flash message pop up that says Account created, please login.

Account Created

Login using the Login link on the left menu.


2.    Go to the Ethereum section:

Next we need to associate our wallet address with our account, we do this by clicking Ethereum, under the POOLS section on the left hand menu.Ethereum Section


3.    Go to the Wallet section:

Next click on the Wallet link, under the MY ACCOUNT section again in the left hand menu. Clicking this link will show your wallet settings. Fill in the details in the POOL ACCOUNT DETAILS section.


Payment Address:This is your ethereum wallet address
Automatic Payout ThresholdThis will be the minimum amount of ether that you will mine prior to receiving a payout. I usually set my threshold to 0.1 ether.
4 Digit PinThis is the same pin that was used to register the account.


Once the details have been populated, click on Update Account button. Once completed, your wallet should now be registered.


Ethereum Section


4.    Connect miner to Miningpoolhub.com:

No flags are needed for individual GPUs, ethminer will collectivly use all GPUs on the node

./ethminer -G -S us-east.ethash-hub.miningpoolhub.com:20535 -O <UserName>.<Worker_Name>:<WorkerPassword>


Replace the value of UserName with the username that was used to register your miningpoolhub account with. Replace Worker_Name with a unique identifier for the node that your running the miner process on and finally replace WorkerPassword with an arbitrary password. Workers do NOT need to be pre-registered with miningpoolhub, nor does the WorkerPassword value matter, miningpoolhub is not even checking the value of this, so I usually set my worker passwords to simply password. Once your mining worker helps to mine and submit a block, it will be auto-registered on miningpoolhub.


./ethminer -G -S us-east.ethash-hub.miningpoolhub.com:20535 -O clusterfrak.workerx:password


geth


5.    Disconnect from the screen session:

Once the miner has been started, you can safely detach from the screen session by hitting ctl A, ctl D. This should put you back to your original shell.


6.    Verify screen is still running:

screen -ls


root@localhost~ # screen -ls
There are screens on:
    2826.pts-0.ip-10-179-4-150  (06/01/2017 10:45:50 AM)    (Detached)
    2637.pts-0.ip-10-179-4-150  (06/01/2017 08:37:00 AM)    (Detached)


7.    Verify miningpoolhub worker:

Now that your node is successfully mining, wait about 15-20 minutes and check miningpoolhub to see your worker nodes hashrate and work performed. To see your stats, click on Dashboard under the My Account section on the Ethereum Pool page menu


The URL for the miningpoolhub dashboard will be:

https://ethereum.miningpoolhub.com/index.php?page=dashboard

dashboarddashboard


Nanopool:


1.    Connect to Nanopool.org:

No flags are needed for individual GPUs, ethminer will collectivly use all GPUs on the node

./ethminer -G -F http://eth1.nanopool.org:8888/<WALLET_ADDRESS>/<WORKER_NAME>/<EMAIL>


Replace the value of WALLET_ADDRESS with a valid ethereum wallet address where nanopool can send your shared reward. Also replace WORKER_NAME with a unique identifier for the node that your running the miner proccess on and finally replace EMAIL with a valid email address. The email will be used by nanopool to send you notifications automatically if your worker node goes offline.


./ethminer -G -F http://eth1.nanopool.org:8888/0x1111222233334444555566667777888899990000/aws-node-1/[email protected]


geth


2.    Disconnect from the screen session:

Once the miner has been started, you can safely detach from the screen session by hitting ctl A, ctl D. This should put you back to your original shell.


3.    Verify screen is still running:

screen -ls


root@localhost~ # screen -ls
There are screens on:
    2826.pts-0.ip-10-179-4-150  (06/01/2017 10:45:50 AM)    (Detached)
    2637.pts-0.ip-10-179-4-150  (06/01/2017 08:37:00 AM)    (Detached)


4.    Verify nanopool registration:

Now that your node is successfully mining, wait about 15-20 minutes and check nanopool to see if you node is registered. Once the account is provisioned based on your worker nodes's work, you will be able to go to your nanopool dashboard, and see all of your running nodes, along with the amount of Ethereum that you made with your worker node.


The URL for nanopool will be:

https://eth.nanopool.org/account/<WALLET_ADDRESS>


So for our example the URL will be:

https://eth.nanopool.org/account/0x1111222233334444555566667777888899990000


geth


Packer File:


The following packer config can be used with packer to automatically provision your own AWS Ethereum Miner Node

Fill in the variables in the packer file below, or create a separate var-file, and use the packer build -var-file filename.json ethereum-rig.json command to run packer. In that example filename.json would be the buildvars file, and ethereum-rig.json would be a file with the code below.


{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "instance_type": "g2.8xlarge",
    "region": "us-east-1",
    "use1_ami": "ami-80861296",
    "vpc_id": "",
    "subnet_id": "",
    "security_group_id": "",
    "ssh_keypair_name": "",
    "ssh_username": "ubuntu"

  },
  "builders": [{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key`}}",
    "secret_key": "{{user `aws_secret_key`}}",
    "region": "{{user `region`}}",
    "source_ami": "{{user `use1_ami`}}",
    "instance_type": "{{user `instance_type`}}",
    "ami_name": "Ethereum-Mining-Rig-{{timestamp}}",
    "ami_description": "Image with all of the tools required to mine Ethereum",
    "availability_zone": "us-east-1a",
    "vpc_id": "{{user `vpc_id`}}",
    "subnet_id": "{{user `subnet_id`}}",
    "security_group_id": "{{user `security_group_id`}}",
    "ssh_keypair_name": "{{user `ssh_keypair_name`}}",
    "ssh_agent_auth": true,
    "ssh_username": "{{user `ssh_username`}}",
    "associate_public_ip_address": true,
    "ssh_private_ip": false,
    "tags": {
        "Name": "Ethereum Mining Rig",
        "OS_Version": "Ubuntu 16.04"
    }
  }],

  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "sudo apt-get -y update",
        "sudo apt-get -y upgrade",
        "sudo apt-get -y install build-essential",
        "sudo apt-get -y install sudo wget vim screen git",
        "cd /media",
        "sudo git clone https://github.com/Genoil/cpp-ethereum/",
        "sudo wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.44-1_amd64.deb",
        "sudo dpkg -i cuda-repo-ubuntu1404_8.0.44-1_amd64.deb",
        "sudo apt-get -y install software-properties-common",
        "sudo add-apt-repository -y ppa:ethereum/ethereum-qt",
        "sudo add-apt-repository -y ppa:ethereum/ethereum",
        "sudo add-apt-repository -y ppa:ethereum/ethereum-dev",
        "sudo apt-get -y update",
        "sudo apt-get -y install cmake libcryptopp-dev libleveldb-dev libjsoncpp-dev libjsonrpccpp-dev libboost-all-dev libgmp-dev libreadline-dev libcurl4-gnutls-dev ocl-icd-libopencl1 opencl-headers mesa-common-dev libmicrohttpd-dev cuda",
        "sudo apt-get -y install ethereum",
        "sudo mkdir /media/cpp-ethereum/build",
        "sudo sh -c 'cd /media/cpp-ethereum/build; cmake -DBUNDLE=miner ..'",
        "sudo sh -c 'cd /media/cpp-ethereum/build; make -j8'",
        "sudo echo 'export GPU_FORCE_64BIT_PTR=0' | sudo tee --append /media/set_env.sh",
        "sudo echo 'export GPU_MAX_HEAP_SIZE=100' | sudo tee --append /media/set_env.sh",
        "sudo echo 'export GPU_USE_SYNC_OBJECTS=1' | sudo tee --append /media/set_env.sh",
        "sudo echo 'export GPU_SINGLE_ALLOC_PERCENT=100' | sudo tee --append /media/set_env.sh",
        "sudo echo 'export GPU_MAX_ALLOC_PERCENT=100' | sudo tee --append /media/set_env.sh",
        "sudo echo 'source /media/set_env.sh' | sudo tee --append /root/.bashrc",
        "sudo echo 'source /media/set_env.sh' | sudo tee --append /home/ubuntu/.bashrc",
        "sudo echo 'source /media/set_env.sh' | sudo tee --append /etc/skel/.bashrc"
      ]
    }
]}


Post Requisites:


None, You can sit back, relax, and collect some ETH !!


References:


clusterfrak.com
Angelomilan Ethereum Guide
Genoil Ethereum Miner Fork
Etherscan.io
Nanopool
Coin Gecko Currency Converter

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks for the very detailed guide mate.

What is the cost and benefit of using AWS to mine Ether at the moment?

I have former co-workers who currently work for Amazon; during a happy-hour event last night, the subject of cryptocurrency mining came up, and he said that AWS has a considerable pool of resources for mining. Good luck, and happy mining :)

yea, I tested a few of the configurations, although it can be super expensive, you can get up to ~300 MH/S with a P2.16xlarge instance type... But not worth it at 10K a month for that instance class.. These instructions can be used on any box really, its not specific to AWS, which is why I wanted to post it.. I built this on Ubuntu 16.04 earlier this week.

Interesting thoughts