更新:我启动了一个 EC2 实例,并且能够让下面的示例正常工作,这证实了这是 Mac 上 Docker 的连接问题。
更新:即使我关闭了 Flink 服务器容器和 Kafka,我仍然会遇到这个错误,这导致我相信这是一个连接问题
我最近尝试使用教程tutorial使用 Python、Apache Beam 和 Apache Flink 处理 Kafka Stream 。根据教程,我使用以下命令设置 Flink:
docker run --net=host apache/beam_flink1.13_job_server:latest
这样做会导致以下结果:
Jul 14, 2021 8:40:47 PM org.apache.beam.runners.jobsubmission.JobServerDriver createArtifactStagingService
INFO: ArtifactStagingService started on localhost:8098
Jul 14, 2021 8:40:47 PM org.apache.beam.runners.jobsubmission.JobServerDriver createExpansionService
INFO: Java ExpansionService started on localhost:8097
Jul 14, 2021 8:40:47 PM org.apache.beam.runners.jobsubmission.JobServerDriver createJobServer
INFO: JobService started on localhost:8099
Jul 14, 2021 8:40:47 PM org.apache.beam.runners.jobsubmission.JobServerDriver run
INFO: Job server now running, terminate with Ctrl+C
使用python main.py
(如下所示)运行我的脚本时,出现以下错误:
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1626301362.091496000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3009,"referenced_errors":[{"created":"@1626301362.091494000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":398,"grpc_status":14}]}"
有谁知道这个的快速解决方法?我应该注意我发现了这个
主文件
import apache_beam as beam
from apache_beam.io.kafka import ReadFromKafka
from apache_beam.options.pipeline_options import PipelineOptions
if __name__ == '__main__':
options = PipelineOptions([
"--runner=PortableRunner",
"--job_endpoint=localhost:8099",
"--environment_type=LOOPBACK",
])
pipeline = beam.Pipeline(options=options)
result = (
pipeline
| "Read from kafka" >> ReadFromKafka(
consumer_config={
"bootstrap.servers": 'localhost:9092',
},
topics=['demo'],
expansion_service='localhost:8097',
)
| beam.Map(print)
)
pipeline.run()