[SOLVED] Need help to setup a new IPFS cluster with 2 peers

[Moderatorā€™s note: the information in this post regarding IPFS Cluster is outdated. Head over to https://cluster.ipfs.io for updated documentation]

Hi.

I wanted to create an IPFS cluster using Docker. Here is what I did.

  1. Just pulled the 2 Docker images

    docker pull ipfs/ipfs-cluster
    docker pull ipfs/go-ipfs

  2. Create a docker compose file:

    version: ā€˜3ā€™
    services:
    cluster:
    image: ipfs/ipfs-cluster
    ports:
    - 8080:8080
    - 4001:4001
    - 5001:5001
    volumes:
    - ./cluster/config:/data/ipfs-cluster
    peer_a:
    image: ipfs/go-ipfs
    ports:
    - 8081:8080
    - 4002:4001
    - 127.0.0.1:5002:5001
    peer_b:
    image: ipfs/go-ipfs
    ports:
    - 8082:8080
    - 4003:4001
    - 127.0.0.1:5003:5001

  3. Start all my containers. Everything looks fine. When I checked my 2 peers, I get that for my first peer:

    peer identity: QmaFoihnHq3BM8XMtchnjjtpAW3Fh3X2G4X12d8Hp5xStW

And that for my second peer:

peer identity: QmS5SCyyj44KcUouga1QQ5amRQ4VLUVzVLRc2vXQaDBh9f
  1. Then, I login to my cluster container and I want to add my peers. To be sure to have the right address, first, I do:

    ipfs swarm peers | grep QmaFoihnHq3BM8XMtchnjjtpAW3Fh3X2G4X12d8Hp5xStW

And I get:

/ip4/172.26.0.2/tcp/4001/ipfs/QmaFoihnHq3BM8XMtchnjjtpAW3Fh3X2G4X12d8Hp5xStW

So, I try to run the following command:

ipfs-cluster-ctl --debug peers add /ip4/172.26.0.2/tcp/4001/ipfs/QmaFoihnHq3BM8XMtchnjjtpAW3Fh3X2G4X12d8Hp5xStW

But I get the following error:

12:36:53.780 DEBUG cluster-ct: POST: http://127.0.0.1:9094/peers main.go:444
12:37:03.785 DEBUG cluster-ct: Response body: {"code":500,"message":"dial attempt failed: \u003cpeer.ID cqpaEy\u003e --\u003e \u003cpeer.ID aFoihn\u003e dial attempt failed: connection refused"}
 main.go:461
An error ocurred:
  Code: 500
  Message: dial attempt failed: <peer.ID cqpaEy> --> <peer.ID aFoihn> dial attempt failed: connection refused

If I retry, I get the following error:

12:39:25.402 DEBUG cluster-ct: POST: http://127.0.0.1:9094/peers main.go:444
12:39:25.404 DEBUG cluster-ct: Response body: {"code":500,"message":"dial backoff"}
 main.go:461
An error ocurred:
  Code: 500
  Message: dial backoff

I donā€™t see what Iā€™m doing wrong :confused:

Thanks for your help

Hey @bchevallereau,

I see a number of misunderstandingsā€¦

  • The ipfs/ipfs-cluster docker container runs both the ipfs and the ipfs-cluster peers on the same container.
  • The ipfs Peer ID is completely different from the ipfs-cluster peer ID. ipfs swarm peers will not list ipfs-cluster peers.
  • ipfs-cluster-ctl --debug peers add takes an ipfs-cluster peer multiaddress. By default this will be a /9096/ as that is the port in which the cluster peer listens.
  • Note that by default by launching two separate containers both ipfs-cluster peers will be initialized with different cluster_secret and will not be able to talk to each other. I recommend mounting the configuration (/data/ipfs-cluster folder, including service.json) from the outside, setting at least the same secret in both (or leaving it empty). Alternatively you could set the CLUSTER_SECRET environment variable with the same value for both containers, for example CLUSTER_SECRET=c5c7199d2b3bf59a6369c249982fcf309285bdecd79396af6838dbd489d9e019 (32 byte hex-encoded secret). That should make sure that they are initialized with the same secret.

Hope it helps!

2 Likes

Hi

First, thanks a lot for your answer. Yes, I noticed that the ipfs/ipfs-cluster docker container runs both. But I wanted to add more peers. So itā€™s why I created the other containers.

And it was one of my question. I didnā€™t know if i should create multiple ipfs/ipfs-cluster or add more ipfs/go-ipfs containers if I wanted multiple peers. If I understand your reply, I should definitely create multiple ipfs/ipfs-cluster containers.

Thanks again

Yeah thatā€™s right, one cluster peer per ipfs peer.

Thanks, it works perfectly well now. Just created 2 containes with this docker compose file:

version: '3'
services:
  peer-1:
    image: ipfs/ipfs-cluster
    ports:
      - 8080:8080
      - 4001:4001
      - 5001:5001
    volumes:
      - ./cluster/peer-1/config:/data/ipfs-cluster
  peer-2:
    image: ipfs/ipfs-cluster
    ports:
      - 8081:8080
      - 4002:4001
      - 5002:5001
    volumes:
      - ./cluster/peer-2/config:/data/ipfs-cluster

And then updated th service.json file to have the same value in the field cluster_secret . And then, I added my peer like that:

ipfs-cluster-ctl peers add /ip4/172.26.0.3/tcp/9096/ipfs/QmcLEdDDZ36vBeHnoHV3uDPd7z8Bt2PfPLBgYhMwWqu579

And it works perfectly well!

Thanks

1 Like

hi, now igot a cluster problem on windows7 when a run ā€œipfs-cluster-ctl peers addā€ it return ā€œNo help topic for ā€˜addā€™ā€

Hi, Iā€™m going to lock this topic as it is old and instructions here might be misleading. For docs on cluster, head over to https://cluster.ipfs.io/documentation.