本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
EMRFS CLI 命令参考
默认情况下,EMRFS CLI 安装在使用 Amazon EMR 发行版 3.2.1 或更高版本创建的所有集群主节点上。您可以使用 EMRFS CLI 管理一致视图的元数据。
注意
只有 VT1 00 终端仿真支持该emrfs命令。但是,它可能适用于其它终端仿真器模式。
emrfs 顶级命令
emrfs 顶级命令支持以下结构。
emrfs [describe-metadata | set-metadata-capacity | delete-metadata | create-metadata | \ list-metadata-stores | diff | delete | sync | import ]
[options]
[arguments]
指定 [选项],根据需要使用或不使用下表中描述的 [参数]。有关特定于子命令 (describe-metadata
、set-metadata-capacity
等) 的 [选项],请参阅下面的每个子命令。
选项 | 描述 | 必填 |
---|---|---|
|
用于向 Amazon S3 写入对象以及在 DynamoDB 中创建或访问元数据存储的访问密钥。 Amazon 默认情况下,设置 |
否 |
|
与您用于向 Amazon S3 写入对象以及在 DynamoDB 中创建或访问元数据存储的访问 Amazon 密钥关联的密钥。默认情况下,设置 |
否 |
|
使输出为详细模式。 |
否 |
|
通过用法语句显示 |
否 |
emrfs describe-metadata 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
例 emrfs describe-metadata 示例
以下示例描述默认元数据表。
$ emrfs describe-metadata EmrFSMetadata read-capacity: 400 write-capacity: 100 status: ACTIVE approximate-item-count (6 hour delay): 12
emrfs set-metadata-capacity 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
|
对元数据表请求的读取吞吐容量。如果未提供 |
否 |
|
对元数据表请求的写入吞吐容量。如果未提供 |
否 |
例 emrfs 示例 set-metadata-capacity
以下示例将名为 600
的元数据表的读取吞吐容量设置为 150
,将写入容量设置为 EmrMetadataAlt
。
$ emrfs set-metadata-capacity --metadata-name EmrMetadataAlt --read-capacity 600 --write-capacity 150 read-capacity: 400 write-capacity: 100 status: UPDATING approximate-item-count (6 hour delay): 0
emrfs delete-metadata 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
例 emrfs delete-metadata 示例
以下示例删除默认元数据表。
$ emrfs delete-metadata
emrfs create-metadata 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
|
对元数据表请求的读取吞吐容量。如果未提供 |
否 |
|
对元数据表请求的写入吞吐容量。如果未提供 |
否 |
例 emrfs create-metadata 示例
以下示例创建一个名为 EmrFSMetadataAlt
的元数据表。
$ emrfs create-metadata -m EmrFSMetadataAlt Creating metadata: EmrFSMetadataAlt EmrFSMetadataAlt read-capacity: 400 write-capacity: 100 status: ACTIVE approximate-item-count (6 hour delay): 0
emrfs list-metadata-stores 子命令
emrfs list-metadata-stores 子命令没有任何 [选项]。
例 List-metadata-stores 示例
以下示例列出您的元数据表。
$ emrfs list-metadata-stores EmrFSMetadata
emrfs diff 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
|
与元数据表进行比较的 Amazon S3 存储桶的路径。存储桶以递归方式同步。 |
是 |
例 emrfs diff 示例
以下示例将默认元数据表与 Amazon S3 存储桶进行比较。
$ emrfs diff s3://elasticmapreduce/samples/cloudfront BOTH | MANIFEST ONLY | S3 ONLY DIR elasticmapreduce/samples/cloudfront DIR elasticmapreduce/samples/cloudfront/code/ DIR elasticmapreduce/samples/cloudfront/input/ DIR elasticmapreduce/samples/cloudfront/logprocessor.jar DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-14.WxYz1234 DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-15.WxYz1234 DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-16.WxYz1234 DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-17.WxYz1234 DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-18.WxYz1234 DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-19.WxYz1234 DIR elasticmapreduce/samples/cloudfront/input/XABCD12345678.2009-05-05-20.WxYz1234 DIR elasticmapreduce/samples/cloudfront/code/cloudfront-loganalyzer.tgz
emrfs delete 子命令
选项 |
描述 |
必填 |
---|---|---|
|
|
否 |
|
为实现一致视图而跟踪的 Amazon S3 存储桶的路径。存储桶以递归方式同步。 |
是 |
-t |
过期时间 (使用时间单位参数进行解释)。将删除指定存储桶中所有早于 |
|
|
用于解释时间参数的度量值 (纳秒、微秒、毫秒、秒、分钟、小时或天)。如果未指定参数,则默认值为 |
|
|
请求用于 delete 操作的可用读取吞吐量。如果未指定 |
否 |
|
请求用于 delete 操作的可用写入吞吐量。如果未指定 |
否 |
例 emrfs delete 示例
以下示例从一致视图的跟踪元数据中删除一个 Amazon S3 存储桶中的所有对象。
$ emrfs delete s3://elasticmapreduce/samples/cloudfront entries deleted: 11
emrfs import 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
|
为实现一致视图而跟踪的 Amazon S3 存储桶的路径。存储桶以递归方式同步。 |
是 |
|
请求用于 delete 操作的可用读取吞吐量。如果未指定 |
否 |
|
请求用于 delete 操作的可用写入吞吐量。如果未指定 |
否 |
例 emrfs import 示例
以下示例随一致视图的跟踪元数据导入一个 Amazon S3 存储桶中的所有对象。忽略所有未知键。
$ emrfs import s3://elasticmapreduce/samples/cloudfront
emrfs sync 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
否 |
|
为实现一致视图而跟踪的 Amazon S3 存储桶的路径。存储桶以递归方式同步。 |
是 |
|
请求用于 delete 操作的可用读取吞吐量。如果未指定 |
否 |
|
请求用于 delete 操作的可用写入吞吐量。如果未指定 |
否 |
例 emrfs sync 命令示例
以下示例随一致视图的跟踪元数据导入一个 Amazon S3 存储桶中的所有对象。删除所有未知键。
$ emrfs sync s3://elasticmapreduce/samples/cloudfront Synching samples/cloudfront 0 added | 0 updated | 0 removed | 0 unchanged Synching samples/cloudfront/code/ 1 added | 0 updated | 0 removed | 0 unchanged Synching samples/cloudfront/ 2 added | 0 updated | 0 removed | 0 unchanged Synching samples/cloudfront/input/ 9 added | 0 updated | 0 removed | 0 unchanged Done synching s3://elasticmapreduce/samples/cloudfront 9 added | 0 updated | 1 removed | 0 unchanged creating 3 folder key(s) folders written: 3
emrfs read-sqs 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
是 |
|
|
是 |
emrfs delete-sqs 子命令
选项 | 描述 | 必填 |
---|---|---|
|
|
是 |
以步骤形式提交 EMRFS CLI 命令
以下示例说明如何在主节点上使用该emrfs
实用程序,方法是利用 Amazon CLI 或 API 和command-runner.jar
,将emrfs
命令作为一个步骤运行。该示例使用 适用于 Python (Boto3) 的 Amazon SDK 向集群添加一个步骤,该步骤将 Amazon S3 存储桶中的对象添加到默认 EMRFS 元数据表中。
import boto3 from botocore.exceptions import ClientError def add_emrfs_step(command, bucket_url, cluster_id, emr_client): """ Add an EMRFS command as a job flow step to an existing cluster. :param command: The EMRFS command to run. :param bucket_url: The URL of a bucket that contains tracking metadata. :param cluster_id: The ID of the cluster to update. :param emr_client: The Boto3 Amazon EMR client object. :return: The ID of the added job flow step. Status can be tracked by calling the emr_client.describe_step() function. """ job_flow_step = { "Name": "Example EMRFS Command Step", "ActionOnFailure": "CONTINUE", "HadoopJarStep": { "Jar": "command-runner.jar", "Args": ["/usr/bin/emrfs", command, bucket_url], }, } try: response = emr_client.add_job_flow_steps( JobFlowId=cluster_id, Steps=[job_flow_step] ) step_id = response["StepIds"][0] print(f"Added step {step_id} to cluster {cluster_id}.") except ClientError: print(f"Couldn't add a step to cluster {cluster_id}.") raise else: return step_id def usage_demo(): emr_client = boto3.client("emr") # Assumes the first waiting cluster has EMRFS enabled and has created metadata # with the default name of 'EmrFSMetadata'. cluster = emr_client.list_clusters(ClusterStates=["WAITING"])["Clusters"][0] add_emrfs_step( "sync", "s3://elasticmapreduce/samples/cloudfront", cluster["Id"], emr_client ) if __name__ == "__main__": usage_demo()
可以使用返回的 step_id
值检查日志以了解操作结果。