

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 設定 JupyterHub
<a name="emr-jupyterhub-configure"></a>

您可以藉由連接至叢集主節點並編輯組態檔案，來自訂 Amazon EMR 上 JupyterHub 的組態和個別的使用者筆記本。在您變更值後，重新啟動 `jupyterhub` 容器。

在下列檔案中修改屬性來設定 JupyterHub 和個別的 Jupyter 筆記本：
+ `jupyterhub_config.py` – 依預設，此檔案儲存在主節點上的 `/etc/jupyter/conf/` 目錄中。如需詳細資訊，請參閱 JupyterHub 文件中的[組態基礎概念](http://jupyterhub.readthedocs.io/en/latest/getting-started/config-basics.html)。
+ `jupyter_notebook_config.py` – 此檔案預設儲存在 `/etc/jupyter/` 目錄中，而且預設為複製到 `jupyterhub` 容器。如需詳細資訊，請參閱 Jupyter 筆記本文件中的[組態檔和命令列選項](https://jupyter-notebook.readthedocs.io/en/5.7.4/config.html)。

您也可以使用 `jupyter-sparkmagic-conf` 組態分類來自訂 Sparkmagic，這會為 Sparkmagic 更新 `config.json` 檔案中的值。關於可用的設定，詳細資訊請參閱 [GitHub 上的 example\$1config.json](https://github.com/jupyter-incubator/sparkmagic/blob/master/sparkmagic/example_config.json)。如需有關在 Amazon EMR 中對應用程式使用組態分類的詳細資訊，請參閱 [設定應用程式](emr-configure-apps.md)。

下列範例使用 啟動叢集 AWS CLI，並參考 Sparkmagic 組態分類設定`MyJupyterConfig.json`的檔案。

**注意**  
包含 Linux 行接續字元 (\$1) 是為了提高可讀性。它們可以在 Linux 命令中移除或使用。對於 Windows，請將其移除或取代為插入符號 (^)。

```
aws emr create-cluster --use-default-roles --release-label emr-5.14.0 \
--applications Name=Jupyter --instance-type m4.xlarge --instance-count 3 \
--ec2-attributes KeyName=MyKey,SubnetId=subnet-1234a5b6 --configurations file://MyJupyterConfig.json
```

`MyJupyterConfig.json` 範例內容如下：

```
[
    {
    "Classification":"jupyter-sparkmagic-conf",
    "Properties": {
      "kernel_python_credentials" : "{\"username\":\"diego\",\"base64_password\":\"mypass\",\"url\":\"http:\/\/localhost:8998\",\"auth\":\"None\"}"
      }
    }
]
```

**注意**  
對於 Amazon EMR 版本 5.21.0 及更高版本，您可以覆寫叢集組態，並且為執行中叢集的每個執行個體群組，指定額外組態分類。您可以使用 Amazon EMR 主控台、 AWS Command Line Interface (AWS CLI) 或 AWS SDK 來執行此操作。如需詳細資訊，請參閱[為執行中叢集的執行個體群組提供組態](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps-running-cluster.html)。