Connecting a Local Cluster of Nodes

I'm attempting to create a cluster of 3 local nodes all on my computer so I can begin to test, but I'm running into problem connecting my nodes.

I first created three separate directories for each node inside a folder on my desktop. I'm running each node with a different directory, same networkid, different port and different rpcport.

When I start my first node: geth --datadir="me/desktop/pvn/testnet/n1" -verbosity 6 --networkid="369" --ipcdisable --port 61916 --rpcport 7898 console 2>> me/desktop/pvn/testnet/n1.log
I then run admin.nodeInfo and grabbed my url which is enode://58ce6bf8a7ef483abfe907a0b0e376d854321b541da9a37cda5bfcac423ad4b46[email protected][::]:61916

I then start my second node: geth --datadir="me/desktop/pvn/testnet/n2" --networkid="369" -verbosity 6 --ipcdisable --port 61917 -rpcport 7899 console 2>> me/desktop/pvn/testnet/n2.log


Next, I use admin.addPeer( enode://58ce6bf8a7ef483abfe907a0b0e376d854321b541da9a37cda5bfcac423ad4b46[email protected]127.0.0.1:61916)

ifconfig|grep netmask|awk '{print $2}'

127.0.0.1
146.244.188.182


I've attempted to use both of the addresses above to parse [::] in the enode address, but anything I try I always end up with:

> {[email protected]0.0.1:61917)
(anonymous): Line 1:20 Unexpected token :
>


I'm stuck on what to do to connect my geth instances. I've tried creating a static-nodes.json file and I put in the enode addresses of the other instances that I created but I don't think I did that right either because nothing is connecting. If I am to create a static-nodes file and I have three geth instances I always want to connect, do I need to put a static-node.json file in each seperate directory of the three nodes I created with the other two nodes' addresses?

-Thank you

Comments

  • varunmamillapallivarunmamillapalli Member Posts: 9
    In the addPeer function, did you enclose the enode URI within quotations?
    Check whether net.listening returns true first.
  • AlwaysSunnyAlwaysSunny Member Posts: 14
    @varunmamillapalli

    Yes I did, and net.listening = true.

    When I attempt to addPeer, I parse [::] with 127.0.0.1. I get a return of true, but when I run net.peerCount, it still remains 0 and unconnected.
  • varunmamillapallivarunmamillapalli Member Posts: 9
    When starting the nodes, add the --maxpeers argument to geth. Since you're trying to create a cluster of 3 local nodes, your command should be "--maxpeers 3".
  • AlwaysSunnyAlwaysSunny Member Posts: 14
    @varunmamillapalli

    Not working, same problem. Returns value true yet when I run net.peerCount, it still returns 0.
  • varunmamillapallivarunmamillapalli Member Posts: 9
    Since you're not using the --nodiscover command, the nodes should automatically get connected.
    Can you post the results of admin.nodeInfo and ifconfig of both the nodes which you're trying to connect?
  • AlwaysSunnyAlwaysSunny Member Posts: 14
    edited June 2016
    @varunmamillapalli
    This is without --nodiscover

    Node1: geth --networkid 369 --identity Daemon1 --verbosity 3 --port 61916 --rpcport 7898 --nat none --datadir="/users/me/desktop/pvn/testnet/n1" console

    admin.nodeInfo: {
    enode: "enode://c1cc47d6309001f623613f8f0f7bdbbc14f8dce2b616a58e4e1dd1d08649fe6d7[email protected][::]:61916",
    id: "c1cc47d6309001f623613f8f0f7bdbbc14f8dce2b616a58e4e1dd1d08649fe6d7ce4e4a8ee350e3e5aaf0efaba228708fbe1621cafad2a0318da06cbfab322d1",
    ip: "::",
    listenAddr: "[::]:61916",
    name: "Geth/v1.4.5-stable-a269a713/darwin/go1.6.2/Daemon1",
    ports: {
    discovery: 61916,
    listener: 61916
    },
    protocols: {
    eth: {
    difficulty: 2199092262,
    genesis: "0x185e942de3505685425e63eb8250944198df1046d5e8b2dbddcb15080a63175a",
    head: "0x49be8709b0f87dceaf2c169dd690841b660ad1b3a8f7f0d327632b7409b8942d",
    network: 369
    }
    }
    }

    Node2: geth --networkid 369 --identity Daemon2 --verbosity 3 --port 61917 --rpcport 7890 --nat none --datadir="/users/me/desktop/pvn/testnet/n2" console

    admin.nodeInfo: {
    enode: "enode://06583512b065fb941a28ee8898e87069c5725dc51b6fe6772b7baaa22bae3140b[email protected][::]:61917",
    id: "06583512b065fb941a28ee8898e87069c5725dc51b6fe6772b7baaa22bae3140bfcb8f4bd8fba07e06585a3670729ef5981de3271700fb4ebfee99dbcd8b3d73",
    ip: "::",
    listenAddr: "[::]:61917",
    name: "Geth/v1.4.5-stable-a269a713/darwin/go1.6.2/Daemon2",
    ports: {
    discovery: 61917,
    listener: 61917
    },
    protocols: {
    eth: {
    difficulty: 50738010194023150,
    genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
    head: "0xbd173535f2fc6f9736f1cee8c3a62d73fe6bc3354855f1521ef3bcadb6c52f6b",
    network: 369
    }
    }
    }

    ---

    ifconfig|grep netmask|awk '{print $2}'
    127.0.0.1
    10.180.87.225
  • varunmamillapallivarunmamillapalli Member Posts: 9
    edited June 2016
    I've started two nodes on the same laptop and got them connected without any problems. Following are the geth instances:
    Adding node:

    Try this and let me know if it works.
  • AlwaysSunnyAlwaysSunny Member Posts: 14
    @varunmamillapalli

    That worked! I still have no idea then why my previous attempts failed. Now how do I go about turning these into static nodes so they always connect? Do I just put the enode URLs with [::] as 127.0.0.1 into a .json file and put it in both the directories of the nodes?
  • varunmamillapallivarunmamillapalli Member Posts: 9
    I haven't tried doing this using static nodes but I think you just need to place it in the datadir of one of the nodes, the node which you want the other nodes get connected to.
  • AlwaysSunnyAlwaysSunny Member Posts: 14
    edited June 2016
    @varunmamillapalli

    I'll test it out. What about the genesis block? Does that only need to be initialised by one of the nodes in one of their datadirs or all of them?
  • varunmamillapallivarunmamillapalli Member Posts: 9
    The genesis block need not be in the datadir of a node. I prefer storing the genesis block in another folder so that it doesn't get overwritten. It should be initialized by every instance, not just one node. If you don't initialize the genesis block, your node will start the blockchain with the default Ethereum genesis block and will be running a different blockchain.
Sign In or Register to comment.