I am trying to setup a cluster with Ambari 2.5 on Ubuntu 14.04 and keep on getting the following error while registering hosts.
ERROR 2017-05-02 05:16:35,285 main.py:244 - Ambari agent machine hostname (localhost) does not match expected ambari server hostname (pos2-retl1). Aborting registration. Please check hostname, hostname -f and /etc/hosts file to confirm your hostname is setup correctly
SSH is working fine from ambari server host to other hosts and I have completed the environment setup. Attempted manual registration as well.
This error message indicates that you have not setup the "FQDN" properly on your hosts.
Please make sure that the output of the following commands is reflecting your correct hostname and is accessible from the ambari host.
# hostname -f
returns the correct hostname (pos2-retl1). Somehow Ambari agent machine hostname (localhost) is incorrect.
Can you please check and share the "/etc/hosts" file was updated with the proper IP address and FQDN through out the cluster nodes. Also the "ambari-agent.ini" file to verify if it is using the correct Ambari Hostname.
Sometime back i have written an article that explains how we can have customized hostname and tell ambari-agent to use it.
Please try using the "hostname_script" and "public_hostname_script" attributes in your "/etc/ambari-agent/conf/ambari-agent.ini" and in the [agent] to define your own script to use the hostname.
The following links will help you setting up the correct Hostnames/FQDN.
Please update the config to point to the correct ambari server endpoint
[server] hostname = <ambari-server-ip> url_port = 8440
I get the correct hostname set in /etc/hosts when I run
Somehow when I run the following, I don't get the correct host
python -c 'import socket; print socket.getfqdn()'
This hostname difference is caused by a python issue with socket.getfqdn(). Details regarding this specific python issue can be found at https://bugs.python.org/issue5004.
Ambari code also uses the same socket.getfqdn() to get the hostname thus resulting in the error I have mentioned in the question. I have not come across a workaround or a solution yet.