IDEA报错:No hostname could be resolved for the IP address 127.0.0.1, using IP address as host name.

 idea编辑flink连接kafka读取数据时报错:

No hostname could be resolved for the IP address 127.0.0.1, using IP address as host name. Local input split assignment (such as for HDFS files) may be impacted.

kafka正常,该怎么解决?????

package test

  import org.apache.flink.api.common.serialization.SimpleStringSchema
  import org.apache.flink.streaming.api.scala._
  import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
  import java.util.Properties

object task {

  //fink采集kafka数据,分析写入redis
  def main(args: Array[String]): Unit = {
    //  创建运行环境
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1) //设置并行度
    //封装访问kafka集群的配置
    val prop = new Properties()
      prop.setProperty("bootstrap.servers", "master:9092")
    prop.setProperty("group.id", "order-group")

    //将kafka作为数据源添加进env
    //      SimpleStringSchema,是因为kafka是纯字节存储,所以需要在代码中进行反序列化成对象,让Scala可以解析

    val stream = env.addSource(new FlinkKafkaConsumer[String]("order", new SimpleStringSchema(), prop))
    stream.print()
    env.execute()

  }
}

 报错:

C:\Users\Dell\.jdks\corretto-1.8.0_372\bin\java.exe "-javaagent:D:\zxy\IntelliJ IDEA Community Edition 2023.1.3\lib\idea_rt.jar=49820:D:\zxy\IntelliJ IDEA Community Edition 2023.1.3\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Dell\AppData\Local\Temp\classpath1711515240.jar test.task
2023-07-12 19:41:33,481 WARN [org.apache.flink.runtime.webmonitor.WebMonitorUtils] - Log file environment variable 'log.file' is not set.
2023-07-12 19:41:33,481 WARN [org.apache.flink.runtime.webmonitor.WebMonitorUtils] - JobManager log files are unavailable in the web dashboard. Log file location not found in environment variable 'log.file' or configuration key 'web.log.path'.
2023-07-12 19:41:35,146 WARN [org.apache.flink.runtime.taskmanager.Task] - Source: Custom Source -> Sink: Print to Std. Out (1/1)#0 (a8eadfe10e64678882479a27fb34f604) switched from RUNNING to FAILED with failure cause: java.lang.NoSuchMethodError: org.apache.flink.api.common.functions.RuntimeContext.getMetricGroup()Lorg/apache/flink/metrics/MetricGroup;
	at org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumerBase.run(FlinkKafkaConsumerBase.java:705)
	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:116)
	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:73)
	at org.apache.flink.streaming.runtime.tasks.SourceStreamTask$LegacySourceFunctionThread.run(SourceStreamTask.java:323)

2023-07-12 19:41:35,187 WARN [org.apache.flink.runtime.taskmanager.TaskManagerLocation] - No hostname could be resolved for the IP address 127.0.0.1, using IP address as host name. Local input split assignment (such as for HDFS files) may be impacted.
Exception in thread "main" org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
	at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:144)
	at 

进程已结束,退出代码1

当你尝试通过SSH连接到一个主机,错误提示"Could not resolve hostname host_ipaddress: Temporary failure in name resolution"通常表示计算机无法将你提供的IP地址解析为一个有效的域名或主机名。这可能是由于以下几个原因: 1. DNS问题:DNS服务器暂时无法将IP地址映射到正确的主机名。 2. 网络连接问题:本地网络可能存在问题,导致域名解析请求失败。 3. IP地址输入错误:确保你提供的IP地址是准确无误的,并且可以被其他设备访问。 4. hosts文件未配置:检查你的系统hosts文件,确保目标主机的记录正确。 要解决这个问题,你可以尝试以下步骤: 1. **刷新DNS缓存**:在命令行中执行 `ping host_ipaddress` 或 `nslookup host_ipaddress` 来验证能否正常解析。 2. **检查网络连接**:确保你的网络连接稳定,如果可能,尝试重启路由器。 3. **等待一段时间**:有时候DNS错误可能是临时的,稍后再试可能会成功。 4. **手动添加到hosts文件**(仅限于本地环境):编辑`/etc/hosts` 文件(Linux/Mac)或`C:\Windows\System32\drivers\etc\hosts`(Windows),添加一行`host_ipaddress host_name`。 5. **使用IP地址连接**:在SSH命令中直接使用IP地址连接,如`ssh user@host_ipaddress`。 6. **检查防火墙设置**:确保没有阻止SSH连接。 如果你经常遇到此类问题,建议检查网络配置和DNS设置,或者联系网络管理员寻求帮助。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值