

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 启用 Amazon EMR WAL
<a name="emr-hbase-wal-enabling"></a>

使用 AWS Command Line Interface创建集群时，按照以下步骤启用写入 Amazon EMR WAL 的功能。

**注意**  
您无法为正在运行的集群启用 Amazon EMR WAL，也无法启动具有相同 S3 根目录的两个集群。有关更多信息，请参阅 [Amazon EMR WAL 注意事项和区域](emr-hbase-wal-considerations.md)。

1. 在创建启用了 Amazon EMR WAL 的集群之前，必须向计划用于集群的实例配置文件添加所需的权限。有关更多信息，请参阅 [Amazon EMR WAL 的所需权限](emr-hbase-wal-permissions.md)。

1. 从 AWS CLI创建集群 使用 `--configurations` 选项提供指定 `hbase.emr.wal.enabled` 属性的 JSON 配置对象，如下例所示。
   + 指定 Amazon S3 的存储模式和根目录位置。您指定的 Amazon S3 位置应与您的 EMR 集群位于同一区域，但一次只能有一个活动集群使用 S3 中的同一个 HBase 根目录。
   + 使用实例组配置创建集群。您不能将 Amazon EMR WAL 与实例集配置结合使用。有关使用实例组创建集群的更多信息，请参阅《Amazon EMR 管理指南》**中的[配置统一实例组](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-uniform-instance-group.html)。
   + 有关创建集群的控制台步骤以及使用集群的详细`create-cluster`示例 AWS CLI，请参阅使用[创建集群 HBase](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hbase-create.html)。

1. 要为新集群启用 WAL，请将 `hbase.emr.wal.enabled` 属性设置为 `true`。以下命令包含带有示例配置对象的 JSON 代码段。

   ```
   aws emr create-cluster --name "hbasewal" --release-label emr-6.x.y \
   --applications Name=HBase --use-default-roles --ec2-attributes KeyName=myKey \
   --instance-type m6i.xlarge --instance-count 1 --configurations hbase.json
   $cat hbase.json
   [
       {
           "Classification": "hbase-site",
           "Properties": {
               "hbase.rootdir": "s3://amzn-s3-demo-bucket/MyHBaseStore"
           }
       },
       {
           "Classification": "hbase",
           "Properties": {
               "hbase.emr.storageMode": "s3",
               "hbase.emr.wal.enabled": "true"
           }
       }
   ]
   ```

在新创建的集群上联机时 HBase ， HBase 会自动将 WAL 数据写入 Amazon EMR WAL，并使用 Amazon EMR WAL 进行恢复。

**Example 1：创建使用 Amazon EMR WAL 的 EMR 集群**  

```
[
    {
        "Classification": "hbase-site",
        "Properties": {
            "hbase.rootdir": "s3://amzn-s3-demo-bucket/MyHBaseStore"
        }
    },
    {
        "Classification": "hbase",
        "Properties": {
            "hbase.emr.storageMode": "s3",
            "hbase.emr.wal.enabled": "true"
        }
    }
]
```

**Example 2：使用自定义 WAL Workspace 创建 EMR 集群**  

```
[
    {
        "Classification": "hbase-site",
        "Properties": {
            "hbase.rootdir": "s3://amzn-s3-demo-bucket/MyHBaseStore",
            "emr.wal.workspace": "customWorkspaceName"
        }
    },
    {
        "Classification": "hbase",
        "Properties": {
            "hbase.emr.storageMode": "s3",
            "hbase.emr.wal.enabled": "true"
        }
    }
]
```