AWS SAA summary-Exam 03

7 Route53
7.1 Route53 concept

Amazon Route 53 提供高可用且可扩展的域名系统 (DNS)、域名注册和运行状况检查 Web 服务。设计用于为开发人员和企业提供一种非常可靠且经济高效的方式,把名称(如 example.com)转换为计算机用于互相连接的数字 IP 地址(如 192.0.2.1),从而将最终用户路由到 Internet 应用程序。您可以将 DNS 与运行状况检查服务组合使用,路由流量到运行正常的终端节点,或者独立监控终端节点和/或对其提供警报。您还可以购买和管理域名(例如 example.com),并自动为域配置 DNS 设置。Route 53 高效地将用户请求连接到 AWS 中运行的基础设施,例如 Amazon EC2 实例、Elastic Load Balancing 负载均衡器或 Amazon S3 存储桶,还可以将用户转接到 AWS 外部的基础设施。

借助 Amazon Route 53,您可以创建和管理公有 DNS 记录。与电话簿相似,Route 53 可让您管理 Internet 的 DNS 电话簿中为您的域名所列的 IP 地址。Route 53 也应答将此类特定域名转换为对应的 IP 地址(如 192.0.2.1)的请求。您可以使用 Route 53 创建新域的 DNS 记录,或转换现有域的 DNS 记录。Route 53 具有简单的标准型 REST API,可让您轻松创建、更新和管理 DNS 记录。Route 53 还额外提供运行状况检查,可以监控应用程序的运行状况和性能,还能监控 Web 服务器和其他资源。您还可以注册新的域名或者将现有域名转移到 Route 53 中进行管理。

Route 53 supports up to 50 domain names by default, but this limit can be raised if requested.

Route 53 does support zone apex (naked) domain records.

DNS是一组规则和记录的集合,帮助客户端了解如何通过url访问服务器。在AWS中,最常用的记录是:

· A: URL to IPv4

· AAAA: URL to IPv6

· CNAME: URL to URL

· Alias: URL to aws resource

A记录示例

clip_image106

Figure 30 Diagram for A record

7.2 Routing policy

Route53 可以用于你拥有或购买的公有域名,例如application.mypublicdomain.com, 也可以用于你的VPC内实例解析的私有域名,如application1.company.internal.

Route53有高级的特性,例如:

· 负载均衡(通过DNS—也叫客户端负载均衡)

· 健康检查

· 路由策略—simple, failover, geolocation, latency, weighted, multi value.

以下重点介绍路由策略。

7.2.1 Simple routing policy

· 将一个域映射到一个url

· 使用场景: 当需要重定向到单个资源时使用

· 不能将健康检查附加到简单路由策略

· 当返回多个值时,客户端将随机选择一个

clip_image107

Figure 31 Simple routing policy

7.2.2 Weighted routing policy

WRR--加权轮询可让您为资源记录集合分配权重,以便指定不同回复所服务的频率。您可能希望使用此功能来执行 A/B 测试,发送一小部分流量到进行了软件更改的服务器。例如,假设您向一个 DNS 名称关联了两个记录集合,其中一个的权重为 3,另一个的权重为 1。此情形中,75% 时间内 Route 53 将返回权重为 3 的记录集合,25% 时间内 Route 53 将返回权重为 1 的记录集合。权重可以是 0 到 255 范围内的任意数字。

clip_image109

Figure 32 WRR Policy

7.2.3 Latency routing policy

LBR(基于延迟的路由)是 Amazon Route 53 的一项新功能,有助于您提高应用程序对全球受众的性能。您可以在多个 AWS 地区运行应用程序,Amazon Route 53 则通过其遍布全球的节点将最终用户路由到可提供最低延迟性的 AWS 地区。

只需通过 AWS 管理控制台或简单的 API,就能快速而轻松地使用 Amazon Route 53 的全新 LBR 功能。只需创建包含 IP 地址或各个 AWS 终端节点的 ELB 名称的记录集合,再将该集合标记为支持 LBR 的记录集合,这与将记录集合标记为加权记录集合非常相似。Amazon Route 53 将负责其余的工作 – 为各个请求确定最佳的终端节点并相应地路由最终用户,与 Amazon CloudFront 这一 Amazon 全球内容传输服务非常相似。

LBR特性:

· 重定向到延迟最少的服务器

· 当用户延迟是一个优先级时超级有用

· 延迟是基于用户设计的AWS区域来评估的

· 如果是延迟最低的,那么德国用户的请求可能会重定向到美国

7.2.4 Geolocation

地理定位-- Route 53 Geo DNS 会根据请求发出的地理位置将其送至特定的终端节点,以此帮助调整负载平衡。Geo DNS 可以自定义本地化的内容,例如以正确的语言展示详情页面或限制将内容分配到已授权的市场。Geo DNS 通过一种可以预见而又易于管理的方式让您实现负载平衡,确保每一个终端用户地点始终路由到相同的终端节点。Geo DNS 提供三种地理粒度级别:洲、国家/地区和州/省,Geo DNS 还提供全球记录,当终端用户的地点与您创建的特定 Geo DNS 记录不匹配时,全球记录可在这种情况下发挥作用。您还可以将 Geo DNS 与其他路由类型(例如基于延迟的路由和 DNS 故障转移)进行组合,以实现多种低延迟的容错架构。

Geoproximity policy: 地理邻近性,这个策略在当前的route53中看不到了,但是在考试中仍然可能会出现,这和Geolocation类似。

7.2.5 Multi value answer routing policy

Route 53 现在支持使用多值回答响应 DNS 查询。在 DNS 查询响应中返回多个可检查运行状况的 IP 地址这一功能并非负载均衡器的替代,这是使用 DNS 提高可用性和负载均衡能力的一种方式。如果您希望将流量随机路由到多个资源 (如 Web 服务器),您可以为每个资源创建一条多值回答记录,然后选择性地将 Amazon Route 53 运行状况检查与每条记录关联。Amazon Route 53 最多支持使用八条正常记录响应每条 DNS 查询。

7.2.6 Failover routing policy

当您希望创建主动/被动设置时,将使用故障转移路由策略。 例如,你想把你的主站点放在us-west-2,而从DR 站点在AP-Southeast-2。Route53将使用健康检查检查你的主站点健康情况,一旦发现主站点丢失,就会将流量路由转发到从站点上。

clip_image111

Figure 33 Failover routing

7.3 CNAME vs Alias

CNAME:

· 将一个url指向任何其他url. Application.mypublic.comàblabla.anything.com

· 只能用于非顶点域名

Alias:

· 将一个url指向AWS 资源。Application.mypublic.comàblabla.amazonaws.com

· 可以用于顶点域名和非顶点域名

· 免费

· 本地健康检查

image

Table 4 CNAME vs Alias

Exam tips:

· A simple routing policy allows single and multiple resources for both the primary and secondary resources. Weighted policies do honor health checks and weight numbers do not affect health checks.

8 S3-- Simple storage service

Amazon S3--Simple storage service, 是一种对象存储,专为从 Internet 上的任意位置存储和检索任意数量的数据而构建。它是一种简单的存储服务,以非常低的成本提供极其持久、高度可用并可无限扩展的数据存储基础设施。您可以存储的总数据容量和对象个数不受限制。各个 Amazon S3 对象的大小范围可以从最小 0 字节到最大 5TB。可在单个 PUT 中上传的最大数据对象为 5 GB。对于大于 100MB 的数据对象,客户应该考虑使用分段上传功能。

Amazon S3 提供一系列适合不同使用案例的存储类。这包括 S3 标准(适用于频繁访问的数据的通用存储);S3 智能分层(适用于具有未知或变化的访问模式的数据);S3 标准 - 不频繁访问(S3 标准 - IA)和 S3 单区 - 不频繁访问(S3 单区 - IA),适用于长期存在、但访问不太频繁的数据;以及 Amazon S3 Glacier (S3 Glacier) 和 Amazon S3 Glacier 深度存档(S3 Glacier 深度存档),适用于长期存档和数字保留。

clip_image113

Exam tips:

· While S3 does use availability zones to store objects in buckets, you do not choose the availability zone yourself. Even S3 One Zone-IA does not allow you to specify the AZ for use. By default, all AWS accounts can create up to 100 buckets. However, this limit can easily be raised by AWS if you request an upgrade.

· Multipart Upload is ideal for large objects on stable networks. But it also helps handle less-reliable networks as smaller parts can fail while others get through, reducing the overall failure rate.

· All S3 and S3-IA data is stored in a single region and within at least three availability zones within that region

· The problem here is trying to tag individual folders. You can use IAM for permissions, but a particular folder cannot be tagged separately from other folders; only an entire bucket can be tagged.

· This is important because it reflects a recent change by AWS. Until 2018, there was a hard limit on S3 of 100 PUTs per second, but that limit has now been raised to 3500 PUTs per second.

8.1 S3 features

· S3是基于对象的存储,允许你上传文件

· object文件大小可以从0B 到5T

· 没有存储限制

· 对于大于 100MB 的数据对象,客户应该考虑使用分段上传功能。

· 文件存储在buckets中

· S3使用全局的命名空间,也就是说名字必须是全局唯一的

· Bucket是在region level定义的

