Geth_setup
Chapter 7: Geth Client - Setup & Configuration
Section titled “Chapter 7: Geth Client - Setup & Configuration”Overview
Section titled “Overview”Geth (Go Ethereum) is the most popular and widely-used Ethereum client. It’s written in Go and developed by the Ethereum Foundation. Understanding Geth is essential for any blockchain infrastructure engineer.
7.1 Installing Geth
Section titled “7.1 Installing Geth”Prerequisites
Section titled “Prerequisites”| Requirement | Minimum | Recommended |
|---|---|---|
| OS | Ubuntu 20.04+, macOS, Windows | Ubuntu 22.04 LTS |
| CPU | 4 cores | 8+ cores |
| RAM | 8 GB | 16-32 GB |
| Storage | 1 TB SSD | 2 TB NVMe SSD |
| Network | 25 Mbps | 100 Mbps |
Installation Methods
Section titled “Installation Methods”Method 1: Download Binary (Recommended for Quick Start)
Section titled “Method 1: Download Binary (Recommended for Quick Start)”# Download latest Gethcd /tmpwget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.13.14-8ab7ff97.tar.gztar -xzf geth-linux-amd64-1.13.14-8ab7ff97.tar.gzsudo mv geth-linux-amd64-1.13.14-8ab7ff97/geth /usr/local/bin/rm -rf geth-linux-amd64-1.13.14-8ab7ff97*
# Verify installationgeth versionMethod 2: Install from Source
Section titled “Method 2: Install from Source”# Install Go (if not installed)wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gzsudo tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gzexport PATH=$PATH:/usr/local/go/bin
# Clone and build Gethgit clone https://github.com/ethereum/go-ethereum.gitcd go-ethereummake gethsudo cp build/bin/geth /usr/local/bin/Method 3: Using apt (Ubuntu/Debian)
Section titled “Method 3: Using apt (Ubuntu/Debian)”sudo apt-get updatesudo apt-get install software-properties-commonsudo add-apt-repository ppa:ethereum/ethereumsudo apt-get updatesudo apt-get install geth7.2 Basic Geth Commands
Section titled “7.2 Basic Geth Commands”Quick Start
Section titled “Quick Start”# Start Geth with default settings (connects to mainnet)geth
# Start with console attachedgeth console
# Check Geth versiongeth versionExpected output:
GethVersion: 1.13.14-8ab7ff97Architecture: amd64Protocol Versions: [68]Network Protocols: Ethereum: 68Go Version: go1.21.5Operating System: linuxGOPATH=GOROOT=/usr/local/go7.3 Running a Full Node
Section titled “7.3 Running a Full Node”Basic Full Node Command
Section titled “Basic Full Node Command”geth \ --syncmode full \ --http \ --http.addr 0.0.0.0 \ --http.port 8545 \ --http.api eth,net,web3,debug,txpool \ --http.corsdomain "*" \ --ws \ --ws.addr 0.0.0.0 \ --ws.port 8546 \ --ws.api eth,net,web3 \ --ws.origins "*" \ --datadir /data/ethereum \ --port 30303 \ --maxpeers 50Command Explanation
Section titled “Command Explanation”| Flag | Description | Example |
|---|---|---|
--syncmode | Synchronization mode | full, snap, light |
--http | Enable HTTP-RPC server | |
--http.addr | HTTP server bind address | 0.0.0.0 (all interfaces) |
--http.port | HTTP server port | 8545 |
--http.api | Enabled HTTP APIs | eth,net,web3 |
--ws | Enable WebSocket server | |
--ws.port | WebSocket port | 8546 |
--datadir | Data directory path | /data/ethereum |
--port | P2P networking port | 30303 |
--maxpeers | Maximum peer connections | 50 |
7.4 Important Sync Modes
Section titled “7.4 Important Sync Modes”Geth supports multiple synchronization modes:
┌─────────────────────────────────────────────────────────────────────────────┐│ GETH SYNC MODES │├─────────────────────────────────────────────────────────────────────────────┤│ ││ ┌─────────────────┐ ││ │ FULL SYNC │ ◄── Downloads and verifies every block ││ │ │ Most secure, slowest initial sync ││ └────────┬────────┘ ││ │ ││ ┌────────▼────────┐ ││ │ SNAP SYNC │ ◄── Downloads latest state, fastest ││ │ (Default) │ Recommended for most users ││ └────────┬────────┘ ││ │ ││ ┌────────▼────────┐ ││ │ LIGHT CLIENT │ ◄── Only block headers + minimal data ││ │ │ Fastest, limited functionality ││ └─────────────────┘ ││ ││ Recommendation: Use --syncmode snap for production nodes ││ │└─────────────────────────────────────────────────────────────────────────────┘Sync Mode Comparison
Section titled “Sync Mode Comparison”| Mode | Initial Sync | Storage | Functionality | Security |
|---|---|---|---|---|
| Full | Days | ~1.2 TB | Complete | Highest |
| Snap | Hours | ~1.2 TB | Complete | High |
| Light | Minutes | ~1 GB | Limited | Medium |
7.5 Production Configuration
Section titled “7.5 Production Configuration”Optimized Production Flags
Section titled “Optimized Production Flags”geth \ --syncmode snap \ --http \ --http.addr 127.0.0.1 \ --http.port 8545 \ --http.api eth,net,web3,debug,txpool,erigon \ --http.vhosts "*" \ --ws \ --ws.addr 127.0.0.1 \ --ws.port 8546 \ --ws.api eth,net,web3,debug,txpool,erigon \ --ws.origins "*" \ --datadir /data/ethereum \ --port 30303 \ --maxpeers 100 \ --cache 4096 \ --gc 1 \ --txpool.globalslots 4096 \ --txpool.globalqueue 1024 \ --metrics \ --metrics.addr 0.0.0.0 \ --metrics.port 6060 \ --pprof \ --pprof.addr 0.0.0.0 \ --pprof.port 6061Configuration Parameters Explained
Section titled “Configuration Parameters Explained”| Parameter | Description | Recommended |
|---|---|---|
--cache | Memory for caching (MB) | 4096 (4GB) |
--gc | Enable garbage collection | 1 |
--txpool.globalslots | Max pending transactions | 4096 |
--txpool.globalqueue | Max queued transactions | 1024 |
--metrics | Enable Prometheus metrics | |
--pprof | Enable profiling API |
7.6 Systemd Service Configuration
Section titled “7.6 Systemd Service Configuration”Create Systemd Service File
Section titled “Create Systemd Service File”sudo nano /etc/systemd/system/geth.service[Unit]Description=Ethereum Geth NodeAfter=network.targetWants=network-online.target
[Service]Type=simpleUser=ethereumGroup=ethereumRestart=alwaysRestartSec=10ExecStart=/usr/local/bin/geth \ --syncmode snap \ --http \ --http.addr 127.0.0.1 \ --http.port 8545 \ --http.api eth,net,web3,debug,txpool \ --ws \ --ws.addr 127.0.0.1 \ --ws.port 8546 \ --ws.api eth,net,web3 \ --datadir /data/ethereum \ --port 30303 \ --maxpeers 100 \ --cache 4096 \ --metrics \ --pprof
# HardeningNoNewPrivileges=truePrivateTmp=trueProtectSystem=strictProtectHome=trueReadWritePaths=/data/ethereum
[Install]WantedBy=multi-user.targetEnable and Start Service
Section titled “Enable and Start Service”# Reload systemdsudo systemctl daemon-reload
# Create user and directoriessudo useradd -r -s /sbin/nologin ethereumsudo mkdir -p /data/ethereumsudo chown ethereum:ethereum /data/ethereum
# Enable and startsudo systemctl enable gethsudo systemctl start geth
# Check statussudo systemctl status gethsudo journalctl -fu geth -n 1007.7 Docker Installation
Section titled “7.7 Docker Installation”Using Docker
Section titled “Using Docker”# Pull Geth imagedocker pull ethereum/client-go:latest
# Run Geth containerdocker run -d \ --name ethereum-node \ -p 30303:30303 \ -p 8545:8545 \ -p 8546:8546 \ -v /data/ethereum:/data \ ethereum/client-go:latest \ --syncmode snap \ --http \ --http.api eth,net,web3 \ --datadir /dataDocker Compose
Section titled “Docker Compose”version: '3.8'
services: geth: image: ethereum/client-go:latest container_name: geth-node ports: - "30303:30303" - "8545:8545" - "8546:8546" volumes: - ./data:/data environment: - SYNCMODE=snap command: - --syncmode=snap - --http - --http.api=eth,net,web3 - --datadir=/data restart: unless-stopped7.8 Connecting to Testnet
Section titled “7.8 Connecting to Testnet”Sepolia Testnet
Section titled “Sepolia Testnet”geth \ --sepolia \ --syncmode snap \ --http \ --http.addr 127.0.0.1 \ --http.port 8545 \ --datadir /data/ethereum-sepoliaGoerli Testnet (Deprecated)
Section titled “Goerli Testnet (Deprecated)”geth \ --goerli \ --syncmode snap \ --http \ --http.addr 127.0.0.1 \ --http.port 8545 \ --datadir /data/ethereum-goerliHolesky (Validator Testnet)
Section titled “Holesky (Validator Testnet)”geth \ --holesky \ --syncmode snap \ --http \ --http.addr 127.0.0.1 \ --http.port 8545 \ --datadir /data/ethereum-holesky7.9 Checking Sync Status
Section titled “7.9 Checking Sync Status”Using Geth Console
Section titled “Using Geth Console”geth attach http://localhost:8545
# Check sync statuseth.syncing
# Example output:{ currentBlock: 18500000, highestBlock: 18501234, knownStates: 123456, pulledStates: 120000, startingBlock: 18499000}
# If false, node is syncedeth.syncing# falseUsing JSON-RPC
Section titled “Using JSON-RPC”# Check block numbercurl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
# Check syncing statuscurl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'7.10 Interview Questions
Section titled “7.10 Interview Questions”| Question | Answer |
|---|---|
| How to check if Geth is synced? | Use eth.syncing in console - returns false when synced |
| Difference between sync modes? | Full = verify all; Snap = download state; Light = headers only |
| What port does Geth use? | 30303 for P2P, 8545 for HTTP, 8546 for WebSocket |
| How to make node production-ready? | Use systemd, proper flags, monitoring |
Summary
Section titled “Summary”- Geth is the Go implementation of Ethereum
- Install via binary, source, or package manager
- Use
--syncmode snapfor fastest sync - Configure HTTP/WebSocket APIs for dApp access
- Use systemd for production deployment
- Monitor sync status via RPC or console
Next Chapter
Section titled “Next Chapter”In Chapter 8: Geth CLI Options & Flags, we’ll explore all Geth command-line options in detail.
Last Updated: 2026-02-20