This article is a continuation of the article Private Proof-of-Authority Ethereum Network on Synology NAS
Here we describe how to add another node to our private Ethereum development blockchain. Keep in mind that it is private and development platform, so for public node all security requirements may not be met.
In previous article we already did set up private network and got genesis.json as strating point of any new geth node.
The procedure is very similar like for first node.
1. Install Ethereum and geth
2. Make directory for geth.
1 |
mkdir node2 |
3. Create a geth account.
1 |
geth --datadir node1 account new |
Be sure to keep track of the password used to create each account!
4. Initialize geth Ethereum new node instance with genesis settings
1 |
geth --datadir blkchain init genesis.json |
5. Start geth console.
1 |
geth --datadir="node2" --networkid 58343 --syncmode 'full' --nodiscover --port 3002 console --unlock 0xa53E043deCA4ea37D7E1004AC4311235B3e60499 --rpc --rpcport "8542" --rpcaddr "0.0.0.0" --rpccorsdomain "*" --rpcapi "eth,net,web3,miner,debug,personal,rpc" -miner.gasprice 0 --miner.etherbase=0xa53E043deCA4ea37D7E1004AC4311235B3e60499 --allow-insecure-unlock |
We will plan to start more nodes later and have set up address patterns like
node1: –port 3001 –rpcport 8541
node2: –port 3002 –rpcport 8542
and so on.
Depending on you needs you may not to start rpc or mining at all.
Now the node is up, but it has no knowledge of other node(s) neither does it contain data and is not synchronized.
First we have to turn back to initial primary node and find out enode info. Enter next command in geth console:
1 2 3 |
admin.nodeInfo.enode "enode://643a63d1a138ee2cf1ee75baa0f05e582f437db890c749f6c5652ac530d4d5b1274962c3a9e0f62b183f1409e9e1cbb1cade64e4e9449714c935b13523b43673@192.168.1.32:3000" |
Take note of the response and on second node geth console add new peer with command:
1 |
admin.addPeer("enode://643a63d1a138ee2cf1ee75baa0f05e582f437db890c749f6c5652ac530d4d5b1274962c3a9e0f62b183f1409e9e1cbb1cade64e4e9449714c935b13523b43673@1192.168.1.32:300") |
But before that second node must have access to port 3000 on fist nodes computer at ip 192.168.1.32
On command prompt of first computer add firewall rule (for fist node we used Ubuntu server )
1 |
sudo ufw allow proto tcp from 192.168.1.54 to 192.168.1.32 port 3000 |
In this example 192.168.1.54 is the ip address of second node.
if all port numbers are correct, firewall has access and correct genesis file was used then you should see something like this:
Synchronization has been started and new blocks have been imported. To verify the sync status you can execute few times command eth.blockNumber and see if block number grows. Keep the rerun period longer than the Ethereum block time though.
Next time we will have a look how to add new authority to blockchain, we will turn this new node2 to authority node and finally will switch initial node completely off.
Pingback: Adding Signer Node to Private Ethereum Network - Software Blog