This guide provides a clear, step-by-step process for setting up your own Ethereum mainnet full node. Whether for development, research, or to support the network, running a node is a valuable skill.
Recommended System Requirements
For a stable and efficient node synchronization experience, we recommend the following hardware and network specifications.
Recommended Configuration:
- CPU: 8 cores
- RAM: 16 GB
- Storage: 500 GB SSD (Solid State Drive)
- Network: 5 Mbps+ bandwidth
Minimum Configuration:
- CPU: 4 cores
- RAM: 8 GB
- Storage: 500 GB high-speed hard drive
- Network: 2 Mbps bandwidth
Using the recommended configuration, a full initial sync from genesis to the current block typically completes within approximately two days.
Server Location: Domestic vs. International
The choice between a domestic or international cloud server involves a trade-off between convenience and connectivity.
- International Servers: The installation process is generally more straightforward as there are typically no restrictions on accessing the required resources and peer connections.
- Domestic Servers: While cloud services are mature, you may encounter connectivity issues or slower peer discovery due to network firewalls, requiring additional troubleshooting during setup.
For this guide, an Alibaba Cloud VPS running CentOS 6 was used. Note that community resources and tutorials are often more plentiful for Ubuntu or CentOS 7.
Step-by-Step Installation and Configuration
This section details the commands and procedures to install the necessary software and configure your Geth node.
Installing the Go Programming Language
The Go language is required to compile the go-ethereum source code. While version managers like gvm are useful, a simple yum install often works best for a clean server setup.
yum install golangVerify the installation with:
go version
# Example output: go version go1.11.5 linux/amd64Installing Git for Source Code Management
You need Git to clone the go-ethereum repository. The default yum version may be outdated; use the following commands to install a more recent version.
yum install https://centos6.iuscommunity.org/ius-release.rpm
yum install epel-release
yum install git2uVerify the installation:
git version
# Example output: git version 2.16.4Downloading and Compiling Go-Ethereum
Clone the official repository and check out a stable release branch to ensure reliability.
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum/
git checkout release/1.9Compile the source code to build the Geth binary and other tools.
cd go-ethereum/
make allThe compiled binaries, including geth, will be located in the build/bin directory.
Adding Geth to the System PATH
To run geth from anywhere on your system, add its directory to your PATH.
- Edit the profile file:
vi /etc/profile - Add this line to the end:
export PATH=$PATH:/path/to/go-ethereum/build/bin - Apply the changes:
source /etc/profile Verify the configuration:
geth version
Key Parameters for Launching Geth
Simply running geth will start syncing, but several flags are crucial for performance and remote access.
--datadir "xxxx": Specifies the directory for blockchain data, state data, and keystores. This directory will grow very large, so ensure it is on a partition with ample space.--cache value: Megabytes of memory allocated to internal caching. The default is 1024; increasing this (e.g.,4096) can significantly speed up the initial sync.--rpc: Enables the HTTP-RPC server.--rpcaddr value: Interface address the HTTP-RPC server listens on (default: "localhost"). Use0.0.0.0to accept connections from other machines (use with caution and proper security).--rpcport value: HTTP-RPC server listening port (default: 8545).--ws: Enables the WebSocket-RPC server, which is essential for listening to real-time events like pending transactions.--wsaddr value: Interface address the WS-RPC server listens on.--wsport value: WS-RPC server listening port (default: 8546).
A typical launch command looks like this:
geth --datadir data --cache 4096 --rpc --rpcport 6666 --rpcaddr 0.0.0.0 --ws --wsaddr 0.0.0.0 --wsport 6667 --wsorigins "*"Security Note: Exposing RPC/WS interfaces on 0.0.0.0 can be risky. It is highly recommended to use a firewall, reverse proxy, or SSH tunneling to control access instead.
Running Geth as a Background Process
To keep your node running after closing the terminal, use nohup.
nohup geth [YOUR_FLAGS_HERE] & > nohup.outTo stop a background Geth process gracefully, you can use a script to send an interrupt signal.
#!/bin/sh
pid=$(ps -ef | grep geth | grep -v grep | awk '{print $2}')
echo $pid
kill -INT $pidSending an INT signal (SIGINT) allows Geth to terminate its processes cleanly, which is important for database integrity. 👉 Explore more strategies for managing long-running processes.
Monitoring the Synchronization Status
You can check the sync progress by attaching to the running node instance.
geth attach data/geth.ipcChecking Sync Status within the Geth Console
Once attached, you can run several commands to monitor health and progress.
eth.syncing: This will returnfalseif the node is fully synced. If it's still syncing, it returns an object showing thecurrentBlockandhighestBlock(the latest block on the network).> eth.syncing { currentBlock: 6143193, highestBlock: 6143296, knownStates: 91512910, pulledStates: 91498893, startingBlock: 0 }eth.blockNumber: During sync, this will return0. Once synced, it returns the latest block number your node has processed.net.peerCount: This indicates how many other nodes you are connected to for data synchronization. If this is0, there is a network connectivity issue (e.g., firewall blocking port 30303).> net.peerCount 8
When the log output changes from importing state entries to importing new chain segments, and eth.blockNumber returns a non-zero value, your node is fully synced and ready to use.
Frequently Asked Questions
How long does the initial sync take?
The initial synchronization process, where your node downloads and verifies the entire blockchain history, can take anywhere from several hours to a few days. The duration depends primarily on your hardware (especially SSD speed and allocated RAM cache) and internet bandwidth. Using the recommended 8-core CPU and 16GB RAM with a fast SSD can complete the process in approximately 48 hours.
Why is it crucial to open port 30303?
Port 30303 is the default listening port for Geth's devp2p protocol. Opening this port on your firewall allows incoming connections from other nodes on the Ethereum network. This significantly improves the number of peers you can connect to, which enhances the speed and stability of data synchronization and helps propagate transactions and blocks you produce.
What is the difference between a full node and an archive node?
A full node stores the current state and the most recent 128 blocks, allowing it to verify new transactions and blocks. An archive node stores everything a full node does plus all historical states back to the genesis block. Archive nodes require significantly more storage (over 10TB and growing) and are typically only needed for historical data queries or specific development tasks.
My node shows 'syncing: false' but is behind the latest block. What's wrong?
This often indicates a connectivity issue. The most common cause is a closed firewall port 30303, which limits your peer connections. Ensure this port is open and forwarded to your node. You can also try adding trusted bootnodes manually to establish initial connections.
Can I run a node on a virtual private server (VPS)?
Yes, running a node on a VPS is a very popular and practical option. It provides high uptime and avoids consuming electricity and bandwidth on a home connection. Ensure you choose a VPS provider that offers sufficient SSD storage and does not charge high fees for large amounts of data egress.
What should I do if Geth fails to start after an improper shutdown?
An improper shutdown (like a power loss) can corrupt the node's database. You may see an error like Fatal: Error starting protocol stack: missing block number for head header hash. The most reliable solution is to delete the blockchain data and resync from scratch using the command geth removedb --datadir data. Always use the kill -INT command to stop Geth gracefully and minimize this risk.
Key Takeaways and Final Advice
Setting up an Ethereum mainnet node is a rewarding project that deepens your understanding of the network. The key to a smooth experience lies in using adequate hardware—a multi-core CPU, ample RAM, a fast SSD, and a stable internet connection. Remember to configure your firewall correctly, open port 30303, and always shut down the Geth process gracefully to avoid database corruption. This guide provides the foundation; your node will become a valuable part of the decentralized ecosystem.