[Solved] ERROR RocketmqCommon-Failed to obtain the host name

report an error when building a rocketmq stand-alone environment.

Problem encountered: using command

nohup sh mqnamesrv &

The following error occurred

java. net. UnknownHostException: hadoop03: hadoop03: unknown error
at java. net. InetAddress. getLocalHost(InetAddress.java:1505)
at org. apache. rocketmq. common. BrokerConfig. localHostName(BrokerConfig.java:201)
at org. apache. rocketmq. common. BrokerConfig.& lt; init> (BrokerConfig.java:39)
at org. apache. rocketmq. broker. BrokerStartup. createBrokerController(BrokerStartup.java:101)
at org. apache. rocketmq. broker. BrokerStartup. main(BrokerStartup.java:56)
Caused by: java. net. UnknownHostException: hadoop03: unknown error
at java. net. Inet4AddressImpl. lookupAllHostAddr(Native Method)
at java. net. InetAddress$2. lookupAllHostAddr(InetAddress.java:928)
at java. net. InetAddress. getAddressesFromNameService(InetAddress.java:1323)
at java. net. InetAddress. getLocalHost(InetAddress.java:1500)
… 4 common frames omitted

This is because the IP address corresponding to your host name cannot be found during startup. Just add the above configuration in /etc/hosts

Solution:

Operate according to the following command

Add the mapping marked in red to the file. Note: permission problems may occur during editing, and the root account needs to be switched

:wq! Save exit

Use the JPS command to check the process to see if NamesrvStartup has been started. If it is about closing it

sh mqshutdown namesrv

Start mqnamesrv again

nohup sh mqnamesrv &

Check the log and solve the problem

Read More: