O'Reilly logo

Elixir Cookbook by Paulo A Pereira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting nodes

In this recipe, we will start two different terminal sessions that will be our nodes, and we will connect them.

Getting ready

We will need two terminal windows opened and in each of them, we will create a node.

How to do it…

  1. Start a named node in terminal window one:
    > iex --name one@127.0.0.1
    Interactive Elixir (1.0.2) - press Ctrl+C to exit (type h() ENTER for help)
    iex(one@127.0.0.1)1>
    
  2. Start another named node in terminal window two:
    > iex --name two@127.0.0.1
    Interactive Elixir (1.0.2) - press Ctrl+C to exit (type h() ENTER for help)
    iex(two@127.0.0.1
    )1>
    
  3. Verify the list of nodes that each of our newly created nodes is aware of:
    iex(one@127.0.0.1)1> Node.list
    []
    iex(two@127.0.0.1)1> Node.list
    []
    
  4. To connect the two nodes, we will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required