· 不适合于安装OS

· 成功上传文件后将会生成 HTTP 200状态码

· Permissions

§ User based policiesà roles (IAM)

§ Resource based policies

§ Bucket Policies

§ Access control lists

· Bucket ACL

· Object ACL

clip_image115

clip_image117

clip_image119

clip_image121

· 缺省条件下,所有新建的bucket都是PRIVATE,你可以配置访问控制

· S3可以配置创建访问日志,记录所有访问S3 Bucket的请求。这个log可以发送到其他bucket,即使是属于其他账号的bucket也可以。

· cross-origin requests

-not support https custom domain

· Request Authorization

-Permission Delegation

- Operation Authorization

· Lifecycle Management

-Transition

-Expiration

· price

-request + storage + data transfer

· Versioning enable 后不能被disable, 只能被suspended

· 任何文件,在启动Versioning 前,version 均为 “null”

clip_image123

clip_image125

clip_image127

s3是基于对象的,你可以把对象简单考虑为文件,以下是对象的组成部分:

  • Key: 这简单的指object 名字
  • Value :这是简单的数据,由一个字节序列组成
  • Version ID: 这对versioning 来说很重要
  • Metadata: 有关您正在存储的数据的数据
  • Subresources
  • Access control lists
  • Torrent

S3提供了两种数据一致性模式

  • Read after write consistency for PUTS of new objectsà new object can be read immediately
  • Eventual consistency for overwrite PUTS and DELETES (can take some time to propagate)
  • Stale read possible after updates and deletes (until change is fully propagated)
  • Lowest read latency
  • Highest read throughput

Bucket 命名规则:

  • 不含大写字母
  • 不含下划线
  • 3-63个字符长度
  • 没有IP
  • 必须以小写字母或数字开头

By default, newly created S3 buckets are private. They can only be accessed by a user that has been granted explicit access.


clip_image131clip_image129

clip_image133

8.2 S3 replication

clip_image135

clip_image137

clip_image139

clip_image141

8.3 S3 use cases and comparison
8.3.1 S3 use cases
  • S3 standard: 冗余地存储在多个设备中的多个设备上,旨在同时承受两个设备的损失
  • S3-Intelligent tier: 设计用于成本优化,通过自动将数据移动到最具成本效益的访问层,而不影响性能或操作开销层
  • S3-IA: 对于不频繁访问的数据,但需要时可以快速访问。 费用比S3 标准低,但将会产生检索费用
  • S3 One zone – IA : 对于不频繁访问而又追求低成本存储的数据,不要求多AZ 恢复
  • S3 Glacier: 是一种安全,持久且低成本的数据归档存储,检索时间从几分钟到数小时
  • S3 Glacier deep Archive: 这是S3 最低成本的存储,但检索时间12小时则是可接受的

clip_image143

clip_image145

clip_image147

8.3.2 S3 comparison

所有的S3存储类型,都具有相同的持久性,即 11 9s。考试中常考点是在可用性和SLA的区别。

clip_image149

Table 5 S3 comparison

8.4 S3 encryption for objects

在S3中,有4种方法来对object进行加密,考试中要重点了解那种方法适用于那种场景。

  • SSE-S3: 使用aws 处理和管理的密钥来加密S3 object
  • SSE-KMS: S3利用指定的aws KMS 来管理密钥
  • SSE-C: S3 使用用户每次请求提供密钥
  • 客户端加密

In general, SSE-S3 is the “starter” option for encryption. It’s by no means a simple or amateur approach to security, but it is low cost compared to KMS and has much less overhead than client-side or SSE-C encryption keys.

SSE-S3—Object是在server 端进行加密的,使用AES-256加密类型,header 必须设置为: “x-amz-server-side-encryption”: “AES256” 。使用此方法加密,其可靠性低,因为数据被检索后会自动解密,无论是合法还是非法的检索。

clip_image151

Figure 34 SSE-S3

SSE-KMS –> KMS的优势是用户控制和审计追踪,当题干中有audit出现,则应考虑的加密方式即为 SSE-KMS。Object是在server 端进行加密的,header 必须设置为: “x-amz-server-side-encryption”: “aws:kms”

clip_image153

Figure 35 SSE-KMS

SSE-C –> Object还是在server 端进行加密,但使用完全由客户在AWS外部管理的数据密钥,S3中保存用户的加密密钥。其他几种加密方式,传输时都是http 或https可选。但SSE-C必须使用https进行传输,且每个http请求都必须在header中提供加密密钥。

clip_image155

Figure 36 SSE-C

Client side encryption:

  • 客户端库,如amazon s3加密客户端
  • 数据发送到S3前,客户端必须自己先加密
  • 当从S3检索数据时,客户端必须自己解密
  • 客户完全管理密钥和加密周期

