Amazon Redshift Management Manual
Amazon Redshift Management Manual

Amazon Redshift Management Manual

Api version 2012-12-01 data warehouse service in the cloud
Table of Contents

Advertisement

Quick Links

Amazon Redshift
Management Guide
API Version 2012-12-01

Advertisement

Table of Contents
loading

Summary of Contents for Amazon Redshift

  • Page 1 Amazon Redshift Management Guide API Version 2012-12-01...
  • Page 2 Amazon Redshift Management Guide Amazon Web Services...
  • Page 3 Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon.
  • Page 4: Table Of Contents

    Purchasing a Reserved Node Offering with the Console ..............83 Purchasing a Reserved Node Offering Using Java ................86 Purchase a Reserved Node Offering Using Amazon Redshift CLI and API ......... 89 Controlling Access to Amazon Redshift Resources ................90 Connecting to a Cluster ........................
  • Page 5: What Is Amazon Redshift

    Your first step in creating a data warehouse is to launch a set of compute nodes, called an Amazon Redshift cluster. The number and type of compute nodes that you need depends on the size of your data, the number of queries you will execute, and the query execution performance you need. Each cluster that you provision is a fully managed Amazon Redshift data warehouse.You can use the Amazon Redshift...
  • Page 6: Clusters

    IAM controls only access to the Amazon Redshift API; it does not control access to the cluster via JDBC and ODBC. For more information, see Controlling Access to Amazon Redshift Resources (p.
  • Page 7 Amazon Redshift Management Guide Are You a First-Time Amazon Redshift User? • Amazon Redshift Database Developer Guide – If you are a database developer, the Amazon Redshift Database Developer Guide explains how to design, build, query, and maintain the databases that make up your data warehouse.
  • Page 8 Managing Clusters in Virtual Private Cloud (VPC) (p. 23) Overview An Amazon Redshift data warehouse is a collection of computing resources called nodes. This collection of nodes is called a cluster. When you provision a cluster, you specify the type and the number of nodes that will make up the cluster.
  • Page 9 Encryption also applies to backups. When restoring from an encrypted snapshot, the new cluster will be encrypted as well. If you are using the Amazon Redshift console to provision a cluster, it provides values for these options for you to choose from. If you are provisioning a cluster programmatically, you can use the Amazon Redshift API to find available options such as available node types Availability Zones (AZ) in which the node types are available.
  • Page 10 When you associate a new parameter group, you must reboot the cluster for the change to take effect. You can immediately reboot the cluster by using the Amazon API or the Amazon Redshift console. If Amazon Redshift reboots the cluster during maintenance operations, the new parameter group will take effect.
  • Page 11: Managing Clusters Using The Console

    Security Groups for Your VPC. To create a cluster in a VPC, you must first create an Amazon Redshift cluster subnet group by providing subnet information of your VPC, and then provide the subnet group when launching the cluster. For more information, see Amazon Redshift Cluster Subnet Groups (p.
  • Page 12: Creating A Cluster

    Overview (p. 4) of this section. To create a cluster Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. Do one of the following: If no clusters are configured for your account, click Launch Cluster.
  • Page 13 • Cannot be a reserved word. A list of reserved words can be found in Reserved Words the Amazon Redshift Developer Guide. In the Database Port box, type a database port through which you will connect to the database instance.
  • Page 14 Amazon Redshift Management Guide Creating a Cluster On the NODE CONFIGURATION page, do the following. When all the settings are as you want them, click Continue. In the Node Type box, click a node type. The CPU, Memory, Storage, and I/O Performance information will display the corresponding information for the node that you select.
  • Page 15 Amazon Redshift Management Guide Creating a Cluster On the ADDITIONAL CONFIGURATION page, do the following. When all the settings are as you want them, click Continue. (Optional) In the Cluster Parameter Group box, click a cluster parameter group to be associated with the cluster.
  • Page 16 Amazon Redshift Management Guide Creating a Cluster In the following example, a VPC, a VPC security group, and cluster subnet group are specified. The cluster is marked as not publicly accessible, and no preference is selected for the availability zone.
  • Page 17 Redshift Snapshots (p. 52). To modify a cluster Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Clusters. Under Performance Status, click the magnifying glass icon beside the cluster that you want to modify.
  • Page 18 Amazon Redshift Management Guide Modifying a Cluster In the cluster summary page, click Modify. In the Modify Cluster dialog box, make the changes to the cluster, and then click Modify. In the following example, a cluster not provisioned in a VCP is modified so that two security groups are associated with the cluster.
  • Page 19 Amazon Redshift Snapshots (p. 52). To delete a cluster Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Clusters. Under Performance Status, click the magnifying glass icon beside the cluster that you want to delete.
  • Page 20 When you reboot a cluster, the cluster status is set to rebooting and a cluster event is created when the reboot is completed. Any pending cluster modifications are applied at this reboot. To reboot a cluster Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Clusters.
  • Page 21 After you initiate the resize, you should wait until the resize is complete to resume working with the cluster. To resize a cluster Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Clusters.
  • Page 22 Getting Information About Cluster Configuration To get cluster configuration details Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Clusters.
  • Page 23 The cluster Status tab provides a high level overview of the status of a cluster, a summary of events related to the cluster, and a list of Amazon CloudWatch alarms associated with the cluster. To get an overview of cluster status Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift.
  • Page 24 You can take a snapshot of your cluster from the Configuration tab of your cluster as shown below. You can also take a snapshot of your cluster from the snapshots part of the Amazon Redshift console (see Managing Snapshots Using the Console (p.
  • Page 25: Managing Clusters Using Aws Sdk For Java

    In the Snapshot Identifier box, type a name for the snapshot. Click Create. To view details about the snapshot taken and all other snapshots for your AWS account, go to the snapshots part of the Amazon Redshift console (see Managing Snapshots Using the Console (p. 54)).
  • Page 26 Amazon Redshift Management Guide Managing Clusters Using AWS SDK for Java public static void main(String[] args) throws IOException { AWSCredentials credentials = new PropertiesCredentials( CreateAndModifyCluster.class .getResourceAsStream("AwsCredentials.properties")); client = new AmazonRedshiftClient(credentials); try { createCluster(); waitForClusterReady(); describeClusters(); modifyCluster(); describeClusters(); } catch (Exception e) { System.err.println("Operation failed: "...
  • Page 27: Manage Clusters Using Amazon Redshift Cli And Api

    String status = (result.getClusters()).get(0).getClusterStatus(); if (status.equalsIgnoreCase("available")) { clusterReady = true; else { System.out.print("."); Thread.sleep(sleepTime*1000); Manage Clusters Using Amazon Redshift CLI and API You can use the following Amazon Redshift CLI operations to manage clusters. • create-cluster • delete-cluster • describe-clusters •...
  • Page 28: Creating A Cluster In A Vpc

    • Provide VPC information When you request Amazon Redshift to create a cluster in your VPC, you must provide your VPC information, such as the VPC ID, and a list of subnets in your VPC by first creating a cluster subnet group.
  • Page 29: Cluster Subnet Groups

    Managing Cluster Subnet Groups Using AWS SDK for Java (p. 29) • Manage Cluster Subnet Groups Using Amazon Redshift CLI and API (p. 31) Overview You create a cluster subnet group if you are provisioning your cluster your virtual private cloud (VPC).
  • Page 30: Managing Cluster Subnet Groups Using The Console

    After creating a subnet group, you can remove subnets you previously added or add more subnets. Amazon Redshift provides APIs for you to create, modify or delete a cluster subnet group. You can also perform these operations in the console.
  • Page 31 The new group will be displayed in the list of cluster subnet groups. Modifying a Cluster Subnet Group To modify a cluster subnet group Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Subnet Groups.
  • Page 32 You cannot delete a cluster subnet group that is used by a cluster. To delete a cluster subnet group Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Subnet Groups.
  • Page 33: Managing Cluster Subnet Groups Using Aws Sdk For Java

    Amazon Redshift Management Guide Cluster Subnet Groups In the Delete Cluster Subnet Group dialog box, click Delete. Managing Cluster Subnet Groups Using AWS SDK for Java The following Java code example demonstrates common cluster subnet operations including: • Creating a cluster subnet group.
  • Page 34 Amazon Redshift Management Guide Cluster Subnet Groups .getResourceAsStream("AwsCredentials.properties")); client = new AmazonRedshiftClient(credentials); try { createClusterSubnetGroup(); describeClusterSubnetGroups(); modifyClusterSubnetGroup(); } catch (Exception e) { System.err.println("Operation failed: " + e.getMessage()); private static void createClusterSubnetGroup() { CreateClusterSubnetGroupRequest request = new CreateClusterSubnet GroupRequest() .withClusterSubnetGroupName(clusterSubnetGroupName) .withDescription("my cluster subnet group") .withSubnetIds(subnetId1);...
  • Page 35: Manage Cluster Subnet Groups Using Amazon Redshift Cli And Api

    System.out.format(" Subnet: %s, %s, %s\n", subnet.getSubnetIdenti fier(), subnet.getSubnetAvailabilityZone().getName(), subnet.getSub netStatus()); Manage Cluster Subnet Groups Using Amazon Redshift CLI and API You can use the following Amazon Redshift CLI operations to manage cluster subnet groups. • create-cluster-subnet-group • delete-cluster-subnet-group • describe-cluster-subnet-groups •...
  • Page 36: Security Groups

    You can create security groups independent of provisioning any cluster. You can associate a security group with an Amazon Redshift cluster either at the time you provision the cluster or later. Also, you can associate a security group with multiple clusters.
  • Page 37: Managing Security Groups Using The Console

    You can create, modify, and delete a security groups by using the Amazon Redshift console. You can also manage the default security group in the Amazon Redshift console. All of the tasks start from the security group list. You must select a security group to manage it.
  • Page 38 Amazon Redshift Management Guide Creating a Security Group Creating a Security Group To create a security group Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Security Groups. Click Create Cluster Security Group.
  • Page 39 Amazon Redshift Management Guide Managing Ingress Rules for a Security Group Do one of the following: • Take one of the following rule actions. To... Do this... Add an ingress rule based on In the Connection Type bock, click CIDR/IP.
  • Page 40 If a security group is associated with one or more clusters, you cannot delete it. To delete a security group Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Security Groups.
  • Page 41: Managing Security Groups Using Aws Sdk For Java

    One ingress rule is added by specifying a CIDR/IP range; the other is added by specifying an owner ID and Amazon EC2 security group combination. For step-by-step instructions to run the following example, see Running Java Examples for Amazon Redshift Using Eclipse (p.
  • Page 42 Amazon Redshift Management Guide Managing Security Groups Using AWS SDK for Java .getResourceAsStream("AwsCredentials.properties")); client = new AmazonRedshiftClient(credentials); try { createClusterSecurityGroup(); describeClusterSecurityGroups(); addIngressRules(); associateSecurityGroupWithCluster(); } catch (Exception e) { System.err.println("Operation failed: " + e.getMessage()); private static void createClusterSecurityGroup() { CreateClusterSecurityGroupRequest request = new CreateClusterSecurity GroupRequest() .withDescription("my cluster security group")
  • Page 43 Amazon Redshift Management Guide Managing Security Groups Using AWS SDK for Java // Add new security group to the list. secGroupNames.add(clusterSecurityGroupName); // Apply the change to the cluster. ModifyClusterRequest request2 = new ModifyClusterRequest() .withClusterIdentifier(clusterIdentifier) .withClusterSecurityGroups(secGroupNames); Cluster result2 = client.modifyCluster(request2); System.out.format("\nAssociated security group '%s' to cluster '%s'.", clusterSecurityGroupName, clusterIdentifier);...
  • Page 44: Manage Security Group Using Amazon Redshift Cli And Api

    Amazon Redshift Management Guide Manage Security Group Using Amazon Redshift CLI and Manage Security Group Using Amazon Redshift CLI and API You can use the following Amazon Redshift CLI operations to manage security groups. • authorize-cluster-security-group-ingress • create-cluster-security-group • delete-cluster-security-group •...
  • Page 45: Parameter Groups

    When you provision an Amazon Redshift cluster, you associate a parameter group with it. The parameters in the group apply to all the databases you create on the cluster. The Amazon Redshift engine provides a default parameter group, which has preset values for the parameters. You cannot change the values in the default parameter group.
  • Page 46 If the cluster fails and is restarted by Amazon Redshift, your changes will be applied at that time.
  • Page 47: Managing Parameter Groups Using The Console

    • Associating a Parameter Group with a Cluster (p. 47) You can create, modify, and delete parameter groups by using the Amazon Redshift console. All of the tasks start from the parameter group list. In the parameter group list below, there are two parameter groups, the default parameter group and a custom parameter group called parametergroup1 .
  • Page 48 You can create a parameter group if you want to set parameter values that are different from the default parameter group for your cluster version. To create a parameter group Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Parameter Groups.
  • Page 49 Amazon Redshift Management Guide Modifying a Parameter Group Note You cannot modify the default parameter group. Click the Edit tab. To modify a parameter value, type a new value in the corresponding box in the Value column. When the settings are as you want them, click Save Changes.
  • Page 50 If a parameter group is associated with one or more clusters, you cannot delete it. To delete a parameter group Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Parameter Groups.
  • Page 51: Managing Parameter Groups Using Aws Sdk For Java

    Amazon Redshift Management Guide Associating a Parameter Group with a Cluster In the Delete Cluster Parameter Groups dialog box, click Delete. Associating a Parameter Group with a Cluster Each cluster you provision has one parameter group associated with it. You can associate a parameter group with a cluster when you create the cluster, or you can associate a parameter group later by modifying the cluster.
  • Page 52 CreateAndModifyClusterParameterGroup { public static AmazonRedshiftClient client; public static String clusterParameterGroupName = "parametergroup1"; public static String clusterIdentifier = "***provide cluster identifier***"; public static String parameterGroupFamily = "redshift-1.0"; public static void main(String[] args) throws IOException { API Version 2012-12-01...
  • Page 53 Amazon Redshift Management Guide Managing Parameter Groups Using AWS SDK for Java AWSCredentials credentials = new PropertiesCredentials( CreateAndModifyClusterParameterGroup.class .getResourceAsStream("AwsCredentials.properties")); client = new AmazonRedshiftClient(credentials); try { createClusterParameterGroup(); modifyClusterParameterGroup(); associateParameterGroupWithCluster(); describeClusterParameterGroups(); } catch (Exception e) { System.err.println("Operation failed: " + e.getMessage()); private static void createClusterParameterGroup() {...
  • Page 54 Amazon Redshift Management Guide Managing Parameter Groups Using AWS SDK for Java Cluster result = client.modifyCluster(request); System.out.format("Parameter Group %s is used for Cluster %s\n", clusterParameterGroupName, result.getClusterParamet erGroups().get(0).getParameterGroupName()); private static void printResultClusterParameterGroups(DescribeClusterPara meterGroupsResult result) if (result == null) System.out.println("\nDescribe cluster parameter groups result is null.");...
  • Page 55: Manage Parameter Groups Using Amazon Redshift Cli And Api

    Manage Parameter Groups Using Amazon Redshift CLI and API + ", Description: " + parameter.getDescription()); Manage Parameter Groups Using Amazon Redshift CLI and API You can use the following Amazon Redshift CLI operations to manage parameter groups. • create-cluster-parameter-group • delete-cluster-parameter-group •...
  • Page 56: Snapshots

    You can modify the retention period by using the Amazon Redshift console or programmatically by using the Amazon Redshift API or the AWS SDKs. If you set the retention period to zero, automated snapshots are disabled, in which case Amazon Redshift stops taking snapshots and deletes any existing automated snapshots for the cluster.
  • Page 57: Restoring A Cluster From A Snapshot

    Amazon Redshift Management Guide Restoring a Cluster from a Snapshot Redshift ensures that it retains all of the incremental backup data required to restore a cluster using any manual snapshot, or any automatic snapshot that has not yet reached the snapshot retention period...
  • Page 58: Managing Snapshots Using The Console

    Amazon Redshift Snapshots (p. 52). All snapshot tasks in the Amazon Redshift console start from the snapshot list. You can filter the list by using the snapshot type, a time range, and associated cluster. When you select an existing snapshot, the snapshot details are shown in-line in the list as shown in the example below.
  • Page 59 Deleting a Manual Snapshot To delete a manual snapshot Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Snapshots. If you need to filter the list in order to find the snapshot that you want to delete, do any or all of the following: •...
  • Page 60 If you want to keep an automated snapshot, you can copy it to a manual snapshot. Because Amazon Redshift never automatically deletes manual snapshots, you can keep this copy as long as you want.
  • Page 61 Click Copy. Restoring a Cluster from a Snapshot When you restore a cluster from a snapshot, Amazon Redshift creates a new cluster with all the snapshot data on the new cluster. To restore a cluster from a snapshot Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift.
  • Page 62 Amazon Redshift Management Guide Sharing a Cluster Snapshot In the Restore Cluster from Snapshot dialog box, do the following: In the Cluster Identifier box, type a cluster identifier for the restored cluster. Cluster identifiers must meet the following conditions: • Must contain from 1 to 255 alphanumeric characters or hyphens.
  • Page 63: Managing Snapshots Using Aws Sdk For Java

    Amazon Redshift Management Guide Managing Snapshots Using AWS SDK for Java To share a cluster snapshot Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Snapshots. If you need to filter the list in order to find the snapshot that you want to delete, do any or all of the following: •...
  • Page 64 Amazon Redshift Management Guide Managing Snapshots Using AWS SDK for Java import com.amazonaws.services.redshift.model.DescribeClusterSnapshotsResult; import com.amazonaws.services.redshift.model.Snapshot; public class CreateAndDescribeSnapshot { public static AmazonRedshiftClient client; public static String clusterIdentifier = "***provide cluster identifier***"; public static long sleepTime = 10; public static void main(String[] args) throws IOException { AWSCredentials credentials = new PropertiesCredentials( CreateAndDescribeSnapshot.class...
  • Page 65 Amazon Redshift Management Guide Managing Snapshots Using AWS SDK for Java DescribeClusterSnapshotsRequest request = new DescribeClusterSnapshots Request() .withEndTime(creationDate) .withClusterIdentifier(clusterIdentifier) .withSnapshotType("manual"); DescribeClusterSnapshotsResult result = client.describeClusterSnap shots(request); for (Snapshot s : result.getSnapshots()) { DeleteClusterSnapshotRequest deleteRequest = new DeleteClusterSnap shotRequest() .withSnapshotIdentifier(s.getSnapshotIdentifier()); Snapshot deleteResult = client.deleteClusterSnapshot(deleteRequest);...
  • Page 66: Managing Snapshots Using Amazon Redshift Cli And Api

    Amazon Redshift Management Guide Managing Snapshots Using Amazon Redshift CLI and Managing Snapshots Using Amazon Redshift CLI and API You can use the following Amazon Redshift CLI operations to manage snapshots. • authorize-snapshot-access • copy-cluster-snapshot • create-cluster-snapshot • delete-cluster-snapshot •...
  • Page 67: Events

    Viewing Events Using the Console You can view events in the Amazon Redshift console by click on Events on the left navigation. In the list of events you can filter the results using the Source Type filter or a custom Filter that filters for text in all fields of the list.
  • Page 68 Sometimes you want to find a specific category of events or events for a specific cluster. In these cases, you can filter the events displayed. To filter events Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Events.
  • Page 69: Viewing Events Using Aws Sdk For Java

    Amazon Redshift Management Guide Viewing Events Using AWS SDK for Java Viewing Events Using AWS SDK for Java The following example lists the events for a specified cluster and specified event source type. The example shows how to use pagination.
  • Page 70: View Events Using Amazon Redshift Cli And Api

    System.out.format("SourceID: %s\n", event.getSourceIdentifier()); System.out.format("Type: %s\n", event.getSourceType()); System.out.format("Message: %s\n", event.getMessage()); System.out.format("Date: %s\n", event.getDate()); View Events Using Amazon Redshift CLI and You an use the following Amazon Redshift CLI operations to manage events. • describe-events Amazon Redshift provides following API to view events. •...
  • Page 71: Monitoring Cluster Performance

    Amazon Redshift provides performance metrics and data so that you can track the health and performance of your clusters and databases. In this section, we discuss the types of data you can work with in Amazon Redshift and specifically, in the Amazon Redshift console. The performance data that you can use in Amazon Redshift console falls into two categories: •...
  • Page 72: Summary Of Performance Data

    Amazon Redshift has the following two dimensions: •...
  • Page 73 Note In Amazon CloudWatch this metric is reported as 1 or 0 whereas in the Amazon Redshift console, this metric is displayed with the words HEALTHY or UNHEALTHY for convenience. When this metric is displayed in the Amazon Redshift console, sampling averages are ignored and only HEALTHY or UNHEALTHY are displayed.
  • Page 74 For more information about measuring and monitoring your database performance yourself, see Managing Performance in the Amazon Redshift Developer Guide The following table describes different aspects of query and load data you can access in the Amazon Redshift console. API Version 2012-12-01...
  • Page 75: Working With Performance Data

    Amazon Redshift console. When you view performance data in the Amazon Redshift console, you view it by cluster. The performance data graphs for a cluster are designed to give you access to data to answer your most common performance questions.
  • Page 76: Viewing Cluster Performance Data

    WriteOps , are only applicable for compute nodes. Switching the node display mode will reset all filters. To view cluster performance data Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the left navigation, click Clusters.
  • Page 77 Amazon Redshift Management Guide Viewing Cluster Performance Data By default, the performance view displays cluster performance over the past hour. If you need to fine tune the view you have filters that you can use as described in the following table.
  • Page 78: Viewing Cluster Metrics During Query Execution

    To view cluster metrics during query execution Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the left navigation, click Clusters.
  • Page 79 Amazon Redshift Management Guide Viewing Cluster Metrics During Query Execution Select the Queries tab. In the query list find the query you want to work with, and click the query ID in the Query column. In this example, the queries are sorted by Run time to find the query with the maximum run time.
  • Page 80 Amazon Redshift Management Guide Viewing Cluster Metrics During Query Execution Cluster Metrics During Query Execution - Examples In the following example, the Query Properties, Details, SQL, and Loaded Files information for the query are displayed. In the following example, an Explain Plan is shown.
  • Page 81: Viewing Cluster Metrics During Load Operations

    When you view cluster performance during load operations you can identify queries that are consuming resources and take action to mitigate their effect. To view cluster metrics during load operations Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the left navigation, click Clusters.
  • Page 82: Creating An Alarm

    Likewise, setting an alarm for low CPUUtilization on a cluster node, will help indicate when the node is underutilized. This section explains how to create an alarm using the Amazon Redshift console. You can create an alarm using the Amazon CloudWatch console or any other way you typically work with metrics such as with the Amazon CloudWatch Command Line Interface (CLI) or one of the Amazon Software Development Kits (SDKs).
  • Page 83 Create a Topic in the Amazon Simple Notification Service Getting Started Guide. If you don't have any topics in Amazon SNS, you can create a topic in the Create Alarm dialog by clicking the create topic link. The details of your alarm will vary with your circumstance. In the following example, the average...
  • Page 84: Working With Performance Metrics In The Amazon Cloudwatch Console

    • Query and load performance data is only available in the Amazon Redshift console. • Some Metrics in the Amazon CloudWatch have different units than those used in the Amazon Redshift console. For example, WriteThroughput , is displayed in GB/s (as compared to Bytes/s in Amazon CloudWatch) which is a more relevant unit for the typical storage space of a node.
  • Page 85 Working with gateway and volume metrics is similar to working with other service metrics. Many of the common tasks are outlined in the Amazon CloudWatch documentation and are listed below for your convenience: •...
  • Page 86: Purchasing Reserved Nodes

    When you create an Amazon Redshift cluster, you specify information such the AWS region where you want Amazon Redshift to create the cluster, the number of nodes you want in the cluster, and the node type. Amazon Redshift provisions the requested compute nodes as soon as you request them, and your AWS account is billed the hourly rate for the provisioned compute nodes.
  • Page 87: Purchasing A Reserved Node Offering With The Console

    From the Amazon Redshift console, you select these values. You can also obtain a list of available offerings by using the Amazon Redshift API. Each offering has a unique ID that you can use to identify the one that you intend to purchase.
  • Page 88 Listing Reserved Node Offerings Listing Reserved Node Offerings To list reserved node offerings Sign into the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift. In the navigation pane, click Reserved Nodes. (Optional) To filter the display of offers, use the Filter boxes. Do one or both of the following: •...
  • Page 89 Amazon Redshift Management Guide Purchasing Reserved Node Offerings In the Purchase Reserved Nodes wizard, specify Node Type, Term, Offering Type, and Number of Nodes. When the settings are as you want them, click Continue. Review the offering details, and then click Purchase.
  • Page 90: Purchasing A Reserved Node Offering Using Java

    Amazon Redshift Management Guide Purchasing a Reserved Node Offering Using Java Purchasing a Reserved Node Offering Using AWS SDK for Java The following example demonstrates how to use the AWS SDK for Java to do the following: • List existing reserved nodes.
  • Page 91 Amazon Redshift Management Guide Purchasing a Reserved Node Offering Using Java public static String nodeTypeToPurchase = "dw.hs1.xlarge"; public static Double fixedPriceLimit = 10000.00; public static ArrayList<ReservedNodeOffering> matchingNodes = new ArrayL ist<ReservedNodeOffering>(); public static void main(String[] args) throws IOException { AWSCredentials credentials = new PropertiesCredentials( ListAndPurchaseReservedNodeOffering.class...
  • Page 92 Amazon Redshift Management Guide Purchasing a Reserved Node Offering Using Java private static void purchaseReservedNodeOffer() throws IOException { if (matchingNodes.size() == 0) { return; } else { System.out.println("\nPurchasing nodes."); for (ReservedNodeOffering offering : matchingNodes) { printOfferingDetails(offering); System.out.println("WARNING: purchasing this offering will incur costs.");...
  • Page 93: Purchase A Reserved Node Offering Using Amazon Redshift Cli And Api

    Redshift CLI and API System.out.format("Offering Type: %s\n", node.getOfferingType()); System.out.format("Duration: %s\n", node.getDuration()); Purchase a Reserved Node Offering Using Amazon Redshift CLI and API You can use the following Amazon Redshift CLI operations to purchase reserved node offerings. • purchase-reserved-node-offering • describe-reserved-node-offerings •...
  • Page 94: Controlling Access To Amazon Redshift Resources

    By default, IAM users have no permissions; you must grant permissions to a user so that the user can perform Amazon Redshift actions. To define permissions, you create a policy, which is a JSON document in which you specify the actions and resources that you are granting access to.You then attach the policy to an IAM user to grant the specified access to that user, or to an IAM group to give all the users in that group the permissions that are specified in the policy.
  • Page 95 Element Descriptions section of the AWS Identity and Access Management Using IAM guide describes elements you can use in a policy. For policies that you create for Amazon Redshift, note the following about specific policy elements: • Resource – Amazon Redshift does not differentiate among resources for purposes of IAM permissions.
  • Page 96 RevokeClusterSecurityGroupIngress The following section provides example IAM policies that illustrate how to grant a user permission to perform specific Amazon Redshift actions. You can attach these policies to a user or group to whom you want to grant access permissions.
  • Page 97 The value redshift:* in the Action element indicates all the actions in the Amazon Redshift API. This allows the user access all the Amazon Redshift actions. However, if the user is going to access Amazon Redshift using the console, you might need to grant additional access permissions as shown in the following example 2 in which you grant access to Cloudwatch metrics the console provides.
  • Page 98 Amazon Redshift policy templates that you can use to allow the necessary access: • Amazon Redshift Read Only Access – Provides read only access to Amazon Redshift via the AWS Management Console. • Amazon Redshift Full Access –Provides full access to Amazon Redshift via the AWS Management Console.
  • Page 99: Connecting To A Cluster

    Connect from Outside of Amazon EC2 - Firewall Timeout Issue (p. 112) After you create an Amazon Redshift cluster, you can use any SQL client tool to connect to the cluster with PostgreSQL JDBC or ODBC drivers. If you use an Amazon EC2 instance as your client computer, you will need to install SQL Workbench and the required drivers on the instance.
  • Page 100: Setting Up The Sql Workbench Client

    Setting Up the SQL Workbench Client After you create an Amazon Redshift cluster, you can use SQL client tools to connect to the cluster using standard PostgreSQL JDBC or ODBC drivers. If you have a business intelligence application or any other application that can connect to your clusters using standard PostgreSQL JDBC or ODBC driver, then you can skip this section.
  • Page 101 SQL Workbench/J automatically completes the Classname box. Leave the Sample URL box blank, and then click OK. In the Amazon Redshift console, locate the connection string that corresponds to the driver you've selected. In this example, we're using the JDBC driver. Copy the JDBC URL. In the Select Connection dialog box, in the URL box, paste the JDBC URL.
  • Page 102 Autocommit check box. When all the settings are as you want them, click OK to save the profile. If you loaded the sample tables and data from the Amazon Redshift Getting Started Guide, you can test your connection by typing the following query into the Statement window: select * from users order by userid limit 100;...
  • Page 103 .MSI package. In the Amazon Redshift console, click the name of your cluster, and write down or copy the ODBC URL from the Configuration pane. You will use portions of the URL string in step e.
  • Page 104 Amazon Redshift Management Guide Setting Up the SQL Workbench Client In the PostgreSQL ODBC Unicode Driver Setup dialog box, do the following. When all the settings are as you want them, click Save. • In the Data Source box, type a name, or accept the automatically generated name. Make a note of this name;...
  • Page 105 Amazon Redshift Management Guide Setting Up the SQL Workbench Client • In the Password box, type the password that you created for the master user. • In the Port box, type the port number from the ODBC URL you copied in step b.
  • Page 106 Autocommit check box. When all the settings are as you want them, click OK to save the profile. If you loaded the sample tables and data from the Amazon Redshift Getting Started Guide, you can test your connection by typing the following query into the Statement window: select * from users order by userid limit 100;...
  • Page 107: Connect To Your Cluster By Using The Psql Tool

    Connect to Your Cluster by Using the psql Tool After you create an Amazon Redshift cluster, you can use psql, a terminal-based front end from PostgreSQL, to query the data in your cluster. You can type the queries interactively or read them from a file.
  • Page 108: Connect By Using A Certificate

    By default, psql operates with sslmode=prefer .To specify that psql opens an encrypted connection and uses an Amazon Redshift certificate to verify the service, download an Amazon Redshift certificate to your computer, specify sslmode=verify-ca , and specify sslrootcert with the location of the certificate.
  • Page 109: Connect To Your Cluster Using Ssl

    Using a server certificate provides an extra layer of security by validating that the cluster is an Amazon Redshift cluster. It does so by checking the server certificate that is automatically installed on all clusters that you provision. For more information about using server certificates with JDBC, go to http://jdbc.postgresql.org/documentation/81/ssl-client.html.
  • Page 110 Amazon Redshift Management Guide Connect Using the Server Certificate in Java To connect using a server certificate Use the keytool program to add the certificate to a keystore. Do one of the following: At a command prompt, use the following command to add the certificate to your default keystore: ${JAVA_HOME}/bin/keytool -import -alias <alias>...
  • Page 111: Connect To Your Cluster Programmatically

    If you do not use the server certificate, you can still connect to your Amazon Redshift cluster; however, your client will not be able to validate that it is connecting to an Amazon Redshift cluster. If you don't use the certificate, you can still connect by using SSL.
  • Page 112 Connecting to a Cluster by Using Java Using SSL (p. ?) to put the Amazon Redshift server certificate into a keystore. You can refer to the keystore by specifying a property when you run your code as follows: -Djavax.net.ssl.trustStore=<path to keystore>...
  • Page 113 Amazon Redshift Management Guide Connecting to a Cluster by Using Java Example : Connect to a Cluster by Using Java The following example connects to a cluster and runs a sample query that returns system tables. It is not necessary to have data in your database to use this example.
  • Page 114 If you plan to use server authentication, follow the instructions in Connect to Your Cluster Using SSL (p. ?) to download the Amazon Redshift server certificate, and then put the certificate in the correct form for your .NET code. API Version 2012-12-01...
  • Page 115 Amazon Redshift Management Guide Connecting to a Cluster by Using .NET Example : Connect to a Cluster by Using .NET The following example connects to a cluster and runs a sample query that returns system tables. It does not show server authentication. It is not necessary to have data in your database to use this example.
  • Page 116: Connect From Outside Of Amazon Ec2 - Firewall Timeout Issue

    Connect from Outside of Amazon EC2 - Firewall Timeout Issue When you are connecting to Amazon Redshift from a computer other than an Amazon Elastic Compute Cloud (Amazon EC2) instance, idle connections may be terminated by an intermediate network component, such as a firewall after a period of inactivity.
  • Page 117 Amazon Redshift Management Guide Connect from Outside of Amazon EC2 - Firewall Timeout Issue HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Paramet ers\KeepAliveInterval 1000 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Tcp MaxDataRetransmissions 10 Mac — If your client is a Mac, run the following command as the root user. sysctl -w net.inet.tcp.keepidle=20000 sysctl -w net.inet.tcp.keepintvl=20000 sysctl -w net.inet.tcp.keepinit=20000...
  • Page 118: Limits

    If you attempt to exceed a quota, the attempt will fail. Amazon Redshift has a default quota for the number of nodes you can provision in a cluster and an account. These limits are listed at AWS Service Limits.
  • Page 119 • Must contain only lowercase letters. • Cannot be a reserved word. For a list of reserved words, to Reserved Words in the Amazon Redshift Developer Guide. Master user name • Must contain from 1 to 128 alphanumeric characters. • First character must be a letter.
  • Page 120 Amazon Redshift Management Guide Naming Constraints Cluster snapshot identifier • Must contain no more than 255 alphanumeric characters or hyphens. • Must not be "Default". • Must be unique for all security groups that are created by your AWS account.
  • Page 121: Using The Aws Sdks

    For example, for each API request that you send to Amazon Redshift, you must include a signature for authentication. When you use the SDK libraries, you need to provide only your AWS security credentials in your code, and the libraries compute the necessary signature and include it in the request to Amazon Redshift.
  • Page 122: The Command Line

    Running Java Examples Using Eclipse Note The AWS SDK for Java provides thread-safe clients for accessing Amazon Redshift. As a best practice, your applications should create one client and reuse the client between threads. The AmazonRedshiftClient class defines methods that map to underlying Amazon Redshift Query API actions.
  • Page 123 For these cases, adjust the classpath ( -cp ) as appropriate. To run samples in this document, use a version of the AWS SDK that supports Amazon Redshift. To get the latest version of the AWS SDK for Java, go to AWS SDK for Java.
  • Page 124: Uploading Client-Side Encrypted Data

    Amazon S3 handles encryption and decryption, transparently. In client-side encryption, you manage the encryption keys and the related encryption and decryption process. This topic explains how to upload client-side encrypted data in Amazon S3 so that you can work with it in Amazon Redshift.
  • Page 125 Amazon Redshift Management Guide Example: Uploading Client-Side Encrypted Data # Endpoint. Use s3-external-1.amazonaws.com for clusters in us-east s3_endpoint=<s3 endpoint> # Bucket to upload data. s3_bucket=<bucket name> # S3 prefix to add to uploaded data files. All files loaded will have this prefix.
  • Page 126 Amazon Redshift Management Guide Example: Uploading Client-Side Encrypted Data String sourceDir = getProperty(config, "src_dir"); SecretKey mySymmetricKey = new SecretKeySpec( Base64.decodeBase64(masterSym metricKeyBase64.getBytes()) , "AES"); EncryptionMaterials materials = new EncryptionMaterials(mySymmetricKey); AmazonS3 s3 = new AmazonS3EncryptionClient(credentials, materials); s3.setEndpoint(s3Endpoint); // Upload all files. uploadAllFilesToS3(s3, bucketName, s3Prefix, new File(sourceDir) );...
  • Page 127 Example: Uploading Client-Side Encrypted Data } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon S3, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode());...
  • Page 128: Signing An Http Request

    • Example Signature Calculation (p. 125) Amazon Redshift requires that every request you send to the management API be authenticated with a signature. This topic explains how to sign your requests. If you are using one of the AWS Software Development Kits (SDKs) or the AWS Command Line Interface, request signing is handled automatically, and you can skip this section.
  • Page 129 Amazon Web Services Glossary. You can use a GET or POST request to send requests to Amazon Redshift. The difference between the two is that for the GET request your parameters are sent as query string parameters. For the POST request they are included in the body of the request.
  • Page 130 Task 1: Create a Canonical Request (p. 124). The service name to use in the credential scope is redshift . Task 3: Create a Signature (p. 124), the derived key can be represented as: derived key = HMAC(HMAC(HMAC(HMAC("AWS4"...
  • Page 131: Document History

    Amazon Redshift Management Guide Document History The following table describes the important changes since the last release of the Amazon Redshift Management Guide. Latest documentation update: July 17, 2013 Change Description Release Date New Feature Updated to describe cluster snapshot sharing and create 17 July 2013 snapshot progress metrics.

Table of Contents