Dynamodb 简明教程

DynamoDB - Environment

DynamoDB 环境仅包含使用你的亚马逊网络服务帐户来访问 DynamoDB GUI 控制台,不过你也可以执行本地安装。

The DynamoDB Environment only consists of using your Amazon Web Services account to access the DynamoDB GUI console, however, you can also perform a local install.

导航至以下网站 − https://aws.amazon.com/dynamodb/

Navigate to the following website − https://aws.amazon.com/dynamodb/

单击“使用亚马逊 DynamoDB 入门”按钮,或在没有亚马逊网络服务帐户时单击“创建 AWS 帐户”按钮。简单的引导流程将告知你所有相关费用和要求。

Click the “Get Started with Amazon DynamoDB” button, or the “Create an AWS Account” button if you do not have an Amazon Web Services account. The simple, guided process will inform you of all the related fees and requirements.

执行该流程的所有必要步骤后,你将具有访问权限。只需登录 AWS 控制台,然后导航至 DynamoDB 控制台。

After performing all the necessary steps of the process, you will have the access. Simply sign in to the AWS console, and then navigate to the DynamoDB console.

请务必删除未使用或不必要的素材,以免产生相关费用。

Be sure to delete unused or unnecessary material to avoid associated fees.

Local Install

AWS(亚马逊网络服务)提供了用于本地安装的 DynamoDB 版本。它支持在没有 Web 服务或连接的情况下创建应用程序。通过允许使用本地数据库,它也降低了预置吞吐量、数据存储和传输费用。本指南假定为本地安装。

The AWS (Amazon Web Service) provides a version of DynamoDB for local installations. It supports creating applications without the web service or a connection. It also reduces provisioned throughput, data storage, and transfer fees by allowing a local database. This guide assumes a local install.

准备就绪时,你可以对应用程序进行一些微小的调整,以使其转换为 AWS 使用。

When ready for deployment, you can make a few small adjustments to your application to convert it to AWS use.

安装文件是 .jar executable 。它在 Linux、Unix、Windows 和任何其他支持 Java 的操作系统中运行。使用以下链接之一下载该文件 −

The install file is a .jar executable. It runs in Linux, Unix, Windows, and any other OS with Java support. Download the file by using one of the following links −

Note − 其他存储库提供该文件,但不一定是最新的版本。使用上述链接获取最新的安装文件。另外,确保你具有 Java 运行时引擎 (JRE) 6.x 或更高版本。较低版本上无法运行 DynamoDB。

Note − Other repositories offer the file, but not necessarily the latest version. Use the links above for up-to-date install files. Also, ensure you have Java Runtime Engine (JRE) version 6.x or a newer version. DynamoDB cannot run with older versions.

下载适当的存档后,解压缩其目录 (DynamoDBLocal.jar) 并将其放置在所需位置。

After downloading the appropriate archive, extract its directory (DynamoDBLocal.jar) and place it in the desired location.

然后,你可以通过打开命令提示符、导航至包含 DynamoDBLocal.jar 的目录并输入以下命令来启动 DynamoDB −

You can then start DynamoDB by opening a command prompt, navigating to the directory containing DynamoDBLocal.jar, and entering the following command −

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

你也可以通过关闭用于启动它的命令提示符来停止 DynamoDB。

You can also stop the DynamoDB by closing the command prompt used to start it.

Working Environment

你可以使用 JavaScript 外壳程序、GUI 控制台和多种语言来使用 DynamoDB。可用语言包括 Ruby、Java、Python、C#、Erlang、PHP 和 Perl。

You can use a JavaScript shell, a GUI console, and multiple languages to work with DynamoDB. The languages available include Ruby, Java, Python, C#, Erlang, PHP, and Perl.

在本教程中,我们使用 Java 和 GUI 控制台示例,以实现概念和代码清晰。安装 Java IDE、适用于 Java 的 AWS SDK,并为 Java SDK 设置 AWS 安全凭证,以利用 Java。

In this tutorial, we use Java and GUI console examples for conceptual and code clarity. Install a Java IDE, the AWS SDK for Java, and setup AWS security credentials for the Java SDK in order to utilize Java.

Conversion from Local to Web Service Code

准备就绪后,你需要更改你的代码。调整取决于代码语言和其他因素。主要更改仅包含将 endpoint 从本地点更改为 AWS 区域。其他更改需要对你的应用程序进行更深入的分析。

When ready for deployment, you will need to alter your code. The adjustments depend on code language and other factors. The main change merely consists of changing the endpoint from a local point to an AWS region. Other changes require deeper analysis of your application.

本地安装与 Web 服务在许多方面存在差异,包括但不限于以下主要差异 −

A local install differs from the web service in many ways including, but not limited to the following key differences −

  1. The local install creates tables immediately, but the service takes much longer.

  2. The local install ignores throughput.

  3. The deletion occurs immediately in a local install.

  4. The reads/writes occur quickly in local installs due to the absence of network overhead.