Private network
This page describes how to set up a local cluster of nodes, advises how to make them private, and how to hook up your nodes on the eth-netstat network monitoring app. A fully controlled Ethereum network is useful as a backend for network integration testing (core developers working on issues related to networking/blockchain synching/message propagation, or dApp developers testing multi-block and multi-user scenarios).
This guide assumes that you're already able to build geth
by following the build instructions
Setting up multiple nodes
In order to locally run multiple Ethereum nodes, you have to make sure:
Each instance has a separate data directory (
--datadir
)Each instance runs on a different port (both ETH and rpc) (
--port and --rpcport
)In case of a cluster, the instances must know about each other
The ipc endpoint is unique or the ipc interface is disabled (
--ipcpath or --ipcdisable
)
To start the first node, let's make port explicit and disable ipc interface:
We started the node with the console in order to grab the enode url - for instance:
[::]
will be parsed as localhost (127.0.0.1
). If your nodes are on a local network, check each individual host machine and find your ip with ifconfig
(on Linux and MacOS):
If your peers are not on the local network, you'll need to know your external IP address (use a service) to construct the enode url.
Now you can launch a second node with:
If you want to connect this instance to the previously started node, you can add it as a peer from the console with admin.addPeer(enodeUrlOfFirstInstance)
.
You can test the connection by typing in geth console:
Local Cluster
As an extension of the above, you can easily spawn a local cluster of nodes. It can also be scripted, including account creation, which is needed for mining. See gethcluster.sh
script and the README for usage and examples.
Private network
See [[the Private Network Page|Private network]] for more information.
Setup bootnode
The first time a node connects to the network, it uses one of the predefined bootnodes. Through these bootnodes, a node can join the network and locate other nodes. In the case of a private cluster, these predefined bootnodes are not of much use. Therefore, Elastos.ELA.SideChain.ESC offers a bootnode implementation that can be configured and run on your private network.
It can be run through the command:
As displayed, the bootnode asks for a key. Each Ethereum node, including bootnodes, is identified by an enode identifier, which is derived from a key. Therefore, you'll need to give the bootnode this key. Since we currently don't have one, we can instruct the bootnode to generate a key (and store it in a file) before it starts.
(exit with CTRL-C)
The stored key can be seen with:
To instruct geth nodes to use our own bootnode(s), use the --bootnodes
flag. This is a comma separated list of bootnode enode identifiers.
(what [::] means is explained previously)
Since it's convenient to start the bootnode each time with the same enode, we can give the bootnode program the recently generated key the next time it's started.
or
Monitoring your nodes
This page or this README describes how you set up your own monitoring service for a (private or public) local cluster.
Last updated