

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

# 使用 Presto on Amazon EMR 的考量
<a name="emr-presto-considerations"></a>

當您執行 [Presto](https://aws.amazon.com/big-data/what-is-presto/) on Amazon EMR 時，請考慮以下限制。

## Presto 命令列可執行檔
<a name="emr-presto-command-line-cli"></a>

在 Amazon EMR 中，PrestoDB 和 Trino 都使用相同的命令列可執行檔 `presto-cli`，如以下範例所示。

```
presto-cli --catalog hive
```

## 不可設定的 Presto 部署屬性
<a name="emr-presto-deployment-config"></a>

您使用的 Amazon EMR 版本決定了可用的 Presto 部署組態。如需有關這些組態屬性的詳細資訊，請參閱 Presto 文件中的[部署 Presto](https://prestodb.io/docs/current/installation/deployment.html)。下表顯示 Presto `properties` 檔案的不同組態選項。


| 檔案 | 可設定 | 
| --- | --- | 
|  `log.properties`  |  PrestoDB：在 Amazon EMR 版本 4.0.0 及更高版本中可設定。使用 `presto-log` 組態分類。  | 
|  `config.properties`  |  PrestoDB：在 Amazon EMR 版本 4.0.0 及更高版本中可設定。使用 `presto-config` 組態分類。  | 
|  `hive.properties`  |  PrestoDB：在 Amazon EMR 版本 4.1.0 及更高版本中可設定。使用 `presto-connector-hive` 組態分類。  | 
|  `node.properties`  |  PrestoDB：在 Amazon EMR 版本 5.6.0 及更高版本中可設定。使用 `presto-node` 組態分類。  | 
|  `jvm.config`  |  不可設定。  | 

## PrestoDB 安裝
<a name="emr-prestodb-prestosql"></a>

應用程式名稱 *Presto* 繼續被用來在叢集上安裝 PrestoDB。

您可以安裝 PrestoDB 或 Trino，但您不能在單個叢集上同時安裝兩者。如果在嘗試建立叢集時同時指定 PrestoDB 和 Trino，會發生驗證錯誤而且叢集建立請求將會失敗。

## EMRFS 和 PrestoS3FileSystem 組態
<a name="emr-presto-prestos3"></a>

在 Amazon EMR 版本 5.12.0 及更高版本中，PrestoDB 可以使用 EMRFS。如需詳細資訊，請參閱《Amazon EMR 管理指南》**中的 [EMR 檔案系統 (EMRFS)](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-fs)。對於早期版本的 Amazon EMR，PrestoS3FileSystem 是唯一的組態選項。

您可以使用安全組態來設定 Amazon S3 中的 EMRFS 資料加密。您也可以向 Amazon S3 請求使用 EMRFS 的 IAM 角色。如需詳細資訊，請參閱《Amazon EMR 管理指南》**中的[了解加密選項](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-data-encryption-options.html)和[設定向 Amazon S3 請求使用 EMRFS 的 IAM 角色](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-emrfs-iam-roles.html)。

**注意**  
如果您使用 Amazon EMR 版本 5.12.0 查詢 Amazon S3 中的基礎資料，則可能發生 Presto 錯誤。這是因為 Presto 無法從 `emrfs-site.xml` 中取用組態分類值。解決辦法是，在 `usr/lib/presto/plugin/hive-hadoop2/` 下方建立 `emrfs` 子目錄，並在 `usr/lib/presto/plugin/hive-hadoop2/emrfs` 中建立 symlink 以連線至現有 `/usr/share/aws/emr/emrfs/conf/emrfs-site.xml` 檔案。然後重新啟動 presto-server 程序 (`sudo presto-server stop` 在 `sudo presto-server start` 之前)。

您可以覆寫 EMRFS 預設值並改用 PrestoS3FileSystem。若要這樣做，請使用 `presto-connector-hive` 組態分類將 `hive.s3-file-system-type` 設定為 `PRESTO`，如以下範例所示。如需詳細資訊，請參閱[設定應用程式](emr-configure-apps.md)。

```
[
   {
      "Classification": "presto-connector-hive",
      "Properties": {
         "hive.s3-file-system-type": "PRESTO"
      }
   }
]
```

如果您使用 PrestoS3FileSystem，請使用 `presto-connector-hive` 組態分類來設定 PrestoS3FileSystem 屬性。如需有關可用屬性的詳細資訊，請參閱 Presto 文件中「Hive 連接器」一節的 [Amazon S3 組態](https://prestodb.io/docs/current/connector/hive.html#amazon-s3-configuration)。這些設定不適用於 EMRFS。

## 最終使用者模擬的預設設定
<a name="emr-presto-end-user-impersonation"></a>

依預設，在 Amazon EMR 版本 5.12.0 和更高版本中可透過最終使用者模擬存取 HDFS。如需詳細資訊，請參閱 Presto 文件中的[最終使用者模擬](https://prestodb.io/docs/current/connector/hive-security.html#end-user-impersonation)。若要使用 `presto-config` 組態分類變更此設定，請將 `hive.hdfs.impersonation.enabled` 屬性設為 `false`。

## Presto Web 界面的預設連接埠
<a name="emr-presto-default-web-port"></a>

依預設，Amazon EMR 會在 Presto 協調器上將 Presto Web 界面設定為使用連接埠 8889 (針對 PrestoDB 和 Trino).。若要變更連接埠，則使用 `presto-config` 組態分類來設定 `http-server.http.port` 屬性。如需詳細資訊，請參閱 Presto 文件中*部署 Presto* 一節的[設定屬性](https://prestodb.io/docs/current/installation/deployment.html#config-properties)。

## 某些版本中 Hive 儲存貯體執行的問題
<a name="emr-presto-bucket-execution"></a>

Presto 152.3 版有 Hive 儲存貯體執行的問題，此問題會在某些情況下，造成 Presto 查詢效能大幅降低。Amazon EMR 版本 5.0.3、5.1.0 和 5.2.0 包含此版本 Presto。為解決此問題，請使用 `presto-connector-hive` 組態分類將 `hive.bucket-execution` 屬性設定為 `false`，如以下範例所示。

```
[
   {
      "Classification": "presto-connector-hive",
      "Properties": {
         "hive.bucket-execution": "false"
      }
   }
]
```