本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
EMRFS CLI 命令參考
依預設,EMRFS CLI 會安裝在使用 Amazon EMR 發行版本 3.2.1 或更新版本建立之所有叢集主節點上。您可以使用 EMRFS CLI 來管理一致性檢視的中繼資料。
注意
僅支援使用 VT100 終端模擬以執行 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 中建立或存取中繼資料存放區的 AWS 存取金鑰。在預設情況下, |
否 |
|
與您用來將物件寫入 Amazon S3,以及在 DynamoDB 中建立或存取中繼資料存放區的存取金鑰相關聯的 AWS 私密金鑰。在預設情況下, |
否 |
|
使輸出最詳細。 |
否 |
|
顯示 |
否 |
emrfs 描述中繼資料子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
範例 emrfs 描述中繼資料範例
以下範例說明預設的中繼資料表格。
$ emrfs describe-metadata
EmrFSMetadata
read-capacity: 400
write-capacity: 100
status: ACTIVE
approximate-item-count (6 hour delay): 12
emrfs 設定中繼資料容量子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
|
中繼資料資料表的請求讀取輸送容量。如果未提供 |
否 |
|
中繼資料資料表的請求寫入輸送容量。如果未提供 |
否 |
範例 emrfs 設定中繼資料容量範例
以下範例會將讀取輸送容量設為 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 刪除中繼資料子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
範例 emrfs 刪除中繼資料範例
以下範例會刪除預設的中繼資料資料表。
$ emrfs delete-metadata
emrfs 建立中繼資料子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
|
中繼資料資料表的請求讀取輸送容量。如果未提供 |
否 |
|
中繼資料資料表的請求寫入輸送容量。如果未提供 |
否 |
範例 emrfs 建立中繼資料範例
以下範例請求建立名為「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 列出中繼資料存放區子命令
emrfs list-metadata-stores 子命令沒有 [options]。
範例 List-metadata-stores 範例
以下範例列出您的中繼資料資料表。
$ emrfs list-metadata-stores
EmrFSMetadata
emrfs 差異子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
|
Amazon S3 儲存貯體的路徑會與中繼資料資料表相比較。以遞迴的方式同步儲存貯體。 |
是 |
範例 emrfs 差異範例
下列範例會將預設中繼資料資料表與 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 刪除子命令
選項 |
描述 |
必要 |
---|---|---|
|
|
否 |
|
您追蹤以進行一致性檢視之 Amazon S3 儲存貯體路徑。以遞迴的方式同步儲存貯體。 |
是 |
-t |
過期時間 (使用時間單位引數來解釋)。會針對指定儲存貯體將所有早於 |
|
|
用來解譯時間引數 (奈秒、微秒、毫秒、秒、分鐘、小時或天) 的測量。如果未指定任何引數,預設值會是 |
|
|
用於 delete 操作之可用讀取輸送量的請求量。如果未提供 |
否 |
|
用於 delete 操作之可用寫入輸送量的請求量。如果未提供 |
否 |
範例 emrfs 刪除範例
下列範例會將 Amazon S3 儲存貯體中的所有物件從一致性檢視的追蹤中繼資料中移除。
$ emrfs delete s3://elasticmapreduce/samples/cloudfront
entries deleted: 11
emrfs 匯入子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
|
您追蹤以進行一致性檢視之 Amazon S3 儲存貯體路徑。以遞迴的方式同步儲存貯體。 |
是 |
|
用於 delete 操作之可用讀取輸送量的請求量。如果未提供 |
否 |
|
用於 delete 操作之可用寫入輸送量的請求量。如果未提供 |
否 |
範例 emrfs 匯入範例
下列範例會使用一致性檢視的追蹤中繼資料來匯入 Amazon S3 儲存貯體中的所有物件。所有不明的金鑰皆遭到忽略。
$ emrfs import s3://elasticmapreduce/samples/cloudfront
emrfs 同步子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
否 |
|
您追蹤以進行一致性檢視之 Amazon S3 儲存貯體路徑。以遞迴的方式同步儲存貯體。 |
是 |
|
用於 delete 操作之可用讀取輸送量的請求量。如果未提供 |
否 |
|
用於 delete 操作之可用寫入輸送量的請求量。如果未提供 |
否 |
範例 emrfs 同步子命令範例
下列範例會使用一致性檢視的追蹤中繼資料來匯入 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 讀取 sqs 子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
是 |
|
|
是 |
emrfs 刪除 sqs 子命令
選項 | 描述 | 必要 |
---|---|---|
|
|
是 |
提交 EMRFS CLI 命令作為步驟
下列範例示範如何透過利用 AWS CLI 或 API 和 在主節點上使用 emrfs
公用程式command-runner.jar
,以執行 emrfs
命令做為步驟。此範例使用 AWS SDK for Python (Boto3) 將步驟新增至叢集,將 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
值來檢查操作的結果日誌。