【问题标题】:How do you run pyflink scripts on AWS EMR?如何在 AWS EMR 上运行 pyflink 脚本?
【发布时间】:2022-04-02 12:43:47
【问题描述】:

我正在努力运行基本的word_count.py pyflink example,它在 AWS EMR 上加载了 apache flink

采取的步骤:

  1. 使用以下应用程序 [Flink, Zookeeper] 成功创建 AWS EMR 6.5.0 集群 - 验证 $PATH 中存在 flinkflink-yarn-session 二进制文件。 AWS 说它安装了v1.14

  2. 通过执行以下操作成功运行 java 版本

  • sudo flink-yarn-sessions
  • sudo flink run -m yarn-cluster -yid <application_id> /usr/lib/flink/examples/batch/WordCount.jar
  1. 尝试使用 python 运行相同但没有骰子
  • sudo flink run -m yarn-cluster -yid <application_id> -py /usr/lib/flink/examples/python/table/word_count.py

虽然python3 是默认设置,但错误很明显它会选择python2.7!!

  1. 通过遵循link 解决了这个问题。然后尝试用一个简单的例子打印出sys.version。这证实了它选择了我的 python 版本

  2. 用 venv 再试一次

  • sudo flink run -m yarn-cluster -yid <application_id> -pyarch file:///home/hadoop/venv.zip -pyclientexec venv.zip/venv/bin/python3 -py /usr/lib/flink/examples/python/table/word_count.py

此时,我开始看到从no file found 到神秘的各种问题

pyflink.util.exceptions.TableException: org.apache.flink.table.api.TableException: Failed to execute sql

我运行了有/无纱线集群的各种排列。但到目前为止没有任何进展。

我认为我的问题要么与环境有关(为什么 AWS 不处理正确的 python 版本超出了我的范围),要么是我对 yarn/pyflink 缺乏经验。

任何指针将不胜感激。

【问题讨论】:

    标签: apache-flink pyflink


    【解决方案1】:

    这就是你所做的。制作集群:

    aws emr create-cluster --release-label emr-6.5.0 --applications Name=Flink --configurations file://./config.json --region us-west-2 --log-uri s3://SOMEBUCKET --instance-type m5.xlarge --instance-count 2 --service-role EMR_DefaultRole --ec2-attributes KeyName=YOURKEYNAME,InstanceProfile=EMR_EC2_DefaultRole --steps Type=CUSTOM_JAR,Jar=command-runner.jar,Name=Flink_Long_Running_Session,Args=flink-yarn-session,-d
    

    config.json 的内容:

    [
      {
        "Classification": "flink-conf",
        "Properties": {
          "python.executable": "python3",
          "python.client.executable": "python3"
        },
        "Configurations": [
          
        ]
      }
    ]
    

    然后,一旦你进入,试试这个

    sudo flink run -m yarn-cluster -yid YID -py /usr/lib/flink/examples/python/table/batch/word_count.py
    

    您可以在 AWS EMR 控制台的应用程序用户界面下找到 YID。

    【讨论】:

      猜你喜欢
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-16
      • 1970-01-01
      • 2014-12-01
      相关资源
      最近更新 更多