

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

# 建立使用 JupyterHub 的叢集
<a name="emr-jupyterhub-launch"></a>

您可以使用 AWS 管理主控台 AWS Command Line Interface或 Amazon EMR API，透過 JupyterHub 建立 Amazon EMR 叢集。請確定建立叢集時，未選擇在完成步驟後自動終止 ( AWS CLI中的 `--auto-terminate` 選項)。此外，確保管理員和筆記本使用者可以存取您在建立叢集時使用的金鑰對。如需詳細資訊，請參閱《Amazon EMR 管理指南》**中的[使用 SSH 憑證的金鑰對](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan-access-ssh.html)。

## 使用主控台建立具有 JupyterHub 的叢集
<a name="emr-jupyterhub-launch-console"></a>

利用下列的程序，在 Amazon EMR 主控台中使用**進階選項**，來建立安裝了 JupyterHub 的叢集。

**使用 Amazon EMR 主控台來建立安裝了 JupyterHub 的 Amazon EMR 叢集**

1. 導覽至新的 Amazon EMR 主控台，然後從側邊導覽選取**切換至舊主控台**。如需有關切換至舊主控台時預期情況的詳細資訊，請參閱[使用舊主控台](https://docs.aws.amazon.com/emr/latest/ManagementGuide/whats-new-in-console.html#console-opt-in)。

1. 選擇 **Create cluster (建立叢集)**，然後選擇 **Go to advanced options (前往進階選項)**。

1. 在 **Software Configuration (軟體組態)** 中：
   + 針對**版本**，選取 emr-5.36.2，然後選擇 JupyterHub。
   + 如果您使用 Spark，若要使用 AWS Glue Data Catalog 做為 Spark SQL 的中繼存放區，請選取**用於 Spark 資料表中繼資料**。如需詳細資訊，請參閱[在 AWS Amazon EMR 上使用 Glue Data Catalog Catalog 搭配 Spark](emr-spark-glue.md)。
   + 針對 **Edit software settings (編輯軟體設定)** 選擇 **Enter configuration (輸入組態)** 並指定值，或選擇 **Load JSON from S3 (從 S3 載入 JSON)**，然後指定 JSON 組態檔案。如需詳細資訊，請參閱[設定 JupyterHub](emr-jupyterhub-configure.md)。

1. 在 **Add steps (optional) ((新增步驟) (選用))** 中，設定建立叢集時所要執行的步驟，請務必不要選取 **Auto-terminate cluster after the last step is completed (完成最後一個步驟後，自動終止叢集)**，然後選擇 **Next (下一步)**。

1. 選擇 **Hardware Configuration (硬體組態)** 選項、**Next (下一步)**。如需詳細資訊，請參閱《Amazon EMR 管理指南》**中的[設定叢集硬體與聯網](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan-instances.html)。

1. 選擇 **General Cluster Settings (一般叢集設定)** 的選項、**Next (下一步)**。

1. 選擇 **Security Options (安全選項)**、指定一組金鑰對，然後選擇 **Create Cluster (建立叢集)**。

## 使用 使用 JupyterHub 建立叢集 AWS CLI
<a name="emr-jupyterhub-launch-cli"></a>

若要啟動安裝了 JupyterHub 的叢集，請使用 `aws emr create-cluster` 指令，並針對 `--applications` 選項指定 `Name=JupyterHub`。以下範例會在 Amazon EMR 上使用兩個 EC2 執行個體啟動 JupyterHub 叢集 (一個主要和一個核心執行個體)。此外，已啟用偵錯功能，日誌儲存於透過 `--log-uri` 所指定的 Amazon S3 位置。該指定的金鑰對在叢集中提供對 Amazon EC2 執行個體的存取權。

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

```
aws emr create-cluster --name="MyJupyterHubCluster" --release-label emr-5.36.2 \
--applications Name=JupyterHub --log-uri s3://amzn-s3-demo-bucket/MyJupyterClusterLogs \
--use-default-roles --instance-type m5.xlarge --instance-count 2 --ec2-attributes KeyName=MyKeyPair
```