4

I am trying to build a cluster using amazon EC2 instances.

Do I have to set the hostname of each node to what is listed in the .hosts.erlang file?

Currently, .hosts.erlang for each node has:

'ip-10-0-23-186.eu-central-1.compute.internal'.
'ip-10-0-5-10.eu-central-1.compute.internal'.

which are the private DNS of nodes.

and in the vm.args of nodes, I have something like this:

-name api@ip-10-0-5-10.eu-central-1.compute.internal 

I tried to change the hostname to the full private dns, but it only changed to:

ip-10-0-5-10

I checked the cluster, got empty:

$ erl
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V8.0  (abort with ^G)
1> nodes().
[]

I deploy my app using edliver, how can I debug why erlang does not create the expected cluster?

I tried in iex:

iex(3)> hosts_path = Path.expand("/home/admin/.hosts.erlang") 
"/home/admin/.hosts.erlang"
iex(4)> :net_adm.world(:verbose)
[]

edit

I can confirm that the .hosts.erlang can be read:

iex(2)> File.read("/home/admin/.hosts.erlang")
{:ok,
 "'ip-10-0-23-186.eu-central-1.compute.internal'.\n'ip-10-0-5-10.eu-central-1.compute.internal'.\n\n"}

is there a specific folder that I have to run erl from?

In the browser, I can see the app working normally, but I am not sure about the cluster.. please help!

As I am using AWS, here is the security group I am on currently:

enter image description here

simo
  • 23,342
  • 38
  • 121
  • 218
  • (Did you mean to do `Path.expand("~/.hosts/.erlang")` in the iex snippet? Could you also do `File.read` on it, just to confirm?) – Dogbert Nov 28 '16 at 11:33
  • please see edit above – simo Nov 28 '16 at 11:38
  • By starting a shell with erl without a name, you are just starting a local node with no distribution. What is the output when you run `mix edeliver ping production` (or staging, depends which environment you are testing) – Ahmed Omar Nov 28 '16 at 18:13

1 Answers1

1

Ok, I found the solution, I had to define the ip address of nodes in the hosts file at /etc/hosts of each node

10.0.23.186 ip-10-0-23-186.eu-central-1.compute.internal
10.0.5.10   ip-10-0-5-10.eu-central-1.compute.internal
simo
  • 23,342
  • 38
  • 121
  • 218