Select Page

Launch an EC2 instance

●Login on AWS Console.
●In the top-right corner of the AWS Management Console, choose the AWS Region in which you want to create the DB instance. This example uses the US East (N. Virginia) region.
●Select EC2 from the Services dropdown (top-left), click on Launch Instance.
●Search for Ubuntu 16.04 AMI, & Select Ubuntu 16.04 AMI.
●On the next screen, select instance type c4.xlarge, select public subnet.
●Add root storage 30 GiB, Additionally add 300 GiB GP2 storage to keep btc data, & Permanent mount it on /home/crypto
●Select Security Group, Create and download key pair.
●Allow port 22 for your public IP address in security group.
●More instruction to launch an EC2 here.

SSH into your Instance and required softwares

●Connect to the EC2 instance using public IP Address and pem key which you launched earlier.
●Update/Upgrade OS using sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get dist-upgrade -y;
●Install Development Tools using sudo apt-get install libboost-all-dev libboost-dev htop git curl wget zip build-essential unzip -y
●Install bitcoin core from PPA as follows-
sudo apt-add-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoind -y

Configure Bitcoin Core

Before we can start running bitcoind and doing our initial synchronisation with the network, we’ll need to set our options in bitcoin.conf, and create a Ubuntu service to make it easier to start/stop/restart our bitcoind executable and ensure it runs even if the machine reboots.

we’ll create the ~/.bitcoin directory where our bitcoin.conf file will be stored:

mkdir ~/.bitcoin

Now, using vim, create the ~/.bitcoin/bitcoin.conf file and paste in this configuration:

server=1
datadir=/home/crypto
dbcache=6000
txindex=1
rpcuser=bitcoin
rpcpassword=enterpasswordhere
rpcallowip=App_Server_IP/CIDR

Make sure to replace the enterpasswordhere text with a strong password and rpcallowip with your application server IP Address, especially if you’d like to make RPC calls to this full node from a remote client.

Finally, create the bitcoin.service file at /lib/systemd/system/bitcoin.service using vim like so:

sudo vim /lib/systemd/system/bitcoin.service

And paste in the following contents:

[Unit]
Description=Bitcoin’s distributed currency daemon
After=network.target

[Service]
User=ubuntu
Group=ubuntu

Type=forking
PIDFile=/home/crypto/bitcoind.pid
ExecStart=/usr/bin/bitcoind -daemon -pid=//home/crypto/bitcoind.pid \
-conf=/home/ubuntu/.bitcoin/bitcoin.conf -datadir=/home/crypto

Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=2s
StartLimitInterval=120s
StartLimitBurst=5

[Install]
WantedBy=multi-user.target

Run Bitcoin On Startup

After all that, it’s time to fire up the bitcoin process and start the initial sync:

sudo systemctl daemon-reload
sudo systemctl start bitcoin
sudo systemctl enable bitcoin

After a minute or so, you should be able to query the node for information about the blockchain and view your progress:

bitcoin-cli getblockchaininfo

And see how many other nodes you are connected to with this command:

bitcoin-cli getnetworkinfo | grep connections

Allow occupied port for application server from security group

Below ports will be occupied by BTC daemon:

8332 => MainNet RPC (App Instances)
8333 => MainNet P2P (Public)

Please note, It can take upto two days to fully sync with latest block.
And compare the number of blocks in the output with the current height of the blockchain at a site like this: https://www.blockchain.com/explorer