For client-side encryption, you’ll need a master key, which can either be a KMSmanaged key or a client-side master key. You’ll also need an SDK for encrypting the client-side data

clip_image157

Figure 37 Client side encryption

clip_image159

8.5 S3 Websites

s3可以托管静态网站并在Internet上访问它们,网站的url有2中形式:

  • <bucket-name>.s3-website-<AWS-region>.amazonaws.com

Or

  • <bucket-name>.s3-website.<AWS-region>.amazonaws.com

如:http:// mybucket.s3-website.eu-west-2.amazonaws.com

如果访问时得到403错误码,请确保 bucket policies是允许公网读取的。

This is a matter of carefully looking at each URL. Bucket names—when not used as a website—always come after the fully qualified domain name (FQDN); in other words, after the forward slash.

Where website hosting is concerned, the bucket name is part of the FQDN; where direct bucket access is concerned, the bucket name comes after the FQDN. This is an essential distinction. you need to recall that the s3-website portion of the FQDN is always connected to the region; in other words, it is not a subdomain.

S3 supports two styles of bucket URLs: virtual-hosted-style and path-style URLs. Virtual-hosted-style URLs are of the form http://bucket.s3-aws-region .amazonaws.com, and path-style URLs are the traditional URLs youve seen: https://s3-aws-region.amazonaws.com/bucket-name.

https://ytmProfilePictures.s3-website-us-east-2.amazonaws.com/images

S3 buckets have names based upon the S3 identifier (s3), the region (us-east-1 in this case), and the amazonaws.com domain. Then, the bucket name appears after the domain. That results in a URL like https://s3-us-east-1.amazonaws.com/ prototypeBucket32. However, buckets in US East are a special case and should use the special, unique endpoint s3.amazonaws.com

Only the root account can enable MFA Delete. Even the console user that created the bucket—if it isn’t the root user—cannot enable MFA Delete on a bucket.

Object URL

https://myawssaatest01.s3.amazonaws.com/versioning+test.txt

clip_image161

Figure 38 Object not public

S3 CORS à Cross-Origin Resource Sharing

如果你请求的数据来自另一个S3 bucket, 你就需要enable CORS, CORS允许您限制可以在s3中请求文件的网站的数量,并限制您的成本。常见的考试场景如下图:

clip_image163

Figure 39 CORS case

clip_image165

clip_image167

8.6 S3 lifecycle management

clip_image169

clip_image171

Define rules based on:

  • Object age
  • Current and previous version

Filter based on:

  • Prefix (images/, logs/)
  • Object tags (name= PHI)

clip_image173

clip_image175

clip_image177

clip_image179

clip_image181

clip_image183

9 Database
9.1 Database overview introduction

数据库是“按照数据结构来组织、存储和管理数据的仓库”。是一个长期存储在计算机内的、有组织的、可共享的、统一管理的大量数据的集合。数据库是以一定方式储存在一起、能与多个用户共享、具有尽可能小的冗余度、与应用程序彼此独立的数据集合,可视为电子化的文件柜——存储电子文件的处所,用户可以对文件中的数据进行新增、查询、更新、删除等操作。

数据库的分类,从大的方面来看,分为两大类,即关系型数据库(SQL)和非关系型数据库(NoSQL)。

关系型数据库,存储的格式可以直观地反映实体间的关系。关系型数据库和常见的表格比较相似,关系型数据库中表与表之间是有很多复杂的关联关系的。 常见的关系型数据库有MySQL、MariaDB、Oracle、Aurora、SQL Server 或 PostgreSQL等。在轻量或者小型的应用中,使用不同的关系型数据库对系统的性能影响不大,但是在构建大型应用时,则需要根据应用的业务需求和性能需求,选择合适的关系型数据库。

随着近些年技术方向的不断拓展,大量的NoSql数据库如DynamoDB、MongoDB、Redis、HBase、Memcache出于简化数据库结构、避免冗余、影响性能的表连接、摒弃复杂分布式的目的被设计。NoSQL数据库适合追求速度和可扩展性、业务多变的应用场景。 对于非结构化数据的处理更合适,如文章、评论,这些数据如全文搜索、机器学习通常只用于模糊处理,并不需要像结构化数据一样,进行精确查询,而且这类数据的数据规模往往是海量的,数据规模的增长往往也是不可能预期的,而NoSQL数据库的扩展能力几乎也是无限的,所以NoSQL数据库可以很好的满足这一类数据的存储。NoSQL数据库利用key-value可以大量的获取大量的非结构化数据,并且数据的获取效率很高,但用它查询结构化数据效果就比较差。

RDS provides two (and only two) methods for backing up RDS databases at this point: automated backups and automated snapshots.

All the major databases supported by RDS—MariaDB, SQL Server, MySQL, Oracle, and PostgreSQL—allow up to 16 TB of storage for a provisioned IOPS volume.

clip_image185

clip_image187

clip_image189

9.2 SQL database introduction
9.2.1 RDS (OLTP)

Amazon Relational Database Service 也称为 Amazon RDS,是一种托管服务,可以简化在云中设置、操作和扩展关系数据库的过程。它在管理耗时的数据库管理任务的同时,提供经济高效的可调容量,使您能够腾出时间专注于应用程序和业务。与所有 Amazon Web Services 相同,您无需预先投资,而且只需为所使用的资源付费。如果您的应用程序需要更多的数据库实例,您可以通过此申请表申请更多数据库实例。

· 管理 MySQL、MariaDB、Oracle、SQL Server 或 PostgreSQL ,这意味着您当前用于现有数据库的代码、应用程序和工具也可以无缝用于 Amazon RDS。

· Amazon RDS 可以自动备份您的数据库,并使您的数据库软件版本保持最新。

· 您可以灵活方便地扩展与关系数据库实例相关联的计算资源或存储容量,并从中受益。此外,Amazon RDS 还可通过复制轻松增强数据库可用性、改进数据耐久性或扩展读取密集型数据库工作负载中单一数据库实例的容量限制。

· 默认情况下,客户最多可以拥有 40 个 Amazon RDS 数据库实例。全都可用于“BYOL” (Bring Your Own License) 模式下的 Amazon Aurora、MySQL、MariaDB、PostgreSQL 以及 Oracle。

· 适用于 SQL Server 的 RDS 在单个数据库实例上有最多拥有 100 个数据库的限制。

· 必须提供EC2实例和EBS卷类型和大小

· 通过CloudWatch 监控

· 备份/快照/时间点恢复功能

· RDS 在虚拟机上运行,但你不能登录这些OS

· AWS 负责RDS OS 的安全,用户负责使用ssl在DB中设置KMS, Security group, IAM policies和授权用户

· RDS 不是 serverless

· 支持 read replica

  • 用于增加性能
  • 必须开启自动备份
  • 可以在不同的regions
  • 支持Multi AZ
  • 可以是Aurora 或MariaDB, MySQL,Oracle, and PostgreSQL
  • 可以提升为master,但这将打破read replica
  • You can have up to five read replicas at a time for a single instance

· 通过rebooting RDS实例,你可以强制灾难恢复从一个AZ到另一个AZ

将数据导入 Amazon RDS 的方式有很多并且非常简单,例如对于 MySQL 使用 mysqldump 或 mysqlimport 实用程序,对于 Oracle 使用数据泵、Import/Export 或 SQL Loader,对于 SQL Server 使用 Import/Export 向导、完整备份文件(.bak 文件)或 Bulk Copy Program (BCP),或对 PostgreSQL 使用 pg_dump。有关数据导入和导出的更多信息,请参阅 MySQL 数据导入指南、Oracle 数据导入指南、SQL Server 数据导入指南、PostgreSQL 数据导入指南。

静态加密支持Aurora、MySQL、SQL Server、MariaDB、PostgreSQL 以及 Oracle。使用AWS的密钥管理服务(KMS )来完成加密。一旦RDS实例被加密,就会加密底层存储中的静态数据,以及它的自动备份、read replicas和snapshots。

Exam tips:

· Read replicas use asynchronous replication, pushing data to the read replicas whenever possible, for improved read performance. Read replicas are intended to provide scalability for your application by adding additional instances for increased reads from applications. you can set up a read replica in an on-premises instance. Additionally, read replicas are often created in separate regions from the primary instance, to improve performance for clients closer to different regions than the primary instance.

· A read replica configuration is aimed squarely at increasing database performance, specifically the performance of reading data from an RDS instance. Read replicas are updated via asynchronous replication— the most performant approach—from the primary database.

· read replicas are not a backup strategy, nor do they cause automatic backups to be set up. However, you must turn on automatic backups for the primary database instance to enable read replicas.

· Read replicas do not create automatic backups, but the primary database instance must have automatic backups enabled to create read replicas.

· Amazon RDS does not support circular replication, which means one database reads from a second database but then is replicated back by that second database. However, it is absolutely permissible for one database to replicate another database and then be the source for a third database.

· Currently, read replicas in RDS are only supported by MariaDB, MySQLOracle, and PostgreSQL.

· A Multi-AZ setup is about disaster recovery, and therefore durability. They provide automatic backups, upgrades happen on the primary database and then are replicated, and there is a primary and usually a single secondary instance

· A Multi-AZ setup is focused on disaster recovery and fault tolerance, while read replicas provide performance and scalability.

· Replication occurs synchronously from a primary instance to a secondary instance in a Multi-AZ setup. Asynchronous replication only occurs in a read replica setup (which can be enabled in addition to a Multi-AZ setup).

· RDS provides for SQL interaction as well as access through the RDS web APIs. RDS instances do not allow access via SSH or RDP.

· AWS does not support circular replication through RDS. While some of the databases supported by RDS do, RDS itself does not provide access to this functionality.

clip_image191

clip_image193

clip_image195

clip_image197

clip_image199

clip_image201

clip_image203

9.2.2 Aurora

clip_image205

· 以10GB为起点,10GB 为增量增加到64T,存储可自动伸缩

· 计算资源可以纵向扩展到32Vcpu ,244G 内存

· 至少有3个可用区,每个可用区包含2个副本,也即是你的数据至少6个副本

· 当主机故障:

一个read replica将自动晋升为主机(60秒内)

如果没有read replica,将自动lauch 新的替代主机

· 你可以分享Aurora snapshots给其他AWS 账户

· 缺省情况下,Aurora开启自动备份

· Aurora 是 serverless

· Aurora 速度是MySQL 5倍, PostgreSQL 3倍

· AWS 负责Aurora OS 的安全,用户负责使用ssl在DB中设置KMS, Security group, IAM policies

clip_image207

Figure 40 The comparison between MySQL and Aurora

clip_image209

clip_image211

clip_image213

clip_image215

9.2.3 RDS summary

Backup

· preferred backup window

· backup retention period

· I/O suspension for single

· Point-In-Time Recovery

Snapshot

· DB Snapshots make entire DB instance

· from one region to another region, a copy retain in that region

· Because KMS encryption keys are specific to the region that they are created in, encrypted snapshot cannot be copied to another region

· DB Snapshot Sharing

§ DB snapshot that uses an option group with permanent or persistent options cannot be shared

· KMS key policy must first be updated by adding any accounts to share the snapshot with, before sharing an encrypted DB snapshot

Replication

· routing read queries from applications to the Read Replica

· Failover mechanism automatically changes the DNS record of the DB instance to point to the standby DB instance

Multi-AZ deployment

· read-only traffic, use a Read Replica.

· synchronous standby replica in a different Availability Zone

· must be in same region

· For multi-AZ high availability, RDS uses synchronous replication between primary and standby systems.  If standby is slow, transactions will take longer to complete.  RDS Read Replica on the other hand uses asynchronous replication and any slowness in Read Replica instance would simply cause data lag in the read - replica.  Transactions in primary is impacted

Read Replica

· RDS sets up a secure communications channel between the source DB instance and the Read Replica, if that Read Replica is in a different AWS region from the DB instance

· replication link is broken, A Read Replica can be promoted to a new independent source DB

· use some tools like HAPROXY, with two url, one for write one tor read

Security

· Encryption enabled at creating, can not change key later

· Once encryption, log, snapshot, autobackup and replica are encripted

· Cross region replicas and snapshots copy does not work since the key is only available in a single region

· Database security groups default to a “deny all” access mode

Monitor

· 监控的metric 16 项, ReplicaLag

· Backup not notify for snapshot

Maintenance

· Multi-AZ deployment, preform standby, promote standby, preform old primary

· RDS takes two DB snapshots, before upgrade, after upgrade

9.3 NoSQL database introduction
9.3.1 ElastiCache

使用ElastiCache来增加数据库和web应用程序的性能,它具有如下特性:

· 管理 Redis / Memcache. (类似于RDS,但用于缓存)

· 内存数据存储,延迟低于毫秒级

· 必须提供EC2实例类型

· 支持集群(Redis)和 Multi AZ, Read replicas (sharding)

· 安全是通过IAM, Security group, KMS, Redis Auth

· 备份/快照/时间点恢复功能

· 通过CloudWatch 监控

· AWS 负责OS 的安全,用户负责使用ssl在DB中设置KMS, Security group, IAM policies,users (Redis Auth)

clip_image217

Figure 41 Redis vs Memcached

Exam tips:

· ElastiCache, when used through AWS, handles all of these tasks and more: hardware provisioning, software patching, setup, configuration, monitoring, failure recovery, and backups. à Means everything handled by ElastiCache

· ElastiCache is an in-memory data store that shards across instances. It is not in itself a data distribution mechanism. And it is not a monitoring solution at all.

· ElastiCache is ideal for high-performance and real-time processing as well as heavyduty business intelligence.

· Consider ElastiCache as only useful for storing transient data. Further, it’s not a persistent store; therefore, it’s great for caching data from a message queue or providing very fast ephemeral storage.

· ElastiCache uses shards as a grouping mechanism for individual redis nodes.

· ElasticCache

§ ElastiCache currently allows access only from the EC2 network

§ Memcache not support multi-AZ

§ REDIS replica read can not across regions

§ Redis Replication Groups, max 5 replica

§ Redis Multi-AZ with Automatic Failover, promote one replica as primary, disabled Failover, create new instance and sync with exist replica

clip_image219

clip_image221

clip_image223

9.3.2 DynamoDB

AWS DynamoDB是一个快速和灵活的NoSQL数据库服务,适用于所有需要一致的、任何规模的延迟在个位数的应用程序,他是一个完全托管的数据库,支持文档和Key-value数据模型。它灵活的数据模型和可靠的性能使它非常适合于移动、web、游戏、广告技术、IoT和许多其他应用程序。mobile, web, gaming, ad-tech, IoT, and many other applications.

clip_image225

Primary key:

Simpleàsingle attribute

Compositeà Two attribute (partition key, sort key)

· AWS 专有的技术,NoSQL 数据库管理

· 存储在SSD存储器中

· 高可用,分布在3个地理上不同的数据中心

· 缺省是最终的一致性 读取(eventual consistent reads)

所有数据副本之间的一致性通常在1秒内到达。在短时间内重复读取应该会返回更新后的数据(最后的读性能)

· 支持强一致读取 (Strongly consistent reads)

强一致的读将返回一个结果,该结果反应在读之前收到成功响应的所有写操作

Cost 是最终一致性的2倍

· Serverless,配置容量,自动扩展

· 具有备份/恢复功能,全局表功能

· 可以代替ElastiCache作为 key-value存储,例如存储会话数据

· 通过CloudWatch 监控

· 安全—身份认证和授权是通过IAM 完成的

· 只能查询主key,排序key和 index

· Use case: 无服务器应用程序开发,分布式无服务器缓存,不支持SQL 查询语言

DynamoDB

· synchronously replicates data across three AZ’s in a region

· durability with shared data

· secutiry&permission

· IAM Role that allows write access to the DynamoDB,

· Launch an EC2 Instance with the IAM Role included

· Secondary Indexes

· global, an index with a hash and range key that can be different from those on the table

· batch read up to 100 items (using primary keys)

· batch up to 25 individual putitem and deleteitem request

clip_image227

clip_image229

clip_image231

clip_image233

clip_image235

clip_image237

clip_image239

clip_image241

clip_image243

clip_image245

clip_image247

clip_image249

clip_image251

clip_image253

clip_image255

9.4 Redshift

Redshift 是基于PostgreSQL的,但它并不用于OLTP-- online transation processing,而是用于OLAP—online analytical processing,作为分析和数据仓库。其性能是其他数据仓库的10倍,可扩展到PB级的数据。存储时基于列存储而不是行存储,支持大规模的并行查询(MPP—Massively Parallel Query Execution), 且高可用。由SQL 接口来执行查询。根据所提供的实例按需付费,集成了BI 工具,如 AWS Quicksight或tableau。

Redshift具有如下特性:

· 单节点—160Gb

· 多节点

§ Leader节点,管理客户端连接和接收查询

§ Compute节点,存储数据和执行查询即计算,可扩展到128个计算节点

· 数据从S3、DynamoDB、DMS和其他DBs加载

· cluster can be restored from snapshot in same region

· Redshift spectrum: 可以直接针对S3执行查询,不需要加载

· Redshift增强了VPC路由功能,复制和卸载(unload)都经过VPC

· Backups

§ 默认启用,保留一天

§ 最长保存期为35天

§ Redshift总是试图维护至少3个数据副本:计算节点上的original和replica,以及Amazon S3中的备份

§ Redshift还可以异步复制你的snapshots到另一个区域的S3中,进行灾难恢复

· Redshift的可用性:

§ 当前只支持1个AZ

§ 有自动愈合功能—auto healing

§ 可以在停机时将snapshots恢复到新的 AZ (same region)

§ 可用于商业智能(Business intelligence)

· 操作类似于RDS

· 安全也类似于RDS: IAM, VPC, KMS,SSL

Redshift is one of AWS’s OLAP (online analytics processing) tools and is a database service. While it does processing, it is primarily intended to receive large amounts of data and operate upon that data, as a database would (in loose terms).

Redshift is optimized for batched write operations and for reading high volumes of data. Columnar storage minimizes I/O and maximize data throughput by retrieving only the blocks that contain data for the selected columns. It is not meant for high frequency update use cases typically seen in OLTP systems

clip_image257

9.5 How to connect to a RDS database instance in one VPC

通过 VPC 内部署的 EC2 实例可以访问同一 VPC 内部署的数据库实例。如果这些 EC2 实例部署在具有关联弹性 IP 的公共子网中,您可以通过 Internet 访问 EC2 实例。对于 VPC 内部署的数据库实例,可通过 VPN 或您在公有子网中可以启动的堡垒主机,或使用 Amazon RDS 可公开访问选项通过 Internet 或从 VPC 外部的 EC2 实例进行访问。

要使用堡垒主机,您需要设置一个包含用作 SSH 堡垒的 EC2 实例的公开子网。该公有子网的 Internet 网关和路由规则必须允许通过 SSH 主机引导流量,然后必须将请求转发到 RDS 数据库实例的私有 IP 地址。

简单创建数据库实例,并将“可公开访问”选项设定为“是”,即可使用公共连接。默认情况下,当“可公开访问”选项可用时,从您的 VPC 外部可实现对 VPC 内数据库实例的完全访问。这表示您无需配置 VPN 或堡垒主机来允许对实例的访问。

您也可以设置一个 VPN 网关,将公司网络扩展到 VPC,然后允许访问该 VPC 中的 RDS 数据库实例。有关详细信息,请参阅 Amazon VPC 用户指南。我们强烈建议您使用 DNS 名称来连接数据库实例,因为基础 IP 地址可能会发生变化(例如,在故障转移时)。

数据库实例迁移:可以从VPC外部迁移到内部,但不能从内部迁移到外部。

· 如果数据库实例未在 VPC 中,您可以使用 AWS 管理控制台轻松将数据库实例移至 VPC 中。

· 对 VPC 外部的数据库实例拍摄快照,然后通过指定您要使用的数据库子网组,将其还原到 VPC。此外,您也可以执行“还原到时间点”操作。

· 不支持将数据库实例从 VPC 内部迁移到外部。出于安全考虑,无法将 VPC 内数据库实例的数据库快照还原到 VPC 外部。同样,也无法执行“还原到时间点”功能。

9.6 RDS Database configuration

如果您的 AWS 账户是在 2013 年 12 月 4 日之前创建的,那么您或许可以在 Amazon Elastic Compute Cloud (EC2)-Classic 环境中运行 Amazon RDS。无论使用 EC2-Classic 还是 EC2-VPC,Amazon RDS 的基本功能完全相同。无论数据库实例部署在 VPC 内部还是外部,Amazon RDS 都能管理备份、软件补丁、自动故障检测、只读副本和恢复。

数据库子网组是您希望为 VPC 中的 RDS 数据库实例委派的子网集合。每个数据库子网组都应在指定区域中的每个可用区内拥有至少一个子网。在 VPC 中创建数据库实例时,您需要选择一个数据库子网组。然后,Amazon RDS 使用该数据库子网组和您首选的可用区来选择子网以及该子网内的 IP 地址。Amazon RDS 创建弹性网络接口,并通过该 IP 地址将其关联到您的数据库实例。请注意,我们强烈建议您使用 DNS 名称来连接数据库实例,因为基础 IP 地址可能会变化(例如,在故障转移时)。

对于多可用区部署,为一个区域内的所有可用区定义子网可允许 Amazon RDS 在需要时在其他可用区中创建新的备用实例。即使是单一可用区部署,您也需要这样做,以防以后需要将它们转换为多可用区部署。

以多可用区部署模式运行我的数据库实例时,不可以使用备用副本来执行读取或写入操作。多可用区备用副本不能服务读取请求。多可用区部署旨在增强数据库可用性和持久性,而非获得读取扩展优势。因此,该功能在主副本和备用副本之间采用同步复制。我们的实施可确保主副本和备用副本一直处于同步状态,但不能使用备用副本执行读取或写入操作。

需要先启用数据库实例的自动备份,然后才能创建只读副本。将备份保留时间设置为 0 以外的任何值,以此在添加只读副本之前启用源数据库实例的自动备份。要使只读副本能够运行,必须保持备份的启用状态。借助 Amazon RDS for MySQL、MariaDB、PostgreSQL 和 Oracle,最多可为给定的源数据库实例创建 5 个只读副本。Amazon RDS 支持跨区域只读副本。数据写入源数据库实例与数据在只读副本上可用之间的时间长度取决于两个区域之间的网络延迟,只读副本使用这些引擎的本机异步复制执行。Amazon Aurora 使用的是一种不同但仍然是异步的复制机制。

posted @ 2022-10-03 10:24  逆流的鱼2016  阅读(113)  评论(0编辑  收藏  举报