如何在EMR中设置自定义环境变量以用于spark应用程序

Net*_*itz 11 hadoop environment-variables amazon-web-services emr apache-spark

我需要在EMR中设置一个自定义环境变量,以便在运行spark应用程序时可用.

我试过添加这个:

                   ...
                   --configurations '[                                    
                                      {
                                      "Classification": "spark-env",
                                      "Configurations": [
                                        {
                                        "Classification": "export",
                                        "Configurations": [],
                                        "Properties": { "SOME-ENV-VAR": "qa1" }
                                        }
                                      ],
                                      "Properties": {}
                                      }
                                      ]'
                   ...
Run Code Online (Sandbox Code Playgroud)

并试图取代"spark-env hadoop-env 但似乎没有任何效果.

aws论坛有这个答案.但我无法弄清楚如何应用它.我正在运行EMR 5.3.1并使用cli中预先配置的步骤启动它:aws emr create-cluster...

fra*_*ijo 5

将自定义配置(如JSON以下)添加到文件中,例如, custom_config.json

[   
  {
   "Classification": "spark-env",
   "Properties": {},
   "Configurations": [
       {
         "Classification": "export",
         "Properties": {
             "VARIABLE_NAME": VARIABLE_VALUE,
         }
       }
   ]
 }
]
Run Code Online (Sandbox Code Playgroud)

并且,在创建emr集群时,将文件引用传递给该--configurations选项

aws emr create-cluster --configurations file://custom_config.json --other-options...
Run Code Online (Sandbox Code Playgroud)

  • 如果它是真的,听起来像是个错误。尚未尝试过,但是您确定这实际上是有区别的吗?因为当我查看配置下的EMR UI(带有问题的版本)时,我可以看到我的变量已设置。.只是spark应用程序无法 (3认同)

Prz*_*mek 5

对我来说,将Spark-env替换为YARN-ENV解决了问题。