LoginSignup
0
0

More than 5 years have passed since last update.

[JAWS-UG CLI] Amazon Redshift 入門 (4) スナップショットの取得/削除

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. スナップショットの作成、削除

スナップショット名の指定

コマンド
SNAPSHOT_NAME=mysnapshot

パラメータの確認

コマンド
cat << ETX

   CLUSTER_NAME: ${CLUSTER_NAME}
   SNAPSHOT_NAME: ${SNAPSHOT_NAME}

ETX
結果

   CLUSTER_NAME: mycluster
   SNAPSHOT_NAME: mysnapshot

スナップショットの作成

コマンド
aws redshift create-cluster-snapshot --snapshot-identifier ${SNAPSHOT_NAME} \
  --cluster-identifier ${CLUSTER_NAME}
結果
{
    "Snapshot": {
        "EstimatedSecondsToCompletion": -1,
        "OwnerAccount": "************",
        "CurrentBackupRateInMegaBytesPerSecond": 0.0,
        "ActualIncrementalBackupSizeInMegaBytes": -1.0,
        "NumberOfNodes": 1,
        "Status": "creating",
        "VpcId": "vpc-********",
        "ClusterVersion": "1.0",
        "Tags": [],
        "MasterUsername": "awsuser",
        "TotalBackupSizeInMegaBytes": -1.0,
        "DBName": "mydb",
        "BackupProgressInMegaBytes": 0.0,
        "ClusterCreateTime": "2016-04-28T10:47:23.091Z",
        "EncryptedWithHSM": false,
        "ClusterIdentifier": "mycluster",
        "SnapshotCreateTime": "2016-04-28T13:21:08.756Z",
        "AvailabilityZone": "ap-northeast-1a",
        "NodeType": "dc1.large",
        "Encrypted": false,
        "ElapsedTimeInSeconds": 0,
        "SnapshotType": "manual",
        "Port": 5439,
        "SnapshotIdentifier": "mysnapshot"
    }
}

スナップショットの確認

(作成が完了するまで少々お待ちください。)

コマンド
aws redshift describe-cluster-snapshots --query Snapshots[?SnapshotType==\'manual\']
結果
[
    {
        "EstimatedSecondsToCompletion": 0,
        "OwnerAccount": "************",
        "CurrentBackupRateInMegaBytesPerSecond": 53.8349,
        "ActualIncrementalBackupSizeInMegaBytes": 332.0,
        "NumberOfNodes": 1,
        "Status": "available",
        "VpcId": "vpc-********",
        "ClusterVersion": "1.0",
        "Tags": [],
        "MasterUsername": "awsuser",
        "TotalBackupSizeInMegaBytes": 339.0,
        "DBName": "mydb",
        "BackupProgressInMegaBytes": 332.0,
        "ClusterCreateTime": "2016-04-28T10:47:23.091Z",
        "RestorableNodeTypes": [
            "dc1.large"
        ],
        "EncryptedWithHSM": false,
        "ClusterIdentifier": "mycluster",
        "SnapshotCreateTime": "2016-04-28T13:21:32.303Z",
        "AvailabilityZone": "ap-northeast-1a",
        "NodeType": "dc1.large",
        "Encrypted": false,
        "ElapsedTimeInSeconds": 6,
        "SnapshotType": "manual",
        "Port": 5439,
        "SnapshotIdentifier": "mysnapshot"
    }
]

スナップショットの削除

コマンド
aws redshift delete-cluster-snapshot --snapshot-identifier ${SNAPSHOT_NAME}
結果
{
    "Snapshot": {
        "EstimatedSecondsToCompletion": 0,
        "OwnerAccount": "************",
        "CurrentBackupRateInMegaBytesPerSecond": 53.8349,
        "ActualIncrementalBackupSizeInMegaBytes": 332.0,
        "NumberOfNodes": 1,
        "Status": "deleted",
        "VpcId": "vpc-********",
        "ClusterVersion": "1.0",
        "Tags": [],
        "MasterUsername": "awsuser",
        "TotalBackupSizeInMegaBytes": 339.0,
        "DBName": "mydb",
        "BackupProgressInMegaBytes": 332.0,
        "ClusterCreateTime": "2016-04-28T10:47:23.091Z",
        "EncryptedWithHSM": false,
        "ClusterIdentifier": "mycluster",
        "SnapshotCreateTime": "2016-04-28T13:21:32.303Z",
        "AvailabilityZone": "ap-northeast-1a",
        "NodeType": "dc1.large",
        "Encrypted": false,
        "ElapsedTimeInSeconds": 6,
        "SnapshotType": "manual",
        "Port": 5439,
        "SnapshotIdentifier": "mysnapshot"
    }
}

確認

コマンド
aws redshift describe-cluster-snapshots --query Snapshots[?SnapshotType==\'manual\']
結果
[]

以上

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