Start Up Nodes
Runs of geth on data directory of each nodes will use the genesis block I have defined.
I can find the networkid
in genesis block metadata.
$ cd Desktop/
$ vim poaOfYen.json
{
...
"chainId": 21382,
...
}
- Start
node1
$ cd ..
$ cd Downloads/
$ ./geth --datadir /Users/yen/Desktop/node1/data -rpc --rpcapi "db,eth,net,web3,personal" --networkid 21382 --port 2000 console
INFO [08-15|11:21:37] Starting peer-to-peer node instance=Geth/v1.6.2-unstable-ef7b9fb7/darwin-amd64/go1.8.1
INFO [08-15|11:21:37] Allocated cache and file handles database=/Users/yen/Desktop/node1/data/geth/chaindata cache=128 handles=1024
WARN [08-15|11:21:37] Upgrading chain database to use sequential keys
INFO [08-15|11:21:37] Initialised chain configuration config="{ChainID: 21382 Homestead: 1 DAO: <nil> DAOSupport: false EIP150: 2 EIP155: 3 EIP158: 3 Engine: clique}"
WARN [08-15|11:21:37] Upgrading db log bloom bins
INFO [08-15|11:21:37] Bloom-bin upgrade completed elapsed=84.188µs
INFO [08-15|11:21:37] Initialising Ethereum protocol versions="[63 62]" network=21382
INFO [08-15|11:21:37] Database conversion successful
INFO [08-15|11:21:37] Loaded most recent local header number=0 hash=7527a6…a2b0e3 td=1
INFO [08-15|11:21:37] Loaded most recent local full block number=0 hash=7527a6…a2b0e3 td=1
INFO [08-15|11:21:37] Loaded most recent local fast block number=0 hash=7527a6…a2b0e3 td=1
INFO [08-15|11:21:37] Starting P2P networking
INFO [08-15|11:21:40] RLPx listener up self=enode://4e0bcd872eca4c3159353ac70b2a4cc1989a70f1b01fb571eb26a8d184fcaf7adc45ba5ee8fe22fd1df729c7bbeed02418646ace0209f6492c8a97db9b676bd8@192.168.1.90:2000
INFO [08-15|11:21:40] IPC endpoint opened: /Users/yen/Desktop/node1/data/geth.ipc
INFO [08-15|11:21:40] HTTP endpoint opened: http://127.0.0.1:8545
Welcome to the Geth JavaScript console!
instance: Geth/v1.6.2-unstable-ef7b9fb7/darwin-amd64/go1.8.1
coinbase: 0x2a7a93ca16e95a6e4478bf67e33ce3a9c20bf66d
at block: 0 (Tue, 15 Aug 2017 10:43:05 CST)
datadir: /Users/yen/Desktop/node1/data
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
should enable
RPC
withweb3
fornode1
. It also can unlock the account here.
- Start
node2
$ ./geth --datadir /Users/yen/Desktop/node2/data --networkid 21382 --port 2001 console
the
networkid
should be the same.the
port
should be different, because these 2 nodes are both in local.
Add Peers
Check the connectivity on each node with below command.
$ net.peerCount
0
This private chain has no lunch node and static node, so that node1
and node2
could not find each others. I have to add node2
to node1
manually.
- find
enode
ofnode1
> admin.nodeInfo
{
enode: "enode://4e0bcd872eca4c3159353ac70b2a4cc1989a70f1b01fb571eb26a8d184fcaf7adc45ba5ee8fe22fd1df729c7bbeed02418646ace0209f6492c8a97db9b676bd8@xxx.xxx.x.xx:2000",
......
}
enode://<id>@<ip>:<port>
- Use below command in console of
node2
> admin.addPeer("enode://4e0bcd872eca4c3159353ac70b2a4cc1989a70f1b01fb571eb26a8d184fcaf7adc45ba5ee8fe22fd1df729c7bbeed02418646ace0209f6492c8a97db9b676bd8@127.0.0.1:2000")
true
replace the
ip
tolocalhost
- check result on console of
node1
> net.peerCount
1
> admin.peers
[{
...
id: "b23ca7187a5c485eb08f25bb7a73e988b24f628757f7a5cbbbacc5c3d3fd89b76390ef0a4cd9d53ca03c145b361fe95fc715b95256a0a2caef20dd3d2687a664",
network: {
localAddress: "127.0.0.1:2000",
remoteAddress: "127.0.0.1:57130"
},
...
}]
Starting Up Your Member Nodes at go-ethereum GitHub