现象
Cloudera Agent服务已经启动,但报HeartBeat错误,意味着Agent与Server通信有问题。
查看Cloudera Agent日志报错如下,
[22/Feb/2019 16:05:19 +0000] 15199 MainThread _cplogging INFO [22/Feb/2019:16:05:19] ENGINE Started monitor thread '_TimeoutMonitor'.
[22/Feb/2019 16:05:19 +0000] 15199 HTTPServer Thread-2 _cplogging ERROR [22/Feb/2019:16:05:19] ENGINE Error in HTTP server: shutting down
Traceback (most recent call last):
File "/usr/lib64/cmf/agent/build/env/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/process/servers.py", line 187, in _start_http_thread
self.httpserver.start()
File "/usr/lib64/cmf/agent/build/env/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/wsgiserver/wsgiserver2.py", line 1825, in start
raise socket.error(msg)
error: No socket could be created on ('sjtl-n001.esgyn.com', 9000) -- [Errno 99] Cannot assign requested address
解决
根据错误信息,发现是Agent与Server通信错误,可能是IP和机器名映射问题,通过以下python语句验证IP与HOSTNAME映射关系,
python -c 'import socket; print socket.getfqdn(), socket.gethostbyname(socket.getfqdn())'
再使用ifconfig查看IP地址,并查看/etc/hosts,发现是因为/etc/hosts中配置了外网IP导致。