jar package failed to start java Name or service not known solutions

We use in a production environment of a machine-written jar包the 启动脚本discovery jar package will not start, then use the java command to start their own separate jar package, the following error

root@aly-gz-web-1:/etc/init.d# java -Dfile.encoding=UTF-8 -Xmx2048M \
-Dcom.sun.management.jmxremote  \
-Dcom.sun.management.jmxremote.port=30113 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false  \
-jar /data/appdata/kjyl_1000020/kjly.jar

Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: aly-gz-web-1: aly-gz-web-1: Name or service not known

The error is caused because the server could not be found当前主机名对应的ip

Then I went to see the machine's /etc/hostsfile and found the hosts file in the machine 公网IPand the machine 主机名映射after a problem, then modify it as normal, as follows:

# 编辑/etc/hosts文件
vim /etc/hosts

# 有问题的
154.188.27.71 aly-gz-web-100

# 修改后(正确的主机名)
154.188.27.71 aly-gz-web-1

The last execution in the jar package startup script successfully started

root@aly-gz-web-1:/etc/init.d# /etc/init.d/kjyl_1000020 start
{"changed": true, "changes": "kjyl_1000020 start Success"}

Guess you like

Origin blog.51cto.com/12643266/2439828