Building an Ethereum Node on Ubuntu

ยท

Installing Geth

To install Geth (Go Ethereum), follow these steps:

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

After installation, verify the Geth version to confirm successful setup:

geth version

Expected output example:

Geth Version: 1.8.12-stable
Git Commit: 37685930d953bcbe023f9bc65b135a8d8b8f1488
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10
Operating System: linux

Creating Geth Start/Stop Scripts

Step 1: Identify Your Local IP Address

Run this command to find your internal IP:

ifconfig -a

Step 2: Create Startup Script (starteth.sh)

#!/bin/bash
nohup geth --rpcaddr "YOUR_LOCAL_IP" --rpc --rpccorsdomain="*" --datadir "/data/ethereum" >> geth.log 2>&1 &

Step 3: Create Stop Script (stopeth.sh)

#!/bin/bash
PIDS=$(ps -ef | grep geth | grep -v grep | awk '{print $2}')
if [ "$PIDS" != "" ]; then
    kill -9 $PIDS
else
    echo "$(date +%F" "%H:%M:%S) Geth is NOT running!"
fi

Step 4: Set Execute Permissions

chmod u+x st*.sh

Starting Geth and Syncing Blockchain Data

Begin synchronization with:

./starteth.sh

Monitor progress by viewing the log:

tail -f geth.log

๐Ÿ‘‰ Learn more about Ethereum node synchronization

Verifying Sync Completion

Check synchronization status via Geth console:

geth attach
> eth.blockNumber

FAQ Section

Q: How long does initial synchronization take?
A: Typically 3+ days depending on server bandwidth and hardware.

Q: Why does eth.blockNumber return 0?
A: This indicates synchronization is still in progress.

Q: What's the recommended server specification?
A: Minimum 4CPU/8GB RAM with SSD storage and high-speed internet.

๐Ÿ‘‰ Explore cloud server options for Ethereum nodes

Q: How to troubleshoot stalled synchronization?
A: 1) Verify sufficient disk space 2) Check network connectivity 3) Restart Geth process.

Optimization Tips

For better performance:

Remember to always maintain proper security measures when running public nodes.