在AWS EMR中,您可以使用AWS SDK或AWS CLI来终止集群。以下是使用AWS SDK(Python)的示例代码:
import boto3
# 创建EMR客户端
emr = boto3.client('emr', region_name='your_region')
# 获取集群ID
cluster_id = 'your_cluster_id'
# 终止集群
response = emr.terminate_job_flows(JobFlowIds=[cluster_id])
# 打印终止集群的响应
print(response)
请确保将your_region
替换为您的AWS区域,将your_cluster_id
替换为您要终止的集群的ID。
您还可以使用AWS CLI执行相同的操作。以下是使用AWS CLI的示例命令:
aws emr terminate-clusters --cluster-ids your_cluster_id
请将your_cluster_id
替换为您要终止的集群的ID。
请注意,终止集群将会停止所有正在运行的作业和任务,并释放集群中的所有资源。