程序出现UnknownHostException异常:

Caused by: java.net.UnknownHostException: iZwz9eozywgp2wc41sg3a5Z: 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)

image

解决办法:

1. 修改hostname

hostnamectl set-hostname s01

2. 修改host配置

vim /etc/hosts

# 新增内容
10.0.0.201 s01
如果觉得我的文章对你有用,请随意赞赏