---
schema_version: "1"
id: b2dcae4489287364dee3881f0af8ef79e2f4adfd6e88ac29f260d31811721d8a
title: Amazon Athena
collection: tableau
version: current
locale: zh-cn
portal_url: https://docs.salesforce.com/tableau/current/zh-cn/pro/desktop/examples_amazonathena.md
canonical_url: https://help.tableau.com/current/pro/desktop/zh-cn/examples_amazonathena.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 16f688a9f232c81f9aca000914b226c23d1cc3350dc5a129baaffd3c3d2ff1c5
description: Connect Tableau to Amazon Athena data and set up the data source, including OAuth options.
---
[跳转到主要内容](#main-content)

# Amazon Athena

本文介绍如何将 Tableau 连接到 Amazon Athena 数据并设置数据源。有关将 OAuth/OIDC 与 Amazon Athena 结合使用的信息，请参见[设置 Amazon Athena IAM OAuth](https://help.tableau.com/current/pro/desktop/zh-cn/amazon_athena_idp.htm)。

**注意：**若要连接到 Amazon Athena，您需要打开端口 443 (ssl) 和 444。

## 开始之前

在开始之前，请收集以下连接信息：

- 承载要连接到的数据库的服务器的名称。格式应如下所示：athena.\[区域\].amazonaws.com。例如：`athena.us-east-1.amazonaws.com`
- S3 暂存目录的名称。例如，`s3://aws-athena-query-results-123456785678-us-eastexample-2/`
- Amazon Web Services (AWS) 访问密钥（访问密钥 ID 和密文访问密钥）。有关详细信息，请参见 AWS 网站上的[访问密钥](http://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys)。
- （可选）要在每次 Tableau 连接时运行的初始 SQL 语句

> [!TIP]
> 
> **提示：**若要支持多个用户和工作组，您可以在服务器字段中添加工作组。例如：`athena.us-east-1.amazonaws.com:443;Workgroup=Name`

### 需要驱动程序

此连接器需要驱动程序才能与数据库通信。如果计算机上未安装该驱动程序，Tableau 将在连接对话框中显示一条错误消息，其中包含指向[驱动程序下载](https://www.tableau.com/zh-cn/support/drivers)页面的链接，您可在该页面中找到驱动程序链接和安装说明。

## 进行连接并设置数据源

1. 启动 Tableau，并在“连接”下选择“Amazon Athena”。有关数据连接的完整列表，请在“至服务器”下选择“更多”。然后执行以下操作：
    
    1. 输入服务器名称。
    2. 输入 S3 暂存目录的名称。
    3. 在“用户名”字段中输入您的 AWS 访问密钥 ID。
    4. 在“密码”字段中输入您的 AWS 密文访问密钥。
    5. （可选）选择“初始 SQL”以指定要在每次连接开始时（例如打开工作簿、刷新数据提取、登录到 Tableau Server 或发布到 Tableau Server 时）运行的 SQL 命令。有关详细信息，请参见[运行初始 SQL](https://help.tableau.com/current/pro/desktop/zh-cn/connect_basic_initialsql.htm)。
    6. 选择“登录”。
        
        如果 Tableau 无法建立连接，请验证您的凭据是否正确。如果仍然无法连接，则说明您的计算机在定位服务器时遇到问题。请与您的网络管理员或数据库管理员联系以获得更多帮助。
2. 在数据源页面上，执行下列操作：
    
    1. （可选）在**“连接”**下，选择默认数据源。
    2. 选择要使用的目录和数据库。
    3. 将一个或多个表拖到工作区。
    4. 选择工作表标签以开始分析。
        
        使用自定义 SQL 连接到特定查询，而非整个数据源。有关详细信息，请参见[连接到自定义 SQL 查询](https://help.tableau.com/current/pro/desktop/zh-cn/customsql.htm)。

> [!TIP]
> 
> **提示**：如果您在 Catalog 下拉菜单中只看到默认的 **AwsDataCatalog**，则可以向 athena.properties 文件中添加`MetadataRetrievalMethod=ProxyAPI` 行来解决该问题。有关详细信息，请参见[使用属性文件自定义 JDBC 连接](https://community.tableau.com/s/question/0D54T00000F339uSAB/customize-jdbc-connections-using-a-properties-file)。

## 自定义 JDBC 连接

Amazon Athena 使用 JDBC 连接，您可以使用属性文件对其进行自定义。有关详细信息，请参见 Tableau 社区中的[使用属性文件自定义 JDBC 连接](https://community.tableau.com/s/question/0D54T00000F339uSAB/customize-jdbc-connections-using-a-properties-file)。

## 另请参见

- [设置数据源](https://help.tableau.com/current/pro/desktop/zh-cn/datasource_prepare.htm) – 向此数据源中添加更多数据，或者在分析数据之前准备数据。
- [构建图表和分析数据](https://help.tableau.com/current/pro/desktop/zh-cn/design_and_analyze.htm) – 开始数据分析。

- [在 Tableau 10.3（及更高版本）中使用 Amazon Athena 连接器连接到 S3 数据](https://www.tableau.com/zh-cn/about/blog/2017/5/connect-your-s3-data-amazon-athena-connector-tableau-103-71105) - 包含 Amazon Athena 资源链接的 Tableau 博文。
- [Tableau Desktop 未能通过代理连接到 Amazon Athena，并出现错误代码 37CE01A3](https://kb.tableau.com/articles/Issue/Tableau-Desktop-Fails-To-Connect-to-Amazon-Athena-through-Proxy-With-Error-Code-37CE01A3?lang=zh-cn) - Tableau 知识库文章，其中包含用于解决问题的步骤。

## 此部分中的其他文章