Amazon Redshift Spectrum 入门 - Amazon Redshift
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

Amazon Redshift Spectrum 入门

在本教程中,您将了解如何使用 Amazon Redshift Spectrum 直接从 Amazon S3 上的文件中查询数据。如果您已经有一个集群和一个 SQL 客户端,您通过极少的设置即可完成本教程。

注意

Redshift Spectrum 查询将产生额外的费用。本教程中运行示例查询的费用极低。有关定价的更多信息,请参阅 Amazon Redshift Spectrum 定价

先决条件

要使用 Redshift Spectrum,您需要一个 Amazon Redshift 集群和一个连接到集群的 SQL 客户端,供您运行 SQL 命令。该集群和 Amazon S3 中的数据文件必须位于同一 Amazon Web Services 区域中。

有关如何创建 Amazon Redshift 集群的信息,请参阅《Amazon Redshift 入门指南》中的Amazon Redshift 集群和数据加载。有关连接到集群的方法的信息,请参阅《Amazon Redshift 入门指南》中的连接到 Amazon Redshift 预置集群

在下面的一些示例中,示例数据位于美国东部(弗吉尼亚州北部)(us-east-1),因此您需要一个也位于 us-east-1 的集群。或者,您可以使用 Amazon S3 将以下桶和文件夹中的数据对象复制到集群所在的 Amazon Web Services 区域的桶中:

  • s3://redshift-downloads/tickit/spectrum/customers/*

  • s3://redshift-downloads/tickit/spectrum/sales_partition/*

  • s3://redshift-downloads/tickit/spectrum/sales/*

  • s3://redshift-downloads/tickit/spectrum/salesevent/*

运行类似于以下内容的 Amazon S3 命令,将位于美国东部(弗吉尼亚州北部)的示例数据复制到您的 Amazon Web Services 区域。在运行命令之前,请创建桶并在此桶中创建文件夹,以匹配您的 Amazon S3 copy 命令。Amazon S3 copy 命令的输出确认文件已复制到所需 Amazon Web Services 区域中的 bucket-name

aws s3 cp s3://redshift-downloads/tickit/spectrum/ s3://bucket-name/tickit/spectrum/ --copy-props none --recursive

使用 Amazon CloudFormation 的 Redshift Spectrum 入门

作为以下步骤的替代方法,您可以访问 Redshift Spectrum DataLake Amazon CloudFormation 模板,以创建一个包含您可查询的 Amazon S3 桶的堆栈。有关更多信息,请参阅启动您的 Amazon CloudFormation 堆栈,然后在 Amazon S3 中查询您的数据

Redshift Spectrum 入门分步指南

要开始使用 Amazon Redshift Spectrum,请执行以下步骤: