启动集群时在 EMR 上配置 Zeppelin 的 Spark Interpreter

Configure Zeppelin's Spark Interpreter on EMR when starting a cluster

我正在 EMR 上创建集群并将 Zeppelin 配置为从 S3 读取笔记本。为此,我使用了一个看起来像这样的 json 对象:

[
  {
    "Classification": "zeppelin-env",
    "Properties": {

    },
    "Configurations": [
      {
        "Classification": "export",
        "Properties": {
        "ZEPPELIN_NOTEBOOK_STORAGE":"org.apache.zeppelin.notebook.repo.S3NotebookRepo",
          "ZEPPELIN_NOTEBOOK_S3_BUCKET":"hs-zeppelin-notebooks",
          "ZEPPELIN_NOTEBOOK_USER":"user"
        },
        "Configurations": [

        ]
      }
    ]
  }
]

我将此对象粘贴到 EMR 的 Stoftware 配置页面中: 我的问题是,how/where 我可以直接配置 Spark 解释器,而不需要每次启动集群时都从 Zeppelin 手动配置它吗?

这有点复杂,您需要做两件事:

  1. 编辑 Zeppelininterpreter.json
  2. 重启解释器

所以您需要做的是编写一个 shell 脚本,然后向运行此 shell 脚本的 EMR 集群配置添加一个额外的步骤。

Zeppelin配置在json,可以使用jq(一种工具)来操作json。我不知道你到底想改变什么,但这里有一个添加(神秘地缺失的)DepInterpreter 的例子:

#!/bin/bash

# 1 edit the Spark interpreter
set -e
cat /etc/zeppelin/conf/interpreter.json | jq '.interpreterSettings."2ANGGHHMQ".interpreterGroup |= .+ [{"class":"org.apache.zeppelin.spark.DepInterpreter", "name":"dep"}]' | sudo -u zeppelin tee /etc/zeppelin/conf/interpreter.json


# Trigger restart of Spark interpreter
curl -X PUT http://localhost:8890/api/interpreter/setting/restart/2ANGGHHMQ

将此 shell 脚本放入 s3 存储桶中。 然后使用

启动您的 EMR 集群
--steps Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://eu-west-1.elasticmapreduce/libs/script-runner/script-runner.jar,Args=[s3://mybucket/script.sh]

我建议使用 Terraform 创建集群 有一个命令:

configurations_json = "${file("config.json")}"

可以让您注入一个 json 文件作为您的 emr 集群的配置文件

https://www.terraform.io/docs/providers/aws/r/emr_cluster.html

问候