LoginSignup
0
0

More than 5 years have passed since last update.

[JAWS-UG CLI] Amazon Redshift 入門 (6) クラスターの削除

Last updated at Posted at 2016-05-23

このハンズオンについて

  • このハンズオンでは、Redshiftのクラスターとそのクラスタに対してクエリを発行するインスタンスの作成を実施します。
  • クエリの発行には、「psql」を利用します。本手順では、Amazon Linux上へのインストールと利用方法を説明します。

前提条件

バージョン確認

このハンズオンは以下のバージョンで動作確認を行いました。

コマンド
aws --version
結果
aws-cli/1.10.23 Python/2.7.10 Linux/4.4.5-15.26.amzn1.x86_64 botocore/1.4.14

必要な権限

作業にあたっては、以下の権限を有したIAMユーザもしくはIAMロールを利用してください。

  • EC2に対するフルコントロール権限
  • RedShiftに関するフルコントロール権限
  • IAMに関するフルコントロール権限
  • S3に関するフルコントロール権限
  • STSに関するフルコントロール権限

0. 準備

リージョンを指定

コマンド
export AWS_DEFAULT_REGION='ap-northeast-1'

資格情報を確認

コマンド
aws configure list
結果
Name                    Value             Type    Location
----                    -----             ----    --------
profile                <not set>             None    None
access_key     ****************RDPA         iam-role
secret_key     ****************9GA8         iam-role
region           ap-northeast-1              env    AWS_DEFAULT_REGION

1. クラスタの削除

確認

コマンド
aws redshift describe-clusters --cluster-identifier ${CLUSTER_NAME}
結果
{
    "Clusters": [
        {
            "PubliclyAccessible": true,
            "MasterUsername": "awsuser",
            "VpcSecurityGroups": [
                {
                    "Status": "active",
                    "VpcSecurityGroupId": "sg-********"
                }
            ],
            "ClusterPublicKey": "ssh-rsa ************************ Amazon-Redshift\n",
            "NumberOfNodes": 1,
            "PendingModifiedValues": {},
            "VpcId": "vpc-********",
            "ClusterVersion": "1.0",
            "Tags": [],
            "AutomatedSnapshotRetentionPeriod": 1,
            "ClusterParameterGroups": [
                {
                    "ParameterGroupName": "default.redshift-1.0",
                    "ParameterApplyStatus": "in-sync"
                }
            ],
            "DBName": "mydb",
            "PreferredMaintenanceWindow": "fri:17:30-fri:18:00",
            "Endpoint": {
                "Port": 5439,
                "Address": "mycluster.************.ap-northeast-1.redshift.amazonaws.com"
            },
            "AllowVersionUpgrade": true,
            "ClusterCreateTime": "2016-04-28T10:47:23.091Z",
            "ClusterSubnetGroupName": "redshift-subnet",
            "ClusterSecurityGroups": [],
            "ClusterIdentifier": "mycluster",
            "ClusterNodes": [
                {
                    "NodeRole": "SHARED",
                    "PrivateIPAddress": "10.0.0.164",
                    "PublicIPAddress": "**.**.**.**"
                }
            ],
            "AvailabilityZone": "ap-northeast-1a",
            "NodeType": "dc1.large",
            "Encrypted": false,
            "ClusterRevisionNumber": "1044",
            "ClusterStatus": "available"
        }
    ]
}

クラスターの削除

(10分くらいかかります)

コマンド
aws redshift delete-cluster --cluster-identifier ${CLUSTER_NAME} --skip-final-cluster-snapshot
結果
{
    "Cluster": {
        "PubliclyAccessible": true,
        "MasterUsername": "awsuser",
        "VpcSecurityGroups": [
            {
                "Status": "active",
                "VpcSecurityGroupId": "sg-********"
            }
        ],
        "NumberOfNodes": 1,
        "PendingModifiedValues": {},
        "VpcId": "vpc-********",
        "ClusterVersion": "1.0",
        "Tags": [],
        "AutomatedSnapshotRetentionPeriod": 1,
        "ClusterParameterGroups": [
            {
                "ParameterGroupName": "default.redshift-1.0",
                "ParameterApplyStatus": "in-sync"
            }
        ],
        "DBName": "mydb",
        "PreferredMaintenanceWindow": "fri:17:30-fri:18:00",
        "Endpoint": {
            "Port": 5439,
            "Address": "mycluster.************.ap-northeast-1.redshift.amazonaws.com"
        },
        "AllowVersionUpgrade": true,
        "ClusterCreateTime": "2016-04-28T10:47:23.091Z",
        "ClusterSubnetGroupName": "redshift-subnet",
        "ClusterSecurityGroups": [],
        "ClusterIdentifier": "mycluster",
        "AvailabilityZone": "ap-northeast-1a",
        "NodeType": "dc1.large",
        "Encrypted": false,
        "ClusterStatus": "deleting"
    }
}

削除されたことを確認

コマンド
aws redshift describe-clusters --cluster-identifier ${CLUSTER_NAME}
結果
A client error (ClusterNotFound) occurred when calling the DescribeClusters operation: Cluster mycluster not found.

2. Subnet Groupの削除

確認

コマンド
aws redshift describe-cluster-subnet-groups --cluster-subnet-group-name ${CLUSTER_SUBNET_GROUP_NAME}
結果
{
    "ClusterSubnetGroups": [
        {
            "Subnets": [
                {
                    "SubnetStatus": "Active",
                    "SubnetIdentifier": "subnet-********",
                    "SubnetAvailabilityZone": {
                        "Name": "ap-northeast-1a"
                    }
                }
            ],
            "VpcId": "vpc-********",
            "Description": "Subnet Group for Redshift",
            "Tags": [],
            "SubnetGroupStatus": "Complete",
            "ClusterSubnetGroupName": "redshift-subnet"
        }
    ]
}

クラスターサブネットグループの削除

コマンド
aws redshift delete-cluster-subnet-group --cluster-subnet-group-name ${CLUSTER_SUBNET_GROUP_NAME}
結果
(返値無し)

削除されたことを確認

コマンド
aws redshift describe-cluster-subnet-groups --cluster-subnet-group-name ${CLUSTER_SUBNET_GROUP_NAME}
結果
A client error (ClusterSubnetGroupNotFoundFault) occurred when calling the DescribeClusterSubnetGroups operation: Cluster Subnet group 'redshift-subnet' not found.

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0