免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
AWS SAA summary--Exam

1 Overview introduction

SAA 備考目的是為了提高職場(chǎng)競(jìng)爭(zhēng)力和自我能力實(shí)現(xiàn)。這是對(duì)近3個(gè)月的學(xué)習(xí)所做的知識(shí)點(diǎn)總結(jié),這里將基于這個(gè)圖例,從外而內(nèi)的剖析每個(gè)部件的功能特征,歸納總結(jié)知識(shí)點(diǎn)。

這是一個(gè)基礎(chǔ)框架,很多專業(yè)的知識(shí)點(diǎn)未被展示在這張圖中,而對(duì)于學(xué)習(xí)備考和將來(lái)的使用又是非常必要的,這里也會(huì)做對(duì)應(yīng)的擴(kuò)展延申總結(jié),比如ELB, RDS, IAM, EBS, SNS, SQS等。由于報(bào)考語(yǔ)言選擇英語(yǔ),這中間有很多從sample question 中復(fù)制的解析,或者是PPT截圖,均為英文版,故內(nèi)容為中英混合。

Figure 1 Architecture overview Diagram

2 IAM

2.1 IAM overview

IAM – Identity access management, 這個(gè)功能是入門AMS將接觸的第一功能。備考時(shí),你首先要注冊(cè)一個(gè)免費(fèi)的AWS 賬號(hào),這就涉及IAM的功能,包含賬號(hào)和角色管理,其底層依賴都是Policy。

IAM由以下部分組成:

· 用戶 users

· 組 groups

· 角色 roles

· 策略 policies

Figure 2 IAM Structure

策略案例:

{

"Id": "Policy1547623824130",

"Version": "2012-10-17",

"Statement": [

{

"Sid": "Stmt1547623806374",

"Action": [

"s3:DeleteBucket"

],

"Effect": "Allow",

"Resource": "arn:aws:s3:::elasticbeanstalk-ap-northeast-1-609617148900",

"Principal": "*"

}

]

}

IAM的功能特性:

· IAM是全局的,不單應(yīng)用于某個(gè)區(qū)域,它就是AWS的中心

· Root account只是在創(chuàng)建AWS賬戶時(shí)的一個(gè)賬號(hào),它具有全部的admin access

· 第一次創(chuàng)建的New user沒(méi)有 permission,應(yīng)當(dāng)分配適當(dāng)?shù)膒ermission (minimal)

· Permission是通過(guò)Policies來(lái)管理的,Policies是用JSON寫的

· IAM 預(yù)定義了“Managed policies”

· 首次創(chuàng)建用戶時(shí),需要選擇AWS access type,這里有2個(gè)類型供選擇

o Programmatic access

§ 要分配Access key ID & secret access key. 他們不同于密碼,你不能用Access key ID & secret access key登錄到console,然而你可以通過(guò)AWS API, CLI, SDK, and 其他開發(fā)工具訪問(wèn)AWS.

§ 你只能看見一次Access key ID & secret access key,如果你丟失了他們,你需要重新生成,因此應(yīng)該將他們保存在安全的地方。

o AWS Management Console access

§ Enables a password that allows users to sign-in to the AWS Management Console.

§ 需要為用戶提供登錄url,如:https://ganyu.signin.aws.amazon.com/console

· 總是需要為 root account 設(shè)置多因素身份認(rèn)證MFA

· 你可以創(chuàng)建和定義自己的密碼輪換策略

· 角色比存儲(chǔ)Access key ID & secret access key在具體的EC2上更安全

· 角色很容易管理

· 創(chuàng)建EC2實(shí)例后,可以通過(guò)console & command line分配角色

· 角色是全局的,你可以使用在任意region

· IAM 聯(lián)合(federation)

§ 大型企業(yè)通常會(huì)將自己的用戶庫(kù)集成到IAM中,通過(guò)這中方式,用戶可以通過(guò)自己的公司憑證登錄到AWS

§ 身份聯(lián)合使用SAML標(biāo)準(zhǔn) (Active directory)

IAM的 1v1 brain dump:

· 一個(gè)IAM用戶對(duì)應(yīng)一個(gè)自然人

· 一個(gè)角色對(duì)應(yīng)一個(gè)應(yīng)用程序

· 絕不能share IAM 憑證

· 絕不能把IAM 憑證寫在代碼中

· 不要提交你的 IAM憑證

· 除了初始設(shè)置時(shí),永遠(yuǎn)不要使用root account

· 不要使用root account 憑證

Exam tips:

· IAM controls permissions for resource-to-resource interaction as well as user access to the AWS console. It does not provide an authentication interface or single sign-on.

· IAM only applies to permissions for users, roles, and groups and does not affect billing or cost or specific application feature accessibility.

· It does not handle hosted application permissions or relate to SNS

· IAM is not the managed service for handling MFA Delete setup on S3 buckets.

· Users, groups, roles, permissions, and similar constructs are part of IAM. Organizations and organizational units are part of AWS Organizations, a different facility.

· There are four types of policies in IAM:

§ identity-based

§ resource-based

§ organization SCPs

§ access control lists (ACLs)

· IAM policies can be attached to users, groups, and roles in the case of identity based policies, and AWS services and components via resource-based policies.

· AWS Organizations provides logical groupings and account management.

· IAM aids in scalability primarily by consolidating and centralizing management of permissions, both to AWS users and from instances to services. Use case:

o It allows assignment of permissions to users en masse via groups.

o It allows consistency in access from instances to managed AWS services across large numbers of instances.

· Power user access is a predefined policy that allows access to all AWS services with the exception of group or user management within IAM.

· The Power User group provides access to developer-related services, but not all services (like IAM).

· AWS defines and keeps updated a number of IAM policies for users, including Administrator, Billing, and Power User.

· A policy document is a collection of permissions in IAM.

· IAM users are global to an AWS account and are not region-specific.

· You should never store your application keys on an instance, in an AMI, or anywhere else permanent on the cloud. application keys are for programmatic access, not console access.

· You can only assign a single role to an instance.

· Remember that AWS provides a principle of least privilege and always wants to limit access to only what a user (or service) needs. Therefore, new IAM users do not have any access to AWS services and must be granted access to any service explicitly

You can choose from several different types of accounts when you add new users. Each type of account comes with different privileges:

  • An "administrator" has full access to the account with all permissions including account maintenance, users, billing information, and subscriptions.
  • A "power user" has similar permissions to an administrator except they can't edit or view subscriptions or other users and they do not have access to billing information.
  • A "user" is the most limited role. They can only view the account. They can't view subscriptions, other users on the account or access billing information.
  • The "no login" role essentially disables the user. They won't be able to log into the account.

2.2 IAM summary

MultiFactor Authentication

· Security token-based, 6位數(shù)字設(shè)備

· SMS text

policy

· An explicit allow overrides default deny

· 語(yǔ)法 Principal, action,Effect,Resource,condition

· Capability policies, Resource policies, IAM policies

Role delegation

· Identity Providers

· Amazon Cognito

· SAML

· Custom Identity broker Federation

· Cross account access

· EC2 has role, app inside can take role

2.3 WIF

WIF---Web Identity Federation, web身份聯(lián)合,允許用戶通過(guò)基于web的身份提供者,如Amazon,F(xiàn)acebook或Google,身份驗(yàn)證成功后,可以訪問(wèn)AWS的資源。身份驗(yàn)證成功,用戶從web ID 提供者接收身份驗(yàn)證code,并將其轉(zhuǎn)換為臨時(shí)的AWS安全憑證。

Amazon Cognito 為WIF 提供了以下功能:

· 注冊(cè)并登錄你的應(yīng)用程序 sign-up and sign-in

· 以guest身份訪問(wèn)

· 充當(dāng)應(yīng)用程序和web ID提供者之間的身份代理(identity broker),因此不需要編寫任何額外代碼

· 為多個(gè)設(shè)備同步用戶數(shù)據(jù)

· 推薦用于所有 mobile app 的AWS 服務(wù)

Cognito 用戶池

用戶池是用于管理移動(dòng)和web應(yīng)用程序的注冊(cè)和登錄功能的用戶目錄。用戶可以直接登錄到用戶池,或使用Amazon,F(xiàn)acebook或Google。Cognito充當(dāng)應(yīng)用程序和web ID提供者之間的中介。成功的身份驗(yàn)證將生成一個(gè)JSON Web令牌 JWTs。

Cognito 身份池

身份池允許提供臨時(shí)的AWS憑證來(lái)訪問(wèn)AWS服務(wù),如S3 或DynamoDB

Figure 3 Cognito in action

Cognito 用例

推薦使用Facebook等社交媒體賬戶的web 身份聯(lián)合。

Figure 4 FaceBook with WIF

Cognito在應(yīng)用程序和Facebook或Google之間進(jìn)行代理,以提供映射到IAM角色的臨時(shí)憑證,從而允許訪問(wèn)所需資源。不需要應(yīng)用程序在設(shè)備本地嵌入或存儲(chǔ)AWS憑證,它為用戶提供跨所有移動(dòng)設(shè)備的無(wú)縫體驗(yàn)。

Cognito追蹤用戶身份和他們登錄的不同設(shè)備之間的聯(lián)系,為你的應(yīng)用程序提供無(wú)縫的用戶體驗(yàn),cognito使用push同步來(lái)跨多個(gè)設(shè)備推送更新和同步用戶數(shù)據(jù)。當(dāng)存儲(chǔ)在云中的數(shù)據(jù)發(fā)生變化時(shí),cognito使用SNS向所有與給定用戶身份相關(guān)的設(shè)備發(fā)送通知。

Figure 5 Push synchronization using SNS

3 VPC

3.1 VPC concept

Amazon VPC -- Virtual private cloud允許您在 AWS 云中私有、隔離的部分創(chuàng)建虛擬網(wǎng)絡(luò)環(huán)境,從中可以對(duì)私有 IP 地址范圍、子網(wǎng)、路由表和網(wǎng)絡(luò)網(wǎng)關(guān)等方面進(jìn)行全面控制。借助 Amazon VPC,您可以定義虛擬網(wǎng)絡(luò)拓?fù)浜妥远x網(wǎng)絡(luò)配置,使其非常類似于您在自己的數(shù)據(jù)中心所操作的傳統(tǒng) IP 網(wǎng)絡(luò)。使用 VPC 的一個(gè)好處在于:您可以運(yùn)行面向公眾的 Web 應(yīng)用程序,同時(shí)仍舊在私有子網(wǎng)中保持非公開訪問(wèn)的后端服務(wù)器。您可以為 Web 服務(wù)器創(chuàng)建一個(gè)可以訪問(wèn) Internet 的公有子網(wǎng),并將后端 RDS 數(shù)據(jù)庫(kù)實(shí)例置于不能訪問(wèn) Internet 的私有子網(wǎng)中。默認(rèn)情況下,一個(gè)aws賬號(hào)最多可以創(chuàng)建5個(gè)VPC, 當(dāng)然,如果業(yè)務(wù)需要,可以向aws申請(qǐng)創(chuàng)建更多VPC.

這里還需要提出另外2個(gè)概念,圖中并未體現(xiàn)。一是區(qū)域(region),二是可用區(qū)(Availability zone)。 區(qū)域是aws在全球范圍內(nèi)所建立的數(shù)據(jù)中心,根據(jù)地理位置我們把某個(gè)地區(qū)的基礎(chǔ)設(shè)施服務(wù)集合稱為一個(gè)區(qū)域。通過(guò)AWS的區(qū)域,一方面可以使得AWS云服務(wù)在地理位置上更加靠近我們的用戶,另一方面使得用戶可以選擇不同的區(qū)域存儲(chǔ)他們的數(shù)據(jù)以滿足法規(guī)遵循方面的要求。AWS的不同區(qū)域之間是相對(duì)獨(dú)立的,但是它們的獨(dú)立程度與區(qū)域的類別有關(guān)。根據(jù)目前10個(gè)區(qū)域的各自特點(diǎn)我們可以把它們分成3個(gè)不同的類別。

· 第一類是GovCloud區(qū)域,主要是服務(wù)美國(guó)的政府機(jī)構(gòu)和部分美國(guó)客戶。

· 第二類是中國(guó)區(qū)域,這也是一個(gè)與其他區(qū)域獨(dú)立的專門服務(wù)中國(guó)客戶的區(qū)域。

· 最后一類的是目前其他8個(gè)區(qū)域。這8個(gè)區(qū)域是面向所有用戶的,且共享同一個(gè)賬戶體系,所以用戶注冊(cè)AWS賬戶后可以使用所有這8個(gè)區(qū)域的服務(wù)。

對(duì)于那些需要同時(shí)使用AWS這8個(gè)區(qū)域和AWS中國(guó)區(qū)域的用戶來(lái)說(shuō),他們同時(shí)需要兩個(gè)賬戶——一個(gè)在中國(guó)的區(qū)域使用,另一個(gè)在其他8個(gè)區(qū)域使用。

A region is an area geographically that has redundancy within it, through at least two availability zones. Each AZ is separate from other AZs and each is in essence a virtual data center. A region contains virtual data centers; it is not itself a virtual data center.

AWS的每個(gè)區(qū)域一般由多個(gè)可用區(qū)(AZ)組成,而一個(gè)可用區(qū)一般是由多個(gè)數(shù)據(jù)中心組成。AWS引入可用區(qū)設(shè)計(jì)主要是為了提升用戶應(yīng)用程序的高可用性。因?yàn)榭捎脜^(qū)與可用區(qū)之間在設(shè)計(jì)上是相互獨(dú)立的,也就是說(shuō)它們會(huì)有獨(dú)立的供電、獨(dú)立的網(wǎng)絡(luò)等,這樣假如一個(gè)可用區(qū)出現(xiàn)問(wèn)題時(shí)也不會(huì)影響另外的可用區(qū)。在一個(gè)區(qū)域內(nèi),可用區(qū)與可用區(qū)之間是通過(guò)高速網(wǎng)絡(luò)連接,從而保證有很低的延時(shí)。

VPC的組成部分:

· Virtual Private Cloud:AWS 云中邏輯隔離的虛擬網(wǎng)絡(luò)。從所選范圍內(nèi)定義 VPC 的 IP 地址空間。

· 子網(wǎng) subnet:VPC 的 IP 地址范圍內(nèi)的一個(gè)區(qū)段,其中可放置隔離的資源組。

· 互聯(lián)網(wǎng)網(wǎng)關(guān)IGW:公有 Internet 連接的 Amazon VPC 端。

· NAT 網(wǎng)關(guān):一款高度可用的托管網(wǎng)絡(luò)地址轉(zhuǎn)換 (NAT) 服務(wù),便于私有子網(wǎng)中的資源訪問(wèn)互聯(lián)網(wǎng)。

· 虛擬私有網(wǎng)關(guān)Virtual Private gateway VGW:VPN 連接的 Amazon VPC 端。

· 對(duì)等連接 VPC Peering:對(duì)等連接使您可以通過(guò)私有 IP 地址在兩個(gè)對(duì)等 VPC 之間路由流量。

· VPC 終端節(jié)點(diǎn) endpoint:支持建立從您的 VPC 到 AWS 中托管的服務(wù)的私有連接,無(wú)需使用互聯(lián)網(wǎng)網(wǎng)關(guān)、VPN、網(wǎng)絡(luò)地址轉(zhuǎn)換 (NAT) 設(shè)備或防火墻代理。

· 僅傳出互聯(lián)網(wǎng)網(wǎng)關(guān)Egress Only Internet Gateways:有狀態(tài)網(wǎng)關(guān),僅提供從 VPC 到 Internet 的 IPv6 流量傳出訪問(wèn)權(quán)限。

3.2 VPC network

對(duì)于VPC的網(wǎng)絡(luò)劃分,這里將引入子網(wǎng)(subnet)的概念。在一個(gè)可用區(qū)中,可以包含200個(gè)子網(wǎng),而一個(gè)子網(wǎng)只能屬于一個(gè)可用區(qū)。也就是說(shuō),子網(wǎng)與可用區(qū)是一對(duì)一 的,而可用區(qū)與子網(wǎng)是一對(duì)多的關(guān)系。開通aws賬號(hào),會(huì)默認(rèn)在每個(gè)區(qū)域(3類)都創(chuàng)建一個(gè)default VPC,VPC可以跨同一區(qū)域的可用區(qū)。例如,在區(qū)域us-east-1中創(chuàng)建一個(gè)VPC,該區(qū)域中的所有可用區(qū)都能被VPC 選擇使用。subnets can communicate with each other across availability zones by default.

Figure 6 VPC and subnet

所有子網(wǎng),可以根據(jù)配置,分為公有子網(wǎng)和私有子網(wǎng)。 所謂公有子網(wǎng), 是一個(gè)對(duì)世界開放的子網(wǎng),只要公共子網(wǎng)有一個(gè)互聯(lián)網(wǎng)網(wǎng)關(guān)(IGWà通過(guò)配置路由表來(lái)實(shí)現(xiàn)連接,那么公共子網(wǎng)中的任何主機(jī)實(shí)例都可以被訪問(wèn);而私有子網(wǎng)則無(wú)此配置,只能在內(nèi)部網(wǎng)絡(luò)中使用,無(wú)法通過(guò)互聯(lián)網(wǎng)訪問(wèn),實(shí)例/主機(jī)只能在私有子網(wǎng)內(nèi)互相通信。如果將IGW附加到私有子網(wǎng),它將成為公共子網(wǎng)。一個(gè)私有子網(wǎng)將沒(méi)有IGW,因此他們使用Bastion和NAT連接到互聯(lián)網(wǎng)。

Exam tips:

· Egress-only internet gateways are stateful and support IPv6 traffic.

· An egress-only gateway is for use with IPv6 traffic and only allows outbound traffic.

· Egress always has a cost associated with it, while ingress is always free.

· Transferring data across regions is treated the same as transfers to the Internet. Only inter-AZ data transfer is guaranteed to be costless

3.3 Create VPC

這里首先介紹新創(chuàng)建的VPC將會(huì)獲得什么樣的配置,然后將其和default VPC做對(duì)比。新建VPC, 你需要指定:

· Name tagà Creates a tag with a key of 'Name' and a value that you specify.

· IPv4 CIDR BlockàThe range of IPv4 addresses for your VPC in CIDR block format, for example, 10.0.0.0/24. Block sizes must be between a /16 netmask and /28 netmask. IPv6 CIDR Block是可選的,VPC中可以沒(méi)有IPv6地址段。

· The default VPC has a CIDR block of /16, but the default subnet in each AZ is a /20.

· There is no default CIDR block for custom VPCs, custom VPCs must have this entered in.

· 5 VPCs are allowed per region, per account, unless you contact AWS to raise this default limit.

· This limit is your primary CIDR block and then, in addition, 4 secondary CIDR blocks, totally 5 CIDR blocks.

Figure 7 Create custom VPC

對(duì)比新建一個(gè)VPC之后,可以看出,后者不只是多出一個(gè)VPC,同時(shí)還多了一個(gè)route table, Network ACLs and Security group. 這里是沒(méi)有新增internet 網(wǎng)關(guān)的,也就是說(shuō),默認(rèn)情況下,custom VPC都是私有的, 而default VPC是公有的。

Figure 8 Compare VPC

Exam tips:

· All VPCs have NACLs, security groups, and route tables automatically created.

· However, only the default VPC has a default subnet and an internet gateway created as well.

· A VPC cannot be changed from dedicated hosting tenancy to default hosting. You have to re-create the VPC.

3.4 VPC Peering

AWS 使用現(xiàn)有 VPC 基礎(chǔ)設(shè)施創(chuàng)建 VPC 對(duì)等連接,既不是網(wǎng)關(guān),也不是 VPN 連接,因此不依賴某個(gè)獨(dú)立的實(shí)體硬件。不會(huì)發(fā)生單點(diǎn)通信故障或帶寬瓶頸。區(qū)域間 VPC 對(duì)等連接采用當(dāng)前支持 VPC 的橫向擴(kuò)展、冗余且高度可用的技術(shù)。區(qū)域間 VPC 對(duì)等連接流量經(jīng)過(guò)具有內(nèi)置冗余和動(dòng)態(tài)帶寬分配的 AWS 骨干網(wǎng)。如果區(qū)域間對(duì)等連接出現(xiàn)故障,流量將不會(huì)通過(guò) Internet 路由。

VPC Peering的功能特點(diǎn)

· 私有地使用AWS 網(wǎng)絡(luò)連接兩個(gè)VPC

· VPC建立對(duì)等連接后,就如同在一個(gè)網(wǎng)絡(luò)中

· 必須確保沒(méi)有重疊的CIDR

· VPC Peering不能轉(zhuǎn)移,即A?àB?à C, 不等同于A?à C

· 可以和其他賬戶的VPC建立對(duì)等連接

· 必須在每個(gè)VPC 子網(wǎng)中更新路由表,確保實(shí)例間可以正常通信

Figure 9 VPC Peering

VPC Peering 動(dòng)手實(shí)驗(yàn)

Figure 10 VPC Peering hands on

Exam tips:

· AWS calls a connection between two VPCs via peering across regions an inter-region VPC peering connection.

· AWS does not support IPv6 inter-region communication.

· EC2-Classic was a flat network that offered very little in the way of multiple options. With VPCs, you can assign multiple IP addresses as well as multiple network interfaces

3.5 Endpoints and Flow logs

3.5.1 Endpoints

Endpoints是虛擬設(shè)備,它們是可以水平伸縮的、冗余的、高可用的VPC組件,允許VPC中的實(shí)例與服務(wù)之間進(jìn)行通信,而不會(huì)對(duì)網(wǎng)絡(luò)流量造成可用性風(fēng)險(xiǎn)或帶寬限制。

VPC endpoints允許你將自己的VPC 私有地連接到受支持的AWS 服務(wù)和由PrivateLink提供支持的VPC 端點(diǎn)服務(wù),而不需要Internet網(wǎng)關(guān)、NAT 設(shè)備、VPN 連接或AWS Direct連接(云專線)。VPC中的實(shí)例不需要公網(wǎng)IP來(lái)與服務(wù)中的資源進(jìn)行通信,你的VPC和其他服務(wù)之間的流量不會(huì)離開Amazon網(wǎng)絡(luò)。

A VPC endpoint provides a connection over the Amazon network between your VPC and a service, such as S3. This avoids leaving the network and routing over the public Internet, which inherently provides greater security for the traffic involved; endpoint is a private connection outside of these constructs altogether, which is part of why it is an attractive solution for internal AWS communication. VPC and endpoints must in same region.

這里有兩種類型的VPC endpoints:

· Interface endpoint

· Gateway endpoint

§ 當(dāng)前支持Amazon S3 和DynamoDB

Interface endpoint是一個(gè)具有私有IP的彈性網(wǎng)絡(luò)接口,該私有IP 用作指向受支持服務(wù)的流量的入口點(diǎn),支持以下服務(wù):

Figure 11 Supported services by Interface endpoint

針對(duì)于gateway endpoint和S3之間的動(dòng)手實(shí)驗(yàn):

Figure 12 Gateway endpoint lab

Exam tips:

· An internet gateway is required to handle Internet traffic, and a VPC endpoint is ideal for connecting the instances to S3.

· An elastic network interface is virtual and can have multiple IPv4 and IPv6 addresses as well as security groups, a MAC address, and a source/destination check flag.

· An instance has a primary network interface in all cases but can have additional network interfaces attached

· Traffic follows the network interface rather than sticking to any particular instance.

· An elastic network interface can only be attached to a single instance at one time but can be moved from one instance to another.

· An instance’s primary network interface cannot be detached. You can detach secondary interfaces, attach multiple interfaces, and move network interfaces.

3.5.2 Flow logs

Flow logs是為了捕獲關(guān)于進(jìn)入接口的IP流量信息,分為一下三類

· VPC flow logs

· Subnet flow logs

· ENI flow logs

Flow logs 的功能特性:

· 幫助監(jiān)視和排除連接問(wèn)題

· 可以轉(zhuǎn)到S3 / CloudWatch logs

· 從AWS管理的接口捕獲網(wǎng)絡(luò)信息 :ELB, RDS, ElastiCache, Redshift, WorkSpaces

· 除非 peer VPC在你的賬戶中,否則無(wú)法為與你的VPC 建立對(duì)等連接的VPC啟用 Flow logs

· 不能標(biāo)記 Flow log

· 創(chuàng)建 flow log后,不能更改配置,例如不能將不同的IAM role與之關(guān)聯(lián)

· 不是所有的IP 流量都受到監(jiān)控

§ 實(shí)例與Amazon DNS服務(wù)器聯(lián)系時(shí)產(chǎn)生的流量。如果你使用自己的DNS 服務(wù)器,則會(huì)記錄到該服務(wù)器的所有流量

§ 由一個(gè)用于Amazon windows license激活的windows 實(shí)例

§ 用于實(shí)例元數(shù)據(jù)的169.254.169.254來(lái)回的流量

§ DHCP 流量

§ 傳輸?shù)侥J(rèn)VPC路由器的保留IP地址

3.6 VPN and Direct connect

3.6.1 VPN

虛擬專用網(wǎng)絡(luò)(VPN)的功能是:在公用網(wǎng)絡(luò)上建立專用網(wǎng)絡(luò),進(jìn)行加密通訊。在企業(yè)網(wǎng)絡(luò)中有廣泛應(yīng)用。VPN網(wǎng)關(guān)通過(guò)對(duì)數(shù)據(jù)包的加密和數(shù)據(jù)包目標(biāo)地址的轉(zhuǎn)換實(shí)現(xiàn)遠(yuǎn)程訪問(wèn)。VPN可通過(guò)服務(wù)器、硬件、軟件等多種方式實(shí)現(xiàn)

Site-to-Site VPN 的組成部分

· 虛擬專用網(wǎng)關(guān)--是 Site-to-Site VPN 連接在 Amazon 一端的 VPN 集線器。您可以創(chuàng)建虛擬專用網(wǎng)關(guān),并將其附加到要從中創(chuàng)建 Site-to-Site VPN 連接的 VPC。

· AWS Transit Gateway--中轉(zhuǎn)網(wǎng)關(guān) 是一個(gè)中轉(zhuǎn)中心,您可用它來(lái)互連 Virtual Private Cloud (VPC) 和本地網(wǎng)絡(luò)。

· 客戶網(wǎng)關(guān)--是指 Site-to-Site VPN 連接在您這一端的實(shí)體設(shè)備或軟件應(yīng)用程序。

Figure 13 Single VPN connection

使用中轉(zhuǎn)網(wǎng)關(guān)的單一 Site-to-Site VPN 連接

Figure 14 VPN with transit gateway

如果您有多個(gè) AWS Site-to-Site VPN 連接,您可以使用 AWS VPN CloudHub 在各個(gè)站點(diǎn)之間提供安全的通信。這可使您的遠(yuǎn)程站點(diǎn)彼此進(jìn)行通信,而不只是與 VPC 進(jìn)行通信。VPN CloudHub 在簡(jiǎn)單的星型拓?fù)溥B接模型上操作,您可以在使用或不使用 VPC 的情況下操作 VPN CloudHub。這種設(shè)計(jì)適合有多間分公司和現(xiàn)有 Internet 連接的客戶,幫助他們實(shí)施方便、潛在低成本的星型拓?fù)溥B接模型,以便在這些遠(yuǎn)程辦公室之間建立主要或備用連接。

Figure 15 VPN CloudHub architecture

要使用 AWS VPN CloudHub,必須創(chuàng)建具有多個(gè)客戶網(wǎng)關(guān)的虛擬專用網(wǎng)關(guān)。您必須為每個(gè)客戶網(wǎng)關(guān)使用唯一的邊界網(wǎng)關(guān)協(xié)議 (BGP) 自治系統(tǒng)編號(hào) (ASN)。客戶網(wǎng)關(guān)可通過(guò)它們的 Site-to-Site VPN 連接傳播適當(dāng)?shù)穆酚桑˙GP 前綴)。路由通告會(huì)被每個(gè) BGP 對(duì)等體接收并重新通告,使每個(gè)站點(diǎn)都可以向其他站點(diǎn)發(fā)送或接受數(shù)據(jù)。站點(diǎn)的 IP 范圍不得重疊。每個(gè)站點(diǎn)還可以發(fā)送和從 VPC 接收數(shù)據(jù)(與使用標(biāo)準(zhǔn) Site-to-Site VPN 連接的方式相同)。

3.6.2 Direct connect

AWS Direct Connect ,也叫云專線,通過(guò)標(biāo)準(zhǔn)的以太網(wǎng)光纖電纜將您的內(nèi)部網(wǎng)絡(luò)鏈接到 AWS Direct Connect 位置。電纜的一端接到您的路由器,另一端接到 AWS Direct Connect 路由器。有了此連接以后,您就可以創(chuàng)建直接連接到公有 AWS 服務(wù)(如 Amazon S3)或 Amazon VPC 的虛擬接口,從而繞過(guò)您的網(wǎng)絡(luò)路徑中的 Internet 服務(wù)提供商。AWS Direct Connect 位置在其關(guān)聯(lián)的區(qū)域提供對(duì) AWS 的訪問(wèn)權(quán)限。您可以使用公有區(qū)域或 AWS GovCloud (US) 中的單個(gè)連接訪問(wèn)所有其他公有區(qū)域中的公有 AWS 服務(wù)。

AWS Direct Connect是一種網(wǎng)絡(luò)服務(wù),提供了一個(gè)使用 Internet 將客戶的本地站點(diǎn)連接到 AWS 的替代解決方案。使用 AWS Direct Connect ,以前通過(guò) Internet 傳輸?shù)臄?shù)據(jù)現(xiàn)在可以借助 AWS 和您的數(shù)據(jù)中心或公司網(wǎng)絡(luò)之間的私有網(wǎng)絡(luò)連接進(jìn)行傳輸。許多情況下,私有網(wǎng)絡(luò)連接可以降低成本、增加帶寬,提供比基于 Internet 的連接更為一致的網(wǎng)絡(luò)體驗(yàn)。

以下是您用于 AWS Direct Connect 的關(guān)鍵組件:

· 連接-- 在 AWS Direct Connect 位置創(chuàng)建連接 以建立從您的本地部署到 AWS 區(qū)域的網(wǎng)絡(luò)連接。

· 虛擬接口-- 創(chuàng)建虛擬接口以啟用對(duì) AWS 服務(wù)的訪問(wèn)。公有虛擬接口允許對(duì)公有服務(wù)的訪問(wèn),如 Amazon S3。私有虛擬接口允許對(duì)您 VPC 的訪問(wèn)

Figure 16 Direct connect

AWS Direct Connect相對(duì)于VPN的聯(lián)網(wǎng)方式,具有更高的安全性,低延遲以及穩(wěn)定性,它還有以下這個(gè)特點(diǎn):

  • 專線,提供到AWS骨干網(wǎng)的私有連接線路
  • 能夠創(chuàng)建到AWS的私有接口或公有接口
  • 減少出口帶寬的開銷(入向帶寬免費(fèi))
  • 始終如一的網(wǎng)絡(luò)性能
  • 冗余連接的可選擇性
  • 可以在多個(gè)AWS區(qū)域中使用
  • 多個(gè)AWS賬號(hào)可以共享同一個(gè)DX線路
  • 使用BGP (Border Gateway Protocol 邊界網(wǎng)關(guān)協(xié)議) 來(lái)交換路由
  • 通過(guò)HIPPA法案
3.6.3 Direct connect vs VPN

Type

Direct connect

VPN

Expense

昂貴的設(shè)置和需要時(shí)間配置

便宜和立即

Connection

專用私人連接

Internet

Cost

減少數(shù)據(jù)傳輸成本

互聯(lián)網(wǎng)數(shù)據(jù)傳輸成本

Consistent

一致的性能

互聯(lián)網(wǎng)固有的可變性

Redundancy

不提供冗余

提供冗余

Table 1 Direct connect vs VPN

3.7 NAT and Bastion host

3.7.1 NAT concept

首先闡述NAT 的概念,NAT—Network Address Translation,即是網(wǎng)絡(luò)地址轉(zhuǎn)換之意,就是替換IP報(bào)文頭部的地址信息。NAT通常部署在公有子網(wǎng)中,通過(guò)將內(nèi)部網(wǎng)絡(luò)IP地址替換為出口的IP地址提供公網(wǎng)可達(dá)性和上層協(xié)議的連接能力。使用NAT的目的,是節(jié)約公網(wǎng)IPv4地址,當(dāng)前公網(wǎng)IPv4地址是稀缺的,如果有大量的私有主機(jī)有Internet訪問(wèn)需求,則NAT是最佳解決方案。在aws cloud 上,實(shí)現(xiàn)NAT 有兩種方式,即NAT instance 和NAT gateway,接下來(lái)將介紹二者的區(qū)別聯(lián)系。

3.7.2 NAT instance vs NAT gateway

NAT instance, 創(chuàng)建時(shí),需要獲取一個(gè)社區(qū)版的NAT AMI, 生成并啟動(dòng)實(shí)例后,在實(shí)例網(wǎng)絡(luò)設(shè)置啟用disable Source/destination check,這是由于destination本身就不唯一,編輯route table,允許internet訪問(wèn)NAT instance。私網(wǎng)中也必須增加一條路由,使其關(guān)聯(lián)到NAT instance,NAT instance 能支持的流量取決于實(shí)例的大小,如果使用中遇到瓶頸,請(qǐng)考慮增加 instance size。你可以對(duì)實(shí)例創(chuàng)建高可用的自動(dòng)伸縮組,在不同的AZ分別創(chuàng)建NAT 實(shí)例,實(shí)現(xiàn)容災(zāi)。

Figure 24 NAT instance

NAT gateway,這是完全托管在aws的服務(wù),你不需要維護(hù)其可用性,default情況下,NAT gateway就是高可用的。創(chuàng)建NAT gateway 時(shí),需要關(guān)聯(lián)一個(gè)EIP—Elastic IP address, 這里需要注意的是EIP是收費(fèi)的,為了考試而創(chuàng)建的免費(fèi)賬號(hào),使用EIP時(shí)需慎重,不用時(shí)及時(shí)釋放掉,不然aws會(huì)按照你所占有該EIP的時(shí)間來(lái)收取費(fèi)用,不管這期間你有沒(méi)有使用到此功能。

Figure 25 NAT gateway

NAT instance和 NAT gateway區(qū)別聯(lián)系:

屬性

NAT gateway

NAT instance

可用性

高度可用。每個(gè)可用區(qū)中的 NAT 網(wǎng)關(guān)都采用冗余實(shí)施。在每個(gè)可用區(qū)中創(chuàng)建一個(gè) NAT 網(wǎng)關(guān)可確保架構(gòu)不依賴于可用區(qū)。

使用腳本管理實(shí)例之間的故障轉(zhuǎn)移。

帶寬

可以擴(kuò)展到 45 Gbps。

取決于實(shí)例類型的帶寬。

維護(hù)

由 AWS 管理。您不需要進(jìn)行任何維護(hù)。

由您管理,例如您需要對(duì)實(shí)例安裝軟件更新或操作系統(tǒng)補(bǔ)丁。

性能

軟件經(jīng)過(guò)優(yōu)化以便處理 NAT 流量。

配置來(lái)執(zhí)行 NAT 的通用 Amazon Linux AMI。

費(fèi)用

費(fèi)用取決于您使用的 NAT 網(wǎng)關(guān)的數(shù)量、使用時(shí)長(zhǎng)以及您通過(guò) NAT 網(wǎng)關(guān)發(fā)送的數(shù)據(jù)量。

費(fèi)用取決于您使用的 NAT 實(shí)例的數(shù)量、使用時(shí)長(zhǎng)以及實(shí)例類型和大小

公有 IP 地址

在創(chuàng)建時(shí)選EIP 地址與 NAT 網(wǎng)關(guān)關(guān)聯(lián)。

為 NAT 實(shí)例使用彈性 IP 地址或公有 IP 地址。您隨時(shí)可以通過(guò)將新的彈性 IP 地址與實(shí)例關(guān)聯(lián)來(lái)更改公有 IP 地址。

私有 IP 地址

在您創(chuàng)建網(wǎng)關(guān)時(shí)自動(dòng)從子網(wǎng)的 IP 地址范圍中選擇。

在您啟動(dòng)實(shí)例時(shí),從子網(wǎng)的 IP 地址范圍內(nèi)分配特定的私有 IP 地址

安全組

無(wú)法與 NAT 網(wǎng)關(guān)關(guān)聯(lián)。您可以將安全組與 NAT 網(wǎng)關(guān)之后的資源關(guān)聯(lián),以控制入站和出站流量。

與您的 NAT 實(shí)例和 NAT 實(shí)例之后的資源關(guān)聯(lián),以控制入站和出站流量。

網(wǎng)絡(luò) ACL

使用網(wǎng)絡(luò) ACL 控制進(jìn)出您的 NAT 網(wǎng)關(guān)所在子網(wǎng)的流量。

使用網(wǎng)絡(luò) ACL 控制進(jìn)出您的 NAT 實(shí)例所在子網(wǎng)的流量。

流日志

使用Flow logs捕獲流量。

使用Flow logs捕獲流量。

端口轉(zhuǎn)發(fā)

不支持.

手動(dòng)自定義配置以支持端口轉(zhuǎn)發(fā)。

堡壘服務(wù)器

不支持。

用作堡壘服務(wù)器

IP 分段

支持轉(zhuǎn)發(fā) UDP 協(xié)議的 IP 分段數(shù)據(jù)包。

不支持 TCP 和 ICMP 協(xié)議的分段。將刪除這些協(xié)議的分段數(shù)據(jù)包。

支持重組 UDP、TCP 和 ICMP 協(xié)議的 IP 分段數(shù)據(jù)包。

Table 2 NAT comparison

Exam tips:

· Elastic IP addresses are specifically for avoiding being tied to a specific instance。

· Elastic IP addresses are, by definition, an IP address that will not change

· NAT gateway is deployed inside a subnet and it can scale only inside that subnet. For fault tolerance, it is recommended that you deploy one NAT gateway per availability zone

3.7.3 Bastion host concept

Bastion主機(jī)是位于公共子網(wǎng)內(nèi)的實(shí)例,通常使用SSH或RDP訪問(wèn)它們。

一旦使用bastion主機(jī)建立了遠(yuǎn)程連接,它就充當(dāng)一個(gè)“跳轉(zhuǎn)”服務(wù)器,允許您使用SSH或RDP登錄到網(wǎng)絡(luò)深處的其他實(shí)例(在私有子網(wǎng)中)。

Figure 26 Bastion host

在上圖中,它給出了一個(gè)想法,在為AWS基礎(chǔ)設(shè)施設(shè)計(jì)bastion主機(jī)時(shí),不應(yīng)該將其用于任何其他目的,因?yàn)檫@會(huì)打開不必要的安全漏洞。你需要盡可能地把它鎖起來(lái)。我建議您考慮加強(qiáng)所選操作系統(tǒng)的安全性。安全組對(duì)于維護(hù)嚴(yán)格的安全性至關(guān)重要,并且在解決方案工作中扮演重要角色。

Bastion hosts的功能特性:

· 可以用Bastion hosts ssh到私有實(shí)例

· Bastion hosts在可以連接到其他私有子網(wǎng)的公有子網(wǎng)中

· 必須加強(qiáng)Bastion hosts 安全組

· 確保只有來(lái)自所需IP的22端口流量,而不是來(lái)自其他實(shí)例的安全組

Bastions vs NAT

· NAT 是用于提供私有子網(wǎng)中EC2 instance路由 internet traffic

· Bastion是用于安全地管理EC2實(shí)例,使用SSH 或RDP, 也被稱作 “Jump boxes in Australia”

· A bastion 可以看作是一個(gè)NAT instance的特例

· 不能使用NAT gateway 來(lái)當(dāng)作 Bastion host.

Exam tips:

· A bastion host is a publicly accessible host that allows traffic to connect to it. Then, an additional connection is made from the bastion host into a private subnet and the hosts within that subnet.

· Because the bastion must be accessed by public clients, it must be exposed to the Internet.

· The security of the bastion must be different from the hosts in the private subnet.

· The bastion host should be hardened significantly as it is public, but also accessible; this is in many ways the opposite of the security requirements of hosts within a private subnet.

3.8 NACL and Security groups

3.8.1 NACL concept

NACL—Network Access Control List,網(wǎng)絡(luò)地址控制列表, 可以將 NACL看作是一個(gè)位于VPC內(nèi)部但位于子網(wǎng)外部的保護(hù)。它們是一個(gè)可選的安全層,您可以在VPC中使用它們來(lái)充當(dāng)防火墻。NACL由一系列規(guī)則組成,這些規(guī)則允許限制特定類型的網(wǎng)絡(luò)流量(如http、https、ssh等) 或IP范圍。您可以創(chuàng)建許多規(guī)則,這些規(guī)則首先根據(jù)最小的數(shù)字按數(shù)字順序計(jì)算。一個(gè)NACL可以被分配給多個(gè)子網(wǎng),但是你不能把一個(gè)子網(wǎng)分配給多個(gè)NACL。NACL的一個(gè)示例用例是,如果希望將對(duì)公共子網(wǎng)的訪問(wèn)限制為只訪問(wèn)一小組IP地址。

所有的vpc在默認(rèn)情況下都有一個(gè)NACL。這個(gè)特定的NACL將默認(rèn)啟用來(lái)自所有IP地址的所有流量。然而,當(dāng)您手動(dòng)創(chuàng)建一個(gè)NACL時(shí),情況正好相反。這些將在默認(rèn)情況下阻塞所有流量。

缺省網(wǎng)絡(luò)ACL:將缺省網(wǎng)絡(luò)ACL配置為允許所有流量進(jìn)出與其關(guān)聯(lián)的子網(wǎng)。每個(gè)網(wǎng)絡(luò)ACL還包含一個(gè)規(guī)則號(hào)為星號(hào)的規(guī)則。這個(gè)規(guī)則確保如果一個(gè)包不匹配任何其他編號(hào)的規(guī)則,它就被拒絕。您不能修改或刪除此規(guī)則。

以下是網(wǎng)絡(luò)ACL規(guī)則的組成部分:

· 規(guī)則數(shù):從編號(hào)最低的規(guī)則開始計(jì)算規(guī)則。只要規(guī)則與流量匹配,就會(huì)應(yīng)用它,而不管可能與之沖突的任何編號(hào)更高的規(guī)則。

· 類型:流量的類型;例如SSH。您還可以指定所有流量或自定義范圍。

· 協(xié)議:您可以指定任何具有標(biāo)準(zhǔn)協(xié)議號(hào)的協(xié)議。有關(guān)更多信息,請(qǐng)參見協(xié)議編號(hào)

· 如果指定ICMP作為協(xié)議,則可以指定任何或所有ICMP類型和代碼。

· 端口范圍:監(jiān)聽端口或通信的端口范圍。例如,HTTP流量為80。

· 來(lái)源:【入站規(guī)則】流量的來(lái)源(CIDR范圍)。

· 目的地:[僅適用于出站規(guī)則]流量的目的地(CIDR范圍)。

· 允許/拒絕:是否允許或拒絕指定的流量。

下面是一個(gè)僅支持IPv4的VPC示例缺省網(wǎng)絡(luò)ACL。

Figure 27 Default NACL configuration

3.8.2 Security Groups

AWS安全組(SG)作為VPC的各個(gè)EC2實(shí)例的防火墻。它們并不適用于它們所在的整個(gè)子網(wǎng)。創(chuàng)建實(shí)例時(shí),必須將其與安全組關(guān)聯(lián)。否則,將分配VPCs默認(rèn)的安全組。

與NACL類似,安全組由規(guī)則組成。這些規(guī)則允許并限制基于諸如流量協(xié)議(http、https、ssh等)和指定的IP范圍等內(nèi)容的流量進(jìn)入實(shí)例。您可以創(chuàng)建許多規(guī)則,這些規(guī)則首先根據(jù)最小的數(shù)字按數(shù)字順序計(jì)算。所有VPC在默認(rèn)情況下都有一個(gè)安全組。Security groups disallow all traffic unless there are specific allow rules for the traffic in the security group. Security groups evaluate all the rules on the group before deciding how to handle traffic.

3.8.3 AWS NACL vs Security group comparison

AWS的認(rèn)證經(jīng)常會(huì)對(duì)VPC的這兩個(gè)特性進(jìn)行比較。這可能是因?yàn)榘踩M與NACL類似。然而,它們有一些關(guān)鍵的區(qū)別,我將在本節(jié)中強(qiáng)調(diào)這些區(qū)別。

Table 3 Security group and NACL comparison

· 安全組在EC2實(shí)例級(jí)起作用;NACL在子網(wǎng)級(jí)起作用。這是最明顯的區(qū)別,很可能在考試中被提到。

· NACL允許分別為入站和出站流量定義allow/deny規(guī)則;安全組只能定義應(yīng)用于入站和出站的allow規(guī)則,你不能為一個(gè)規(guī)則定義不同的行為。

· 安全組是有狀態(tài)的, 任何允許流入的東西都會(huì)自動(dòng)允許流出;而NACL是無(wú)狀態(tài)的,這意味著NACL必須允許返回流量。例如,您需要一個(gè)入站規(guī)則和一個(gè)出站規(guī)則。

· 缺省情況,SG的outbound rule是允許所有流量流出, 如果刪除此規(guī)則,則從instance 主動(dòng)發(fā)起的流出請(qǐng)求將被拒絕, 而流入的流量仍然允許流出。

· NACL規(guī)則按數(shù)值順序計(jì)算。SG在決定是否允許通信流進(jìn)入實(shí)例之前,將處理所有安全組規(guī)則。

· 最后,NACL規(guī)則適用于子網(wǎng)中的所有實(shí)例。因此,如果流量在NACL級(jí)別被阻塞,但在實(shí)例級(jí)別被允許。它永遠(yuǎn)不會(huì)到達(dá)實(shí)例,因?yàn)樗趹?yīng)用安全組規(guī)則之前就被阻塞了。

Figure 28 Inbound rules comparison

Figure 29 Outbound rules comparison

Exap tips:

· A NACL is best for dealing with all traffic at a subnet or VPC level, as it is associated at the subnet level.

· Anytime you are protecting or limiting traffic to or from specific instances, a security group is your best choice. Security groups are associated with specific instances, so they can effectively limit traffic to some instances while allowing other instances—using different security groups—to still be accessible.

· NACL rules have a rule number, a protocol, a choice of ALLOW or DENY, and a CIDR range and port or port range for inbound and outbound traffic.

· Default security groups prevent all traffic in and allow all traffic out.

· without specific outbound rules, nothing is allowed to flow out. (Note that by default, there is an allowance for all outgoing traffic in security groups, although that can be removed.)

· whether an incoming connection automatically can get back out. Security groups are stateful

· A security group can be attached to multiple constructs, like an EC2 instance, but is ultimately associated with a network interface, which in turn is attached to individual instances.

· A security group can actually have no inbound or outbound rules, so A and D are not required. A security group does require a name and description, though.

4 EC2

4.1 EC2 concept

Amazon Elastic Compute Cloud (Amazon EC2) 是一種 Web 服務(wù),在云中提供大小可調(diào)的計(jì)算容量。該服務(wù)旨在讓開發(fā)人員能更輕松地進(jìn)行 Web 級(jí)的計(jì)算。All EC2 instances in the default VPC have both a public and private IP address. They do not have an elastic IP address, and the security group that is created by default does not allow any inbound traffic (until changed manually)

4.2 EC2 instance type

按需實(shí)例(On-Demand Instances ) 按秒為啟動(dòng)的實(shí)例付費(fèi)。

· Applications with spiky workloads are reasons to use on-demand, as on-demand can scale up and down quickly

· on-demand instances are best for users with no initial payment ability

· On-demand instances are ideal for any usage that swings wildly in unpredictable patterns, particularly if a job cannot be halted

· Anytime you’re testing a new application, on-demand is a good choice

預(yù)留實(shí)例 (Reserved Instances)以大幅折扣購(gòu)買一年期到三年期的始終可用的實(shí)例。

· Reserved instances can be paid for in no up-front, partial up-front, and all up-front models, where all up-front is the least expensive and no up-front is the most expensive.

· steady-state usage is ideal for reserved instances

· Steady-state usage is also a use case for reserved instances, to gain cost savings

· If usage is predictable, a long-running job might benefit from a reserved instance

· Reserved instances are locked to the region in which they are created

· AWS suggests using reserved instance pricing in TCO calculations, as it is closest to on-premises servers in an apples-to-apples comparison

· Standard reserved instances often provide up to a 75% discount as compared to on-demand instances.

Spot 實(shí)例 (Spot Instances)請(qǐng)求未使用的 EC2 實(shí)例,這可能會(huì)顯著降低您的 Amazon EC2 成本。

· Spot instances offer you significant costs savings as long as you have flexibility and application processes can be stopped and started.

· Spot instances via the spot market are the potentially least expensive option, given that your compute has flexible timing and needs

· Spot instances also make heavy compute affordable when it would not be on other instance types

· Large and immediate additional capacity needs are best facilitated by spot instances

· spot market is where you purchase spot instances, the spot market provides instances that can stop and start at any time;

· Spot instances are recommended for applications with flexible start and end times, that need to run with low compute prices, or that may have urgent compute needs for large amounts of additional capacity

· If the job can be stopped, then spot instances would be better.

Exam tips:

· Dedicated hosts can be purchased as an on-demand instance or as a reservation for significant savings

· On-demand instances are ideal for any usage that swings wildly in unpredictable patterns, particularly if a job cannot be halted. If usage is predictable, a long-running job might benefit from a reserved instance, and if the job can be stopped, then spot instances would be better.

4.3 Launch new EC2 instance

新建EC2實(shí)例,需要考慮VPC, 可用區(qū)(包含子網(wǎng)),安全組及放置組(placement group)。 如過(guò)EC2用于存儲(chǔ),不需要對(duì)外部網(wǎng)絡(luò)提供服務(wù),則應(yīng)考慮將其放在私有網(wǎng)絡(luò)中,而如果需要對(duì)外提供服務(wù),如web服務(wù),則要考慮放置在公有子網(wǎng)中。如果考慮網(wǎng)絡(luò)延遲,則需要將一組同質(zhì)的EC2 實(shí)例放置一個(gè)Placement group。

這里引出一個(gè)新的概念—Placement group,即單個(gè)可用區(qū)域內(nèi)實(shí)例的邏輯分組。使用放置組時(shí)應(yīng)用程序能夠參與低延遲、10 Gbps的網(wǎng)絡(luò),放置組不能跨越多個(gè)可用區(qū)域。Cluster placement groups (the default type of placement group) must be made up of instances that exist within a single availability zone

Spread Placement group-- 分散放置組有助于降低集群或?qū)嵗M中失敗的可能性。Amazon EC2擁有集群放置組,這使應(yīng)用程序能夠獲得許多HPC應(yīng)用程序典型的緊密耦合節(jié)點(diǎn)到節(jié)點(diǎn)通信所需的低延遲網(wǎng)絡(luò)性能?,F(xiàn)在,使用分散的放置組,成員實(shí)例將放置在不同的硬件上,從而減少了硬件故障對(duì)應(yīng)用程序的影響。分散放置組能跨越多個(gè)可用區(qū)域,一個(gè)組內(nèi)的單個(gè)AZ內(nèi)最多有7個(gè)EC2實(shí)例。

A placement group is concerned primarily with network throughput and reducing latency among EC2 instances within a single availability zone. AWS does support a placement group spanning multiple AZs via spread placement groups, but unless “spread” is specifically mentioned, you should assume the question references a “normal” (or “cluster”) placement group.

比較Placement group和Spread Placement group

· Placement groups are typically in a single availability zone, but now spread placement groups can be placed across availability zones.

· A spread placement group can have a maximum of seven running instances per AZ.

· Spread placement groups primarily offer reduced network lag between instances

· Spread placement groups cannot be set up across regions

· You must specify the distinct underlying hardware for spread placement groups

對(duì)于公網(wǎng)和私網(wǎng)的區(qū)分,則是以能否正常訪問(wèn)internet為關(guān)鍵點(diǎn)。公網(wǎng)中的EC2 實(shí)例,可以自動(dòng)獲取公網(wǎng)IP,能正常訪問(wèn)internet。而私網(wǎng)的EC2實(shí)例,則不能分配到公網(wǎng)IP,如需訪問(wèn)internet,則需要借助于公網(wǎng)中的NAT 服務(wù),如NAT 實(shí)例或NAT 網(wǎng)關(guān)。

新建EC2 實(shí)例,需要指定AMI,獲取AMI的渠道,有以下三種:自己創(chuàng)建AMI、通過(guò)aws marketplace購(gòu)買、還有是社區(qū)版AMI, 這里將包含免費(fèi)的AMI.在SAA 備考階段,使用免費(fèi)的AMI即可。For all new AWS accounts, 20 instances are allowed per region. However, you can increase this limit by requesting it via AWS support.

Figure 17 AMI channel

EC2 需要指定VPC 和subnet,如果創(chuàng)立在default VPC 中,這兩項(xiàng)都可以選默認(rèn)配置。如果指定在custom VPC中,則需要提前創(chuàng)建subnet。默認(rèn)情況下,新建的VPC中沒(méi)有subnet。

Figure 18 Put ec2 into a VPC and subnet

如果是上圖中的情況,可以單擊 Create new subnet進(jìn)入創(chuàng)建subnet頁(yè)面。如下頁(yè)面,需要指定 VPC和AZ, 同時(shí)要定義CIDR 塊,此CIDR 必須隸屬于VPC的CIDR。如果定義該subnet 為public,則需要對(duì)此子網(wǎng)Enable auto-assign public IPv4 address,同時(shí)還需要配置路由表,使其關(guān)聯(lián)到IGW (Internet gateway)。而由于custom VPC 中不包含IGW,這兒仍然需要新建一個(gè)IGW, 并attach到 custom VPC.

Figure 19 Create subnet

配置路由表,增加一條路由記錄, 使IGW 可以訪問(wèn)internet。

Figure 20 Config route table

可以高級(jí)配置中預(yù)寫入腳本,讓實(shí)例啟動(dòng)時(shí),自動(dòng)安裝服務(wù),

Figure 21 Advanced details

將實(shí)例關(guān)聯(lián)到security group,可以選擇VPC中默認(rèn)創(chuàng)建的security group,也可以新建一個(gè)security group,并自定義inbound規(guī)則。這里需要在security group 的inbound中增加SSH 協(xié)議,允許 0.0.0.0/0訪問(wèn),不然則無(wú)法遠(yuǎn)程連接到實(shí)例。接下來(lái)需要選擇已存在的key pair或生成新的key pair, 用于連接到EC2實(shí)例。實(shí)例啟動(dòng)成功后,會(huì)自動(dòng)分配一個(gè)公網(wǎng)IP,但由于此IP 是通過(guò)DHCP 動(dòng)態(tài)分配,如果通過(guò)console reboot 實(shí)例,則該公網(wǎng)IP 會(huì)重新回到地址池而獲取到一個(gè)新的IP,通過(guò)CLI reboot,則公網(wǎng)IP可以被保持。

檢查實(shí)例是否有Internet連接,可以在登錄實(shí)例后,通過(guò)命令curl or dig任意網(wǎng)絡(luò)主機(jī)。

如果啟動(dòng)的實(shí)例在私網(wǎng)中,則只能通過(guò)公網(wǎng)中的實(shí)例ssh 遠(yuǎn)程登錄,或者使用bastion host,無(wú)法從internet上的任意主機(jī)直接登錄。私網(wǎng)中的實(shí)例也沒(méi)有正常的網(wǎng)絡(luò)訪問(wèn)權(quán)限,如果需要網(wǎng)絡(luò)訪問(wèn),需要配置 NAT 實(shí)例或NAT gateway。

4.4 EC2 summary

placement group

Amazon Instance Store/EBS-backed instance

security

· EC2 Key Pairs

· Security Groups

· Connection Tracking

· IAM Role

Tags

· billing Allocation report

· Restriction

· Maximum tags 10

· Maximum key length – 128 Unicode characters in UTF-8

· Maximum value length – 256 Unicode characters in UTF-8

Show

· keyName = value1|value2|value3 or keyName = key1|value1;key2|value2

5 EBS and EFS

EBS-- Elastic Block Store和EFS-- Elastic File System 都提供存儲(chǔ)服務(wù),而對(duì)適當(dāng)?shù)拇鎯?chǔ)選項(xiàng)如何做出決策。我們將比較彈性塊存儲(chǔ)(EBS)和彈性文件系統(tǒng)(EFS)這兩種非常流行的存儲(chǔ)選項(xiàng),以確定哪種存儲(chǔ)方式最適合哪種情況。

5.1 EBS concept

AWS EBS是一個(gè)塊存儲(chǔ)服務(wù),專門用于EC2實(shí)例。它為許多用例提供了高性能選項(xiàng),并且可以用于各種數(shù)據(jù)庫(kù)(關(guān)系數(shù)據(jù)庫(kù)和非關(guān)系數(shù)據(jù)庫(kù))、廣泛的應(yīng)用程序和大數(shù)據(jù)分析。

EBS通過(guò)提供卷來(lái)工作,這些卷是小型網(wǎng)絡(luò)附加塊的集合,您可以將它們視為“磁盤”。卷有不同的類型,無(wú)論您需要最好的性能,需要個(gè)位數(shù)的毫秒延遲,還是您只是在尋找高吞吐量,都有一個(gè)EBS卷可以滿足您的需求。

注意,彈性塊存儲(chǔ)卷獨(dú)立于EC2實(shí)例,可以在任何時(shí)候進(jìn)行附加和分離。當(dāng)它們被掛載時(shí),可以用作任何其他塊存儲(chǔ)。我們的塊存儲(chǔ)系列引入了EBS塊級(jí)存儲(chǔ),并深入研究了兩個(gè)主要塊存儲(chǔ)類別:ssd支持的卷和hdd支持的卷。目前,EBS提供了四種卷類型。

· AWS EBS General Purpose SSD (gp2): A balanced volume type

§ Uses: boot volumes, small or medium database, dev or test env

· Provisioned IOPS SSD (io1): A volume designed for latency-sensitive transactional workloads

§ Uses: boot volumes, critical business application, large db : Cassandra, MongoDB, SQL Sever, Oracle, PostgreSQL, MySQL

· Throughput Optimized HDD (st1): A low-cost volume for frequently accessed and throughput intensive workloads

§ Uses: Big data, Data warehouse, Log processing

· Cold HDD (sc1): A lowest-cost volume for less frequently accessed data

§ Uses: Inexpensive storage, ideal for infrequently accessed sequential workloads

Exam tips:

· HDD types are not available to use as boot volumes.

· An SSD volume is best for transactional workloads with a large number of small I/O sized read/write operations.

· An HDD-backed volume is best for streaming workloads where throughput needs to be maximized over IOPS.

· EBS volumes can be encrypted when they are created.

· There are four types of data encrypted when an EBS volume is encrypted:

§ data at rest on the volume,

§ data moving between the volume and the instance,

§ any snapshots created from the volume,

§ any volumes created from those snapshots.

· If you have a larger database workload, provisioned IOPS SSD is ideal.

· EBS does not offer lifecycle management

· Default behavior is EBS will stop I/O to the volume if it detects potential data inconsistencies in the volume. This is to prevent data corruption. Volume status check would report this condition as Impaired.

· There are couple of ways in which you change the encryption keys associated with an EBS volume: Change the key during snapshot copy process. Another option is: from an EC2 instance, mount a new EBS volume with the desired key and copy data from old volume to new volume

EBS是網(wǎng)絡(luò)驅(qū)動(dòng)的,通過(guò)網(wǎng)絡(luò)來(lái)和EC2實(shí)例通訊,也就意味著這兒可能會(huì)有延遲。它可以從ec2實(shí)例中分離出來(lái),并快速地附加到另一個(gè)實(shí)例上。EBS卷被設(shè)計(jì)為非常持久的,并且在可用區(qū)(AZ)內(nèi)復(fù)制它們。然而,這意味著它們被限制在一個(gè)AZ中,因此您不能移動(dòng)一個(gè)卷,除非您創(chuàng)建它的快照并在其他地方重新創(chuàng)建它。只有GP2和IO1可以用做boot 卷。

By default, EBS root volumes are terminated when the associated instance is terminated. and by default, additional EBS volumes attached to an instance are not. However, this is only the default value,these settings can be changed! You can use the AWS CLI (or the console) to set the root volume to persist after instance termination.

Officially, instances can have up to 28 attachments. One of those attachments is the network interface attachment, leaving 27 attachments available for EBS volumes. However, the better approach is to remember that an instance can attach to a root volume and several more volumes (more than two); Additionally, instances cannot have unlimited attachments.

5.1.1 EBS RAID

這里首先介紹一個(gè)概念,磁盤陣列(Redundant Arrays of Independent Disks,RAID),有“獨(dú)立磁盤構(gòu)成的具有冗余能力的陣列”之意。 磁盤陣列是由很多塊獨(dú)立的磁盤,組合成一個(gè)容量巨大的磁盤組,利用個(gè)別磁盤提供數(shù)據(jù)所產(chǎn)生加成效果提升整個(gè)磁盤系統(tǒng)效能。利用這項(xiàng)技術(shù),將數(shù)據(jù)切割成許多區(qū)段,分別存放在各個(gè)硬盤上。

EBS 已經(jīng)是冗余存儲(chǔ)的,但如果你要考慮增加IOPS,則需要考慮使用RAID 技術(shù),前提是你的OS 支持 RAID. RAID 可配置選項(xiàng)為:

· RAID0

· RAID1

· RAID5(Not recommend)

· RAID6(Not recommend)

推薦使用的是RAID0—性能優(yōu)先,RAID1— 容災(zāi)優(yōu)先。

Figure 22 RAID0

Figure 23 RAID1

general

· attached in same AZà EBS volumes are created at AZ level

· create snapshot cross AZ (any AZ in the region)

· copy snapshot to another region (disaster recovery, expansion)

· Root EBS volume is deleted, by default

· persists independently

encrypted

· Public or shared snapshots of encrypted volumes are not supported

· Existing unencrypted volumes cannot be encrypted directly. Can migrate from copy encripted snapshot

· Supported on all Amazon EBS volume types, not instance type

performence

· use raid0 , raid1 improve iops

· EBS optimized with IOPS EBS

price

· charge with storage, I/O requests and snapshot storage

· EBS backed EC2, every stop/start it will be charged as a separate hour

· Snapshot

5.2 EFS concept

AWS EFS是一種存儲(chǔ)服務(wù),它提供了一個(gè)共享的彈性文件系統(tǒng),提供了幾乎無(wú)限的可伸縮性支持。它被設(shè)計(jì)用于Linux實(shí)例(并支持4.0和4.1網(wǎng)絡(luò)文件系統(tǒng)(NFS)協(xié)議),并且它提供了持久的、高可用的存儲(chǔ),可以同時(shí)被數(shù)千臺(tái)服務(wù)器使用。AWS EFS是一個(gè)可自動(dòng)伸縮的完全托管的服務(wù)。這意味著,當(dāng)您向文件系統(tǒng)添加或刪除文件時(shí),文件系統(tǒng)的大小實(shí)際上會(huì)增加或減少。

從表面上看,AWS EFS聽起來(lái)像一個(gè)簡(jiǎn)單的服務(wù),但是當(dāng)您深入挖掘時(shí),會(huì)發(fā)現(xiàn)它還有更多的功能。當(dāng)EFS的文件系統(tǒng)的大小擴(kuò)展時(shí),它的性能也隨之?dāng)U展。這是一個(gè)有點(diǎn)奇怪的選擇,因此,對(duì)于低利用率,EFS的性能可能會(huì)有點(diǎn)令人失望。然而,如果使用得更多,AWS EFS可以提供高達(dá)10gb /s的性能,以及500,000個(gè)IOPS。

使用EFS的一個(gè)好處是您現(xiàn)有的環(huán)境不需要任何更改。您的應(yīng)用程序和服務(wù)只需附加文件系統(tǒng)即可運(yùn)行。EFS的使用不限于AWS云。對(duì)于那些運(yùn)行混合云環(huán)境的人,AWS EFS也可以由本地實(shí)例使用。該特性極大地?cái)U(kuò)展了EFS的可能用例。

EFS最近也得到了更新,獲得了一個(gè)新的存儲(chǔ)層?,F(xiàn)在,除了提供標(biāo)準(zhǔn)存儲(chǔ)之外,EFS還提供了不常用的訪問(wèn)。使用它只需要啟用一個(gè)生命周期管理,它將根據(jù)所需的策略移動(dòng)數(shù)據(jù)。您仍然可以正常使用EFS。您不需要對(duì)基礎(chǔ)設(shè)施或應(yīng)用程序進(jìn)行任何更改,因?yàn)镋FS在幕后為您處理所有事情。與大多數(shù)AWS服務(wù)一樣,EFS只對(duì)客戶使用的內(nèi)容收費(fèi)。EFS標(biāo)準(zhǔn)層存儲(chǔ)的成本為每月每GB 0.30美元。使用AWS EFS非頻繁訪問(wèn)層存儲(chǔ)的成本大大降低了—每個(gè)月為每GB 0.025美元。但是,請(qǐng)記住,在使用這個(gè)層檢索數(shù)據(jù)時(shí),會(huì)產(chǎn)生額外的成本(每傳輸GB 0.01美元)。

5.3 Compare EBS and EFS

雖然EBS和EFS都提供了很好的特性,但這兩個(gè)存儲(chǔ)解決方案實(shí)際上是為兩種完全不同的用途構(gòu)建的。EBS卷被限制為一個(gè)實(shí)例,更重要的是,一次只能被一個(gè)實(shí)例訪問(wèn)。使用EFS,您可以有成百上千個(gè)實(shí)例同時(shí)訪問(wèn)文件系統(tǒng)。這使得AWS EFS非常適合任何需要良好執(zhí)行的集中式共享存儲(chǔ)(如媒體處理或共享代碼存儲(chǔ)庫(kù))的使用。您還可以使用AWS EFS來(lái)提供web內(nèi)容、保存各種備份并減少存儲(chǔ)開銷。雖然EFS的成本確實(shí)比EBS高(EFS為0.30美元/ GB, EBS為0.10美元/ GB),但您只需為每個(gè)EFS文件系統(tǒng)支付一次費(fèi)用。這意味著,如果您為它附加了12個(gè)實(shí)例,您仍然需要支付與僅為它附加了一個(gè)實(shí)例相同的金額。使用EBS卷,您需要為每個(gè)卷付費(fèi)。因此,為了節(jié)省存儲(chǔ)成本,EFS有時(shí)可以替代EBS。

EFS根據(jù)容量來(lái)衡量性能,雖然在某些情況下這可能非常有益,但它也可能是一個(gè)顯著的缺點(diǎn)。您可能沒(méi)有足夠高的利用率來(lái)達(dá)到所需的文件系統(tǒng)吞吐量。因?yàn)锳WS EBS為您提供了穩(wěn)定且可預(yù)測(cè)的性能,所以EBS幾乎總是更適合您,除非您需要多個(gè)實(shí)例同時(shí)訪問(wèn)您的存儲(chǔ)。

EBS is a much better choice than EFS for a single-instance application

6 AWS Storage Gateway classification網(wǎng)關(guān)類型

6.1 Gateway type

AWS storage gateway is a virtual appliance and is not available as a hardware appliance.

The file gateway enables you to store and retrieve objects in Amazon S3 using file protocols, such as NFS. Objects written through file gateway can be directly accessed in S3.

The volume gateway provides block storage to your applications using the iSCSI protocol. Data on the volumes is stored in Amazon S3. To access your iSCSI volumes in AWS, you can take EBS snapshots which can be used to create EBS volumes.

The tape gateway provides your backup application with an iSCSI virtual tape library (VTL) interface, consisting of a virtual media changer, virtual tape drives, and virtual tapes. Virtual tape data is stored in Amazon S3 or can be archived to Amazon Glacier. A tape gateway is ideal for replacing off-site tape directories. The gateway is a virtual tape directory and avoids the costs of transporting actual tapes to an expensive off-site location.

6.2 File gateway

文件網(wǎng)關(guān) – 文件網(wǎng)關(guān) 支持連接到 Amazon Simple Storage Service (Amazon S3) 的文件接口并將服務(wù)和虛擬軟件設(shè)備組合在一起。通過(guò)使用此組合,可以使用行業(yè)標(biāo)準(zhǔn)文件協(xié)議(如網(wǎng)絡(luò)文件系統(tǒng) (NFS))和服務(wù)器消息塊 (SMB) 在 Amazon S3 中存儲(chǔ)和檢索對(duì)象。軟件設(shè)備 (也就是網(wǎng)關(guān)) 作為運(yùn)行在 VMware ESXi 或 Microsoft Hyper-V 管理程序上的虛擬機(jī) (VM) 部署到您的本地環(huán)境中。利用網(wǎng)關(guān),可以將 S3 中的對(duì)象作為文件或文件共享掛載點(diǎn)進(jìn)行訪問(wèn)。利用文件網(wǎng)關(guān),您可以:

  • 您可以直接使用 NFS 版本 3 或 4.1 協(xié)議存儲(chǔ)和檢索文件。
  • 您可以直接使用 SMB 文件系統(tǒng)版本 2 和 3 協(xié)議存儲(chǔ)和檢索文件。
  • 您可以從任意 AWS 云應(yīng)用程序或服務(wù)直接訪問(wèn) Amazon S3 中的數(shù)據(jù)。
  • 您可以使用生命周期策略、跨區(qū)域復(fù)制和版本控制管理 Amazon S3 數(shù)據(jù)。您可以將文件網(wǎng)關(guān)視為 S3 上的文件系統(tǒng)掛載。

文件網(wǎng)關(guān)簡(jiǎn)化了 Amazon S3 中的文件存儲(chǔ),通過(guò)行業(yè)標(biāo)準(zhǔn)文件系統(tǒng)協(xié)議集成到現(xiàn)有應(yīng)用程序中,并提供了對(duì)本地存儲(chǔ)的經(jīng)濟(jì)高效的替代方法。它還通過(guò)透明本地緩存提供對(duì)數(shù)據(jù)的低延遲訪問(wèn)。文件網(wǎng)關(guān)管理與 AWS 之間的數(shù)據(jù)傳輸,緩沖應(yīng)用程序避免網(wǎng)絡(luò)擁堵,并行優(yōu)化和流式處理數(shù)據(jù),以及管理帶寬消耗。文件網(wǎng)關(guān)與 AWS 服務(wù)集成,例如與以下服務(wù)集成:

  • 使用 AWS Identity and Access Management (IAM) 的常見訪問(wèn)管理
  • 使用 AWS Key Management Service (AWS KMS) 的加密
  • 使用 Amazon CloudWatch (CloudWatch) 的監(jiān)控
  • 使用 AWS CloudTrail (CloudTrail) 的審核
  • 使用 AWS 管理控制臺(tái)和 AWS Command Line Interface (AWS CLI) 的操作
  • 賬單和成本管理
  • The file gateway enables you to store and retrieve objects in Amazon S3 using file protocols, such as NFS. Objects written through file gateway can be directly accessed in S3.
  • File Gateway configuration can locally cache frequently used data and for data that is not in cache, it can retrieve from AWS. It automatically and securely backsup file to S3. Volume gateway is used as block storage and not suitable for this requirement. Tape and Glacier options are suitable for requirement that do not need immediate access to data

6.3 Volume gateway

卷網(wǎng)關(guān)– 卷網(wǎng)關(guān)提供了支持云的存儲(chǔ)卷,可以從本地應(yīng)用程序服務(wù)器將該存儲(chǔ)卷作為 Internet 小型計(jì)算機(jī)系統(tǒng)接口 (iSCSI) 設(shè)備安裝。該網(wǎng)關(guān)支持以下卷配置:

  • 緩存卷– 將數(shù)據(jù)存儲(chǔ)在 Amazon Simple Storage Service (Amazon S3) 中并在本地保留經(jīng)常訪問(wèn)的數(shù)據(jù)子集的副本。緩存卷不僅有助于節(jié)省大量主存儲(chǔ)成本,而且最大程度地減小了本地?cái)U(kuò)展存儲(chǔ)的需求。您還可以保留對(duì)經(jīng)常訪問(wèn)的數(shù)據(jù)的低延遲訪問(wèn)。
  • 存儲(chǔ)卷 – 如果需要對(duì)整個(gè)數(shù)據(jù)集進(jìn)行低延遲訪問(wèn),請(qǐng)首先將本地網(wǎng)關(guān)配置為將所有數(shù)據(jù)存儲(chǔ)在本地。然后以異步方式將此數(shù)據(jù)的時(shí)間點(diǎn)快照備份到 Amazon S3。此配置提供了經(jīng)久、價(jià)格低廉且可以恢復(fù)到本地?cái)?shù)據(jù)中心或 Amazon EC2 的場(chǎng)外備份。例如,如果您出于災(zāi)難恢復(fù)目的需要替代容量,則可以將備份恢復(fù)到 Amazon EC2。

All data is backed up to S3 asynchronously when a stored volume is used. This ensures that no lag is incurred by clients that interact with the stored volumes on-site.

6.4 Tape gateway

磁帶網(wǎng)關(guān) – 通過(guò)使用磁帶網(wǎng)關(guān),您可以采用經(jīng)濟(jì)高效且持久的方式在 GLACIER 或 DEEP_ARCHIVE 中存檔備份數(shù)據(jù)。虛擬磁帶庫(kù)提供了虛擬磁帶基礎(chǔ)設(shè)施,該基礎(chǔ)設(shè)施可根據(jù)您的業(yè)務(wù)需求以無(wú)縫方式擴(kuò)展,并可消除預(yù)配置、擴(kuò)展和維護(hù)物理磁帶基礎(chǔ)設(shè)施的運(yùn)營(yíng)負(fù)擔(dān)。

您可以在本地將 AWS Storage Gateway 作為 VM 設(shè)備運(yùn)行,或者在 AWS 中將其作為 Amazon Elastic Compute Cloud (Amazon EC2) 實(shí)例運(yùn)行。您可以在 EC2 實(shí)例上部署網(wǎng)關(guān),以便在 AWS 中預(yù)配置 iSCSI 存儲(chǔ)卷。您可以使用 EC2 實(shí)例上托管的網(wǎng)關(guān)進(jìn)行災(zāi)難恢復(fù)、數(shù)據(jù)鏡像以及為 Amazon EC2 上托管的應(yīng)用程序提供存儲(chǔ)。

A storage gateway using stored volumes will store all data locally, providing low latency access to that data. Further, the entire dataset is backed up to S3 for disaster recovery. S3 is durable and available, but not as fast as accessing local data. A VTL provides a tape backup interface, but not necessarily fast data access.

A tape gateway is ideal for replacing off-site tape directories. The gateway is a virtual tape directory and avoids the costs of transporting actual tapes to an expensive off-site location.

7 Route53

7.1 Route53 concept

Amazon Route 53 提供高可用且可擴(kuò)展的域名系統(tǒng) (DNS)、域名注冊(cè)和運(yùn)行狀況檢查 Web 服務(wù)。設(shè)計(jì)用于為開發(fā)人員和企業(yè)提供一種非??煽壳医?jīng)濟(jì)高效的方式,把名稱(如 example.com)轉(zhuǎn)換為計(jì)算機(jī)用于互相連接的數(shù)字 IP 地址(如 192.0.2.1),從而將最終用戶路由到 Internet 應(yīng)用程序。您可以將 DNS 與運(yùn)行狀況檢查服務(wù)組合使用,路由流量到運(yùn)行正常的終端節(jié)點(diǎn),或者獨(dú)立監(jiān)控終端節(jié)點(diǎn)和/或?qū)ζ涮峁┚瘓?bào)。您還可以購(gòu)買和管理域名(例如 example.com),并自動(dòng)為域配置 DNS 設(shè)置。Route 53 高效地將用戶請(qǐng)求連接到 AWS 中運(yùn)行的基礎(chǔ)設(shè)施,例如 Amazon EC2 實(shí)例、Elastic Load Balancing 負(fù)載均衡器或 Amazon S3 存儲(chǔ)桶,還可以將用戶轉(zhuǎn)接到 AWS 外部的基礎(chǔ)設(shè)施。

借助 Amazon Route 53,您可以創(chuàng)建和管理公有 DNS 記錄。與電話簿相似,Route 53 可讓您管理 Internet 的 DNS 電話簿中為您的域名所列的 IP 地址。Route 53 也應(yīng)答將此類特定域名轉(zhuǎn)換為對(duì)應(yīng)的 IP 地址(如 192.0.2.1)的請(qǐng)求。您可以使用 Route 53 創(chuàng)建新域的 DNS 記錄,或轉(zhuǎn)換現(xiàn)有域的 DNS 記錄。Route 53 具有簡(jiǎn)單的標(biāo)準(zhǔn)型 REST API,可讓您輕松創(chuàng)建、更新和管理 DNS 記錄。Route 53 還額外提供運(yùn)行狀況檢查,可以監(jiān)控應(yīng)用程序的運(yùn)行狀況和性能,還能監(jiān)控 Web 服務(wù)器和其他資源。您還可以注冊(cè)新的域名或者將現(xiàn)有域名轉(zhuǎn)移到 Route 53 中進(jìn)行管理。

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是一組規(guī)則和記錄的集合,幫助客戶端了解如何通過(guò)url訪問(wèn)服務(wù)器。在AWS中,最常用的記錄是:

· A: URL to IPv4

· AAAA: URL to IPv6

· CNAME: URL to URL

· Alias: URL to aws resource

A記錄示例

Figure 30 Diagram for A record

7.2 Routing policy

Route53 可以用于你擁有或購(gòu)買的公有域名,例如application.mypublicdomain.com, 也可以用于你的VPC內(nèi)實(shí)例解析的私有域名,如application1.company.internal.

Route53有高級(jí)的特性,例如:

· 負(fù)載均衡(通過(guò)DNS—也叫客戶端負(fù)載均衡)

· 健康檢查

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

以下重點(diǎn)介紹路由策略。

7.2.1 Simple routing policy

· 將一個(gè)域映射到一個(gè)url

· 使用場(chǎng)景: 當(dāng)需要重定向到單個(gè)資源時(shí)使用

· 不能將健康檢查附加到簡(jiǎn)單路由策略

· 當(dāng)返回多個(gè)值時(shí),客戶端將隨機(jī)選擇一個(gè)

Figure 31 Simple routing policy

7.2.2 Weighted routing policy

WRR--加權(quán)輪詢可讓您為資源記錄集合分配權(quán)重,以便指定不同回復(fù)所服務(wù)的頻率。您可能希望使用此功能來(lái)執(zhí)行 A/B 測(cè)試,發(fā)送一小部分流量到進(jìn)行了軟件更改的服務(wù)器。例如,假設(shè)您向一個(gè) DNS 名稱關(guān)聯(lián)了兩個(gè)記錄集合,其中一個(gè)的權(quán)重為 3,另一個(gè)的權(quán)重為 1。此情形中,75% 時(shí)間內(nèi) Route 53 將返回權(quán)重為 3 的記錄集合,25% 時(shí)間內(nèi) Route 53 將返回權(quán)重為 1 的記錄集合。權(quán)重可以是 0 到 255 范圍內(nèi)的任意數(shù)字。

Figure 32 WRR Policy

7.2.3 Latency routing policy

LBR(基于延遲的路由)是 Amazon Route 53 的一項(xiàng)新功能,有助于您提高應(yīng)用程序?qū)θ蚴鼙姷男阅?。您可以在多個(gè) AWS 地區(qū)運(yùn)行應(yīng)用程序,Amazon Route 53 則通過(guò)其遍布全球的節(jié)點(diǎn)將最終用戶路由到可提供最低延遲性的 AWS 地區(qū)。

只需通過(guò) AWS 管理控制臺(tái)或簡(jiǎn)單的 API,就能快速而輕松地使用 Amazon Route 53 的全新 LBR 功能。只需創(chuàng)建包含 IP 地址或各個(gè) AWS 終端節(jié)點(diǎn)的 ELB 名稱的記錄集合,再將該集合標(biāo)記為支持 LBR 的記錄集合,這與將記錄集合標(biāo)記為加權(quán)記錄集合非常相似。Amazon Route 53 將負(fù)責(zé)其余的工作 – 為各個(gè)請(qǐng)求確定最佳的終端節(jié)點(diǎn)并相應(yīng)地路由最終用戶,與 Amazon CloudFront 這一 Amazon 全球內(nèi)容傳輸服務(wù)非常相似。

LBR特性:

· 重定向到延遲最少的服務(wù)器

· 當(dāng)用戶延遲是一個(gè)優(yōu)先級(jí)時(shí)超級(jí)有用

· 延遲是基于用戶設(shè)計(jì)的AWS區(qū)域來(lái)評(píng)估的

· 如果是延遲最低的,那么德國(guó)用戶的請(qǐng)求可能會(huì)重定向到美國(guó)

7.2.4 Geolocation

地理定位-- Route 53 Geo DNS 會(huì)根據(jù)請(qǐng)求發(fā)出的地理位置將其送至特定的終端節(jié)點(diǎn),以此幫助調(diào)整負(fù)載平衡。Geo DNS 可以自定義本地化的內(nèi)容,例如以正確的語(yǔ)言展示詳情頁(yè)面或限制將內(nèi)容分配到已授權(quán)的市場(chǎng)。Geo DNS 通過(guò)一種可以預(yù)見而又易于管理的方式讓您實(shí)現(xiàn)負(fù)載平衡,確保每一個(gè)終端用戶地點(diǎn)始終路由到相同的終端節(jié)點(diǎn)。Geo DNS 提供三種地理粒度級(jí)別:洲、國(guó)家/地區(qū)和州/省,Geo DNS 還提供全球記錄,當(dāng)終端用戶的地點(diǎn)與您創(chuàng)建的特定 Geo DNS 記錄不匹配時(shí),全球記錄可在這種情況下發(fā)揮作用。您還可以將 Geo DNS 與其他路由類型(例如基于延遲的路由和 DNS 故障轉(zhuǎn)移)進(jìn)行組合,以實(shí)現(xiàn)多種低延遲的容錯(cuò)架構(gòu)。

Geoproximity policy: 地理鄰近性,這個(gè)策略在當(dāng)前的route53中看不到了,但是在考試中仍然可能會(huì)出現(xiàn),這和Geolocation類似。

7.2.5 Multi value answer routing policy

Route 53 現(xiàn)在支持使用多值回答響應(yīng) DNS 查詢。在 DNS 查詢響應(yīng)中返回多個(gè)可檢查運(yùn)行狀況的 IP 地址這一功能并非負(fù)載均衡器的替代,這是使用 DNS 提高可用性和負(fù)載均衡能力的一種方式。如果您希望將流量隨機(jī)路由到多個(gè)資源 (如 Web 服務(wù)器),您可以為每個(gè)資源創(chuàng)建一條多值回答記錄,然后選擇性地將 Amazon Route 53 運(yùn)行狀況檢查與每條記錄關(guān)聯(lián)。Amazon Route 53 最多支持使用八條正常記錄響應(yīng)每條 DNS 查詢。

7.2.6 Failover routing policy

當(dāng)您希望創(chuàng)建主動(dòng)/被動(dòng)設(shè)置時(shí),將使用故障轉(zhuǎn)移路由策略。 例如,你想把你的主站點(diǎn)放在us-west-2,而從DR 站點(diǎn)在AP-Southeast-2。Route53將使用健康檢查檢查你的主站點(diǎn)健康情況,一旦發(fā)現(xiàn)主站點(diǎn)丟失,就會(huì)將流量路由轉(zhuǎn)發(fā)到從站點(diǎn)上。

Figure 33 Failover routing

7.3 CNAME vs Alias

CNAME:

· 將一個(gè)url指向任何其他url. Application.mypublic.comàblabla.anything.com

· 只能用于非頂點(diǎn)域名

Alias:

· 將一個(gè)url指向AWS 資源。Application.mypublic.comàblabla.amazonaws.com

· 可以用于頂點(diǎn)域名和非頂點(diǎn)域名

· 免費(fèi)

· 本地健康檢查

 

CNAME

Alias

linked record

use at Apex?

No

Yes

Yes(only to other NS1 zones)

Geo-Aware

Yes

No

Yes(when linked to geo-aware record)

Relative Speed

Fast

Faster

Faster

Collapses Responses

Yes

Yes

Yes

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, 是一種對(duì)象存儲(chǔ),專為從 Internet 上的任意位置存儲(chǔ)和檢索任意數(shù)量的數(shù)據(jù)而構(gòu)建。它是一種簡(jiǎn)單的存儲(chǔ)服務(wù),以非常低的成本提供極其持久、高度可用并可無(wú)限擴(kuò)展的數(shù)據(jù)存儲(chǔ)基礎(chǔ)設(shè)施。您可以存儲(chǔ)的總數(shù)據(jù)容量和對(duì)象個(gè)數(shù)不受限制。各個(gè) Amazon S3 對(duì)象的大小范圍可以從最小 0 字節(jié)到最大 5TB??稍趩蝹€(gè) PUT 中上傳的最大數(shù)據(jù)對(duì)象為 5 GB。對(duì)于大于 100MB 的數(shù)據(jù)對(duì)象,客戶應(yīng)該考慮使用分段上傳功能。

Amazon S3 提供一系列適合不同使用案例的存儲(chǔ)類。這包括 S3 標(biāo)準(zhǔn)(適用于頻繁訪問(wèn)的數(shù)據(jù)的通用存儲(chǔ));S3 智能分層(適用于具有未知或變化的訪問(wèn)模式的數(shù)據(jù));S3 標(biāo)準(zhǔn) - 不頻繁訪問(wèn)(S3 標(biāo)準(zhǔn) - IA)和 S3 單區(qū) - 不頻繁訪問(wèn)(S3 單區(qū) - IA),適用于長(zhǎng)期存在、但訪問(wèn)不太頻繁的數(shù)據(jù);以及 Amazon S3 Glacier (S3 Glacier) 和 Amazon S3 Glacier 深度存檔(S3 Glacier 深度存檔),適用于長(zhǎng)期存檔和數(shù)字保留。

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是基于對(duì)象的存儲(chǔ),允許你上傳文件

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

· 沒(méi)有存儲(chǔ)限制

· 對(duì)于大于 100MB 的數(shù)據(jù)對(duì)象,客戶應(yīng)該考慮使用分段上傳功能。

· 文件存儲(chǔ)在buckets中

· S3使用全局的命名空間,也就是說(shuō)名字必須是全局唯一的

· Bucket是在region level定義的

· 不適合于安裝OS

· 成功上傳文件后將會(huì)生成 HTTP 200狀態(tài)碼

· Permissions

§ User based policiesà roles (IAM)

§ Resource based policies

§ Bucket Policies

§ Access control lists

· Bucket ACL

· Object ACL

· 缺省條件下,所有新建的bucket都是PRIVATE,你可以配置訪問(wèn)控制

· S3可以配置創(chuàng)建訪問(wèn)日志,記錄所有訪問(wèn)S3 Bucket的請(qǐng)求。這個(gè)log可以發(fā)送到其他bucket,即使是屬于其他賬號(hào)的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

· 任何文件,在啟動(dòng)Versioning 前,version 均為 “null”

s3是基于對(duì)象的,你可以把對(duì)象簡(jiǎn)單考慮為文件,以下是對(duì)象的組成部分:

§ Key: 這簡(jiǎn)單的指object 名字

§ Value :這是簡(jiǎn)單的數(shù)據(jù),由一個(gè)字節(jié)序列組成

§ Version ID: 這對(duì)versioning 來(lái)說(shuō)很重要

§ Metadata: 有關(guān)您正在存儲(chǔ)的數(shù)據(jù)的數(shù)據(jù)

§ Subresources

§ Access control lists

§ Torrent

S3提供了兩種數(shù)據(jù)一致性模式

§ 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 命名規(guī)則:

§ 不含大寫字母

§ 不含下劃線

§ 3-63個(gè)字符長(zhǎng)度

§ 沒(méi)有IP

§ 必須以小寫字母或數(shù)字開頭

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

8.2 S3 replication

8.3 S3 use cases and comparison

8.3.1 S3 use cases

§ S3 standard: 冗余地存儲(chǔ)在多個(gè)設(shè)備中的多個(gè)設(shè)備上,旨在同時(shí)承受兩個(gè)設(shè)備的損失

§ S3-Intelligent tier: 設(shè)計(jì)用于成本優(yōu)化,通過(guò)自動(dòng)將數(shù)據(jù)移動(dòng)到最具成本效益的訪問(wèn)層,而不影響性能或操作開銷層

§ S3-IA: 對(duì)于不頻繁訪問(wèn)的數(shù)據(jù),但需要時(shí)可以快速訪問(wèn)。 費(fèi)用比S3 標(biāo)準(zhǔn)低,但將會(huì)產(chǎn)生檢索費(fèi)用

§ S3 One zone – IA : 對(duì)于不頻繁訪問(wèn)而又追求低成本存儲(chǔ)的數(shù)據(jù),不要求多AZ 恢復(fù)

§ S3 Glacier: 是一種安全,持久且低成本的數(shù)據(jù)歸檔存儲(chǔ),檢索時(shí)間從幾分鐘到數(shù)小時(shí)

§ S3 Glacier deep Archive: 這是S3 最低成本的存儲(chǔ),但檢索時(shí)間12小時(shí)則是可接受的

8.3.2 S3 comparison

所有的S3存儲(chǔ)類型,都具有相同的持久性,即 11 9s??荚囍谐?键c(diǎn)是在可用性和SLA的區(qū)別。

Table 5 S3 comparison

8.4 S3 encryption for objects

在S3中,有4種方法來(lái)對(duì)object進(jìn)行加密,考試中要重點(diǎn)了解那種方法適用于那種場(chǎng)景。

§ SSE-S3: 使用aws 處理和管理的密鑰來(lái)加密S3 object

§ SSE-KMS: S3利用指定的aws KMS 來(lái)管理密鑰

§ SSE-C: S3 使用用戶每次請(qǐng)求提供密鑰

§ 客戶端加密

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 端進(jìn)行加密的,使用AES-256加密類型,header 必須設(shè)置為: “x-amz-server-side-encryption”: “AES256” 。使用此方法加密,其可靠性低,因?yàn)閿?shù)據(jù)被檢索后會(huì)自動(dòng)解密,無(wú)論是合法還是非法的檢索。

Figure 34 SSE-S3

SSE-KMS –> KMS的優(yōu)勢(shì)是用戶控制和審計(jì)追蹤,當(dāng)題干中有audit出現(xiàn),則應(yīng)考慮的加密方式即為 SSE-KMS。Object是在server 端進(jìn)行加密的,header 必須設(shè)置為: “x-amz-server-side-encryption”: “aws:kms”

Figure 35 SSE-KMS

SSE-Cà Object還是在server 端進(jìn)行加密,但使用完全由客戶在AWS外部管理的數(shù)據(jù)密鑰,S3中保存用戶的加密密鑰。其他幾種加密方式,傳輸時(shí)都是http 或https可選。但SSE-C必須使用https進(jìn)行傳輸,且每個(gè)http請(qǐng)求都必須在header中提供加密密鑰。

Figure 36 SSE-C

Client side encryption:

§ 客戶端庫(kù),如amazon s3加密客戶端

§ 數(shù)據(jù)發(fā)送到S3前,客戶端必須自己先加密

§ 當(dāng)從S3檢索數(shù)據(jù)時(shí),客戶端必須自己解密

§ 客戶完全管理密鑰和加密周期

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

Figure 37 Client side encryption

8.5 S3 Websites

s3可以托管靜態(tài)網(wǎng)站并在Internet上訪問(wèn)它們,網(wǎng)站的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

如果訪問(wèn)時(shí)得到403錯(cuò)誤碼,請(qǐng)確保 bucket policies是允許公網(wǎng)讀取的。

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

Figure 38 Object not public

S3 CORS à Cross-Origin Resource Sharing

如果你請(qǐng)求的數(shù)據(jù)來(lái)自另一個(gè)S3 bucket, 你就需要enable CORS, CORS允許您限制可以在s3中請(qǐng)求文件的網(wǎng)站的數(shù)量,并限制您的成本。常見的考試場(chǎng)景如下圖:

Figure 39 CORS case

8.6 S3 lifecycle management

Define rules based on:

§ Object age

§ Current and previous version

Filter based on:

§ Prefix (images/, logs/)

§ Object tags (name= PHI)

9 Database

9.1 Database overview introduction

數(shù)據(jù)庫(kù)是“按照數(shù)據(jù)結(jié)構(gòu)來(lái)組織、存儲(chǔ)和管理數(shù)據(jù)的倉(cāng)庫(kù)”。是一個(gè)長(zhǎng)期存儲(chǔ)在計(jì)算機(jī)內(nèi)的、有組織的、可共享的、統(tǒng)一管理的大量數(shù)據(jù)的集合。數(shù)據(jù)庫(kù)是以一定方式儲(chǔ)存在一起、能與多個(gè)用戶共享、具有盡可能小的冗余度、與應(yīng)用程序彼此獨(dú)立的數(shù)據(jù)集合,可視為電子化的文件柜——存儲(chǔ)電子文件的處所,用戶可以對(duì)文件中的數(shù)據(jù)進(jìn)行新增、查詢、更新、刪除等操作。

數(shù)據(jù)庫(kù)的分類,從大的方面來(lái)看,分為兩大類,即關(guān)系型數(shù)據(jù)庫(kù)(SQL)和非關(guān)系型數(shù)據(jù)庫(kù)(NoSQL)。

關(guān)系型數(shù)據(jù)庫(kù),存儲(chǔ)的格式可以直觀地反映實(shí)體間的關(guān)系。關(guān)系型數(shù)據(jù)庫(kù)和常見的表格比較相似,關(guān)系型數(shù)據(jù)庫(kù)中表與表之間是有很多復(fù)雜的關(guān)聯(lián)關(guān)系的。 常見的關(guān)系型數(shù)據(jù)庫(kù)有MySQL、MariaDB、Oracle、Aurora、SQL Server 或 PostgreSQL等。在輕量或者小型的應(yīng)用中,使用不同的關(guān)系型數(shù)據(jù)庫(kù)對(duì)系統(tǒng)的性能影響不大,但是在構(gòu)建大型應(yīng)用時(shí),則需要根據(jù)應(yīng)用的業(yè)務(wù)需求和性能需求,選擇合適的關(guān)系型數(shù)據(jù)庫(kù)。

隨著近些年技術(shù)方向的不斷拓展,大量的NoSql數(shù)據(jù)庫(kù)如DynamoDB、MongoDB、Redis、HBase、Memcache出于簡(jiǎn)化數(shù)據(jù)庫(kù)結(jié)構(gòu)、避免冗余、影響性能的表連接、摒棄復(fù)雜分布式的目的被設(shè)計(jì)。NoSQL數(shù)據(jù)庫(kù)適合追求速度和可擴(kuò)展性、業(yè)務(wù)多變的應(yīng)用場(chǎng)景。 對(duì)于非結(jié)構(gòu)化數(shù)據(jù)的處理更合適,如文章、評(píng)論,這些數(shù)據(jù)如全文搜索、機(jī)器學(xué)習(xí)通常只用于模糊處理,并不需要像結(jié)構(gòu)化數(shù)據(jù)一樣,進(jìn)行精確查詢,而且這類數(shù)據(jù)的數(shù)據(jù)規(guī)模往往是海量的,數(shù)據(jù)規(guī)模的增長(zhǎng)往往也是不可能預(yù)期的,而NoSQL數(shù)據(jù)庫(kù)的擴(kuò)展能力幾乎也是無(wú)限的,所以NoSQL數(shù)據(jù)庫(kù)可以很好的滿足這一類數(shù)據(jù)的存儲(chǔ)。NoSQL數(shù)據(jù)庫(kù)利用key-value可以大量的獲取大量的非結(jié)構(gòu)化數(shù)據(jù),并且數(shù)據(jù)的獲取效率很高,但用它查詢結(jié)構(gòu)化數(shù)據(jù)效果就比較差。

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.

9.2 SQL database introduction

9.2.1 RDS (OLTP)

Amazon Relational Database Service 也稱為 Amazon RDS,是一種托管服務(wù),可以簡(jiǎn)化在云中設(shè)置、操作和擴(kuò)展關(guān)系數(shù)據(jù)庫(kù)的過(guò)程。它在管理耗時(shí)的數(shù)據(jù)庫(kù)管理任務(wù)的同時(shí),提供經(jīng)濟(jì)高效的可調(diào)容量,使您能夠騰出時(shí)間專注于應(yīng)用程序和業(yè)務(wù)。與所有 Amazon Web Services 相同,您無(wú)需預(yù)先投資,而且只需為所使用的資源付費(fèi)。如果您的應(yīng)用程序需要更多的數(shù)據(jù)庫(kù)實(shí)例,您可以通過(guò)此申請(qǐng)表申請(qǐng)更多數(shù)據(jù)庫(kù)實(shí)例。

· 管理 MySQL、MariaDB、Oracle、SQL Server 或 PostgreSQL ,這意味著您當(dāng)前用于現(xiàn)有數(shù)據(jù)庫(kù)的代碼、應(yīng)用程序和工具也可以無(wú)縫用于 Amazon RDS。

· Amazon RDS 可以自動(dòng)備份您的數(shù)據(jù)庫(kù),并使您的數(shù)據(jù)庫(kù)軟件版本保持最新。

· 您可以靈活方便地?cái)U(kuò)展與關(guān)系數(shù)據(jù)庫(kù)實(shí)例相關(guān)聯(lián)的計(jì)算資源或存儲(chǔ)容量,并從中受益。此外,Amazon RDS 還可通過(guò)復(fù)制輕松增強(qiáng)數(shù)據(jù)庫(kù)可用性、改進(jìn)數(shù)據(jù)耐久性或擴(kuò)展讀取密集型數(shù)據(jù)庫(kù)工作負(fù)載中單一數(shù)據(jù)庫(kù)實(shí)例的容量限制。

· 默認(rèn)情況下,客戶最多可以擁有 40 個(gè) Amazon RDS 數(shù)據(jù)庫(kù)實(shí)例。全都可用于“BYOL” (Bring Your Own License) 模式下的 Amazon Aurora、MySQL、MariaDB、PostgreSQL 以及 Oracle。

· 適用于 SQL Server 的 RDS 在單個(gè)數(shù)據(jù)庫(kù)實(shí)例上有最多擁有 100 個(gè)數(shù)據(jù)庫(kù)的限制。

· 必須提供EC2實(shí)例和EBS卷類型和大小

· 通過(guò)CloudWatch 監(jiān)控

· 備份/快照/時(shí)間點(diǎn)恢復(fù)功能

· RDS 在虛擬機(jī)上運(yùn)行,但你不能登錄這些OS

· AWS 負(fù)責(zé)RDS OS 的安全,用戶負(fù)責(zé)使用ssl在DB中設(shè)置KMS, Security group, IAM policies和授權(quán)用戶

· RDS 不是 serverless

· 支持 read replica

§ 用于增加性能

§ 必須開啟自動(dòng)備份

§ 可以在不同的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

· 通過(guò)rebooting RDS實(shí)例,你可以強(qiáng)制災(zāi)難恢復(fù)從一個(gè)AZ到另一個(gè)AZ

將數(shù)據(jù)導(dǎo)入 Amazon RDS 的方式有很多并且非常簡(jiǎn)單,例如對(duì)于 MySQL 使用 mysqldump 或 mysqlimport 實(shí)用程序,對(duì)于 Oracle 使用數(shù)據(jù)泵、Import/Export 或 SQL Loader,對(duì)于 SQL Server 使用 Import/Export 向?qū)?、完整備份文件?bak 文件)或 Bulk Copy Program (BCP),或?qū)?PostgreSQL 使用 pg_dump。有關(guān)數(shù)據(jù)導(dǎo)入和導(dǎo)出的更多信息,請(qǐng)參閱 MySQL 數(shù)據(jù)導(dǎo)入指南、Oracle 數(shù)據(jù)導(dǎo)入指南、SQL Server 數(shù)據(jù)導(dǎo)入指南、PostgreSQL 數(shù)據(jù)導(dǎo)入指南。

靜態(tài)加密支持Aurora、MySQL、SQL Server、MariaDB、PostgreSQL 以及 Oracle。使用AWS的密鑰管理服務(wù)(KMS )來(lái)完成加密。一旦RDS實(shí)例被加密,就會(huì)加密底層存儲(chǔ)中的靜態(tài)數(shù)據(jù),以及它的自動(dòng)備份、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, MySQL,Oracle, 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.

9.2.2 Aurora

· 以10GB為起點(diǎn),10GB 為增量增加到64T,存儲(chǔ)可自動(dòng)伸縮

· 計(jì)算資源可以縱向擴(kuò)展到32Vcpu ,244G 內(nèi)存

· 至少有3個(gè)可用區(qū),每個(gè)可用區(qū)包含2個(gè)副本,也即是你的數(shù)據(jù)至少6個(gè)副本

· 當(dāng)主機(jī)故障:

§ 一個(gè)read replica將自動(dòng)晉升為主機(jī)(60秒內(nèi))

§ 如果沒(méi)有read replica,將自動(dòng)lauch 新的替代主機(jī)

· 你可以分享Aurora snapshots給其他AWS 賬戶

· 缺省情況下,Aurora開啟自動(dòng)備份

· Aurora 是 serverless

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

· AWS 負(fù)責(zé)Aurora OS 的安全,用戶負(fù)責(zé)使用ssl在DB中設(shè)置KMS, Security group, IAM policies

Figure 40 The comparison between MySQL and Aurora

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

· 監(jiān)控的metric 16 項(xiàng), 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來(lái)增加數(shù)據(jù)庫(kù)和web應(yīng)用程序的性能,它具有如下特性:

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

· 內(nèi)存數(shù)據(jù)存儲(chǔ),延遲低于毫秒級(jí)

· 必須提供EC2實(shí)例類型

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

· 安全是通過(guò)IAM, Security group, KMS, Redis Auth

· 備份/快照/時(shí)間點(diǎn)恢復(fù)功能

· 通過(guò)CloudWatch 監(jiān)控

· AWS 負(fù)責(zé)OS 的安全,用戶負(fù)責(zé)使用ssl在DB中設(shè)置KMS, Security group, IAM policies,users (Redis Auth)

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

9.3.2 DynamoDB

AWS DynamoDB是一個(gè)快速和靈活的NoSQL數(shù)據(jù)庫(kù)服務(wù),適用于所有需要一致的、任何規(guī)模的延遲在個(gè)位數(shù)的應(yīng)用程序,他是一個(gè)完全托管的數(shù)據(jù)庫(kù),支持文檔和Key-value數(shù)據(jù)模型。它靈活的數(shù)據(jù)模型和可靠的性能使它非常適合于移動(dòng)、web、游戲、廣告技術(shù)、IoT和許多其他應(yīng)用程序。mobile, web, gaming, ad-tech, IoT, and many other applications.

Primary key:

Simpleàsingle attribute

Compositeà Two attribute (partition key, sort key)

· AWS 專有的技術(shù),NoSQL 數(shù)據(jù)庫(kù)管理

· 存儲(chǔ)在SSD存儲(chǔ)器中

· 高可用,分布在3個(gè)地理上不同的數(shù)據(jù)中心

· 缺省是最終的一致性 讀取(eventual consistent reads)

§ 所有數(shù)據(jù)副本之間的一致性通常在1秒內(nèi)到達(dá)。在短時(shí)間內(nèi)重復(fù)讀取應(yīng)該會(huì)返回更新后的數(shù)據(jù)(最后的讀性能)

· 支持強(qiáng)一致讀取 (Strongly consistent reads)

§ 強(qiáng)一致的讀將返回一個(gè)結(jié)果,該結(jié)果反應(yīng)在讀之前收到成功響應(yīng)的所有寫操作

§ Cost 是最終一致性的2倍

· Serverless,配置容量,自動(dòng)擴(kuò)展

· 具有備份/恢復(fù)功能,全局表功能

· 可以代替ElastiCache作為 key-value存儲(chǔ),例如存儲(chǔ)會(huì)話數(shù)據(jù)

· 通過(guò)CloudWatch 監(jiān)控

· 安全—身份認(rèn)證和授權(quán)是通過(guò)IAM 完成的

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

· Use case: 無(wú)服務(wù)器應(yīng)用程序開發(fā),分布式無(wú)服務(wù)器緩存,不支持SQL 查詢語(yǔ)言

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

9.4 Redshift

Redshift 是基于PostgreSQL的,但它并不用于OLTP-- online transation processing,而是用于OLAP—online analytical processing,作為分析和數(shù)據(jù)倉(cāng)庫(kù)。其性能是其他數(shù)據(jù)倉(cāng)庫(kù)的10倍,可擴(kuò)展到PB級(jí)的數(shù)據(jù)。存儲(chǔ)時(shí)基于列存儲(chǔ)而不是行存儲(chǔ),支持大規(guī)模的并行查詢(MPP—Massively Parallel Query Execution), 且高可用。由SQL 接口來(lái)執(zhí)行查詢。根據(jù)所提供的實(shí)例按需付費(fèi),集成了BI 工具,如 AWS Quicksight或tableau。

Redshift具有如下特性:

· 單節(jié)點(diǎn)—160Gb

· 多節(jié)點(diǎn)

§ Leader節(jié)點(diǎn),管理客戶端連接和接收查詢

§ Compute節(jié)點(diǎn),存儲(chǔ)數(shù)據(jù)和執(zhí)行查詢即計(jì)算,可擴(kuò)展到128個(gè)計(jì)算節(jié)點(diǎn)

· 數(shù)據(jù)從S3、DynamoDB、DMS和其他DBs加載

· cluster can be restored from snapshot in same region

· Redshift spectrum: 可以直接針對(duì)S3執(zhí)行查詢,不需要加載

· Redshift增強(qiáng)了VPC路由功能,復(fù)制和卸載(unload)都經(jīng)過(guò)VPC

· Backups

§ 默認(rèn)啟用,保留一天

§ 最長(zhǎng)保存期為35天

§ Redshift總是試圖維護(hù)至少3個(gè)數(shù)據(jù)副本:計(jì)算節(jié)點(diǎn)上的original和replica,以及Amazon S3中的備份

§ Redshift還可以異步復(fù)制你的snapshots到另一個(gè)區(qū)域的S3中,進(jìn)行災(zāi)難恢復(fù)

· Redshift的可用性:

§ 當(dāng)前只支持1個(gè)AZ

§ 有自動(dòng)愈合功能—auto healing

§ 可以在停機(jī)時(shí)將snapshots恢復(fù)到新的 AZ (same region)

§ 可用于商業(yè)智能(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

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

通過(guò) VPC 內(nèi)部署的 EC2 實(shí)例可以訪問(wèn)同一 VPC 內(nèi)部署的數(shù)據(jù)庫(kù)實(shí)例。如果這些 EC2 實(shí)例部署在具有關(guān)聯(lián)彈性 IP 的公共子網(wǎng)中,您可以通過(guò) Internet 訪問(wèn) EC2 實(shí)例。對(duì)于 VPC 內(nèi)部署的數(shù)據(jù)庫(kù)實(shí)例,可通過(guò) VPN 或您在公有子網(wǎng)中可以啟動(dòng)的堡壘主機(jī),或使用 Amazon RDS 可公開訪問(wèn)選項(xiàng)通過(guò) Internet 或從 VPC 外部的 EC2 實(shí)例進(jìn)行訪問(wèn)。

要使用堡壘主機(jī),您需要設(shè)置一個(gè)包含用作 SSH 堡壘的 EC2 實(shí)例的公開子網(wǎng)。該公有子網(wǎng)的 Internet 網(wǎng)關(guān)和路由規(guī)則必須允許通過(guò) SSH 主機(jī)引導(dǎo)流量,然后必須將請(qǐng)求轉(zhuǎn)發(fā)到 RDS 數(shù)據(jù)庫(kù)實(shí)例的私有 IP 地址。

簡(jiǎn)單創(chuàng)建數(shù)據(jù)庫(kù)實(shí)例,并將“可公開訪問(wèn)”選項(xiàng)設(shè)定為“是”,即可使用公共連接。默認(rèn)情況下,當(dāng)“可公開訪問(wèn)”選項(xiàng)可用時(shí),從您的 VPC 外部可實(shí)現(xiàn)對(duì) VPC 內(nèi)數(shù)據(jù)庫(kù)實(shí)例的完全訪問(wèn)。這表示您無(wú)需配置 VPN 或堡壘主機(jī)來(lái)允許對(duì)實(shí)例的訪問(wèn)。

您也可以設(shè)置一個(gè) VPN 網(wǎng)關(guān),將公司網(wǎng)絡(luò)擴(kuò)展到 VPC,然后允許訪問(wèn)該 VPC 中的 RDS 數(shù)據(jù)庫(kù)實(shí)例。有關(guān)詳細(xì)信息,請(qǐng)參閱 Amazon VPC 用戶指南。我們強(qiáng)烈建議您使用 DNS 名稱來(lái)連接數(shù)據(jù)庫(kù)實(shí)例,因?yàn)榛A(chǔ) IP 地址可能會(huì)發(fā)生變化(例如,在故障轉(zhuǎn)移時(shí))。

數(shù)據(jù)庫(kù)實(shí)例遷移:可以從VPC外部遷移到內(nèi)部,但不能從內(nèi)部遷移到外部。

· 如果數(shù)據(jù)庫(kù)實(shí)例未在 VPC 中,您可以使用 AWS 管理控制臺(tái)輕松將數(shù)據(jù)庫(kù)實(shí)例移至 VPC 中。

· 對(duì) VPC 外部的數(shù)據(jù)庫(kù)實(shí)例拍攝快照,然后通過(guò)指定您要使用的數(shù)據(jù)庫(kù)子網(wǎng)組,將其還原到 VPC。此外,您也可以執(zhí)行“還原到時(shí)間點(diǎn)”操作。

· 不支持將數(shù)據(jù)庫(kù)實(shí)例從 VPC 內(nèi)部遷移到外部。出于安全考慮,無(wú)法將 VPC 內(nèi)數(shù)據(jù)庫(kù)實(shí)例的數(shù)據(jù)庫(kù)快照還原到 VPC 外部。同樣,也無(wú)法執(zhí)行“還原到時(shí)間點(diǎn)”功能。

9.6 RDS Database configuration

如果您的 AWS 賬戶是在 2013 年 12 月 4 日之前創(chuàng)建的,那么您或許可以在 Amazon Elastic Compute Cloud (EC2)-Classic 環(huán)境中運(yùn)行 Amazon RDS。無(wú)論使用 EC2-Classic 還是 EC2-VPC,Amazon RDS 的基本功能完全相同。無(wú)論數(shù)據(jù)庫(kù)實(shí)例部署在 VPC 內(nèi)部還是外部,Amazon RDS 都能管理備份、軟件補(bǔ)丁、自動(dòng)故障檢測(cè)、只讀副本和恢復(fù)。

數(shù)據(jù)庫(kù)子網(wǎng)組是您希望為 VPC 中的 RDS 數(shù)據(jù)庫(kù)實(shí)例委派的子網(wǎng)集合。每個(gè)數(shù)據(jù)庫(kù)子網(wǎng)組都應(yīng)在指定區(qū)域中的每個(gè)可用區(qū)內(nèi)擁有至少一個(gè)子網(wǎng)。在 VPC 中創(chuàng)建數(shù)據(jù)庫(kù)實(shí)例時(shí),您需要選擇一個(gè)數(shù)據(jù)庫(kù)子網(wǎng)組。然后,Amazon RDS 使用該數(shù)據(jù)庫(kù)子網(wǎng)組和您首選的可用區(qū)來(lái)選擇子網(wǎng)以及該子網(wǎng)內(nèi)的 IP 地址。Amazon RDS 創(chuàng)建彈性網(wǎng)絡(luò)接口,并通過(guò)該 IP 地址將其關(guān)聯(lián)到您的數(shù)據(jù)庫(kù)實(shí)例。請(qǐng)注意,我們強(qiáng)烈建議您使用 DNS 名稱來(lái)連接數(shù)據(jù)庫(kù)實(shí)例,因?yàn)榛A(chǔ) IP 地址可能會(huì)變化(例如,在故障轉(zhuǎn)移時(shí))。

對(duì)于多可用區(qū)部署,為一個(gè)區(qū)域內(nèi)的所有可用區(qū)定義子網(wǎng)可允許 Amazon RDS 在需要時(shí)在其他可用區(qū)中創(chuàng)建新的備用實(shí)例。即使是單一可用區(qū)部署,您也需要這樣做,以防以后需要將它們轉(zhuǎn)換為多可用區(qū)部署。

以多可用區(qū)部署模式運(yùn)行我的數(shù)據(jù)庫(kù)實(shí)例時(shí),不可以使用備用副本來(lái)執(zhí)行讀取或?qū)懭氩僮?。多可用區(qū)備用副本不能服務(wù)讀取請(qǐng)求。多可用區(qū)部署旨在增強(qiáng)數(shù)據(jù)庫(kù)可用性和持久性,而非獲得讀取擴(kuò)展優(yōu)勢(shì)。因此,該功能在主副本和備用副本之間采用同步復(fù)制。我們的實(shí)施可確保主副本和備用副本一直處于同步狀態(tài),但不能使用備用副本執(zhí)行讀取或?qū)懭氩僮鳌?/p>

需要先啟用數(shù)據(jù)庫(kù)實(shí)例的自動(dòng)備份,然后才能創(chuàng)建只讀副本。將備份保留時(shí)間設(shè)置為 0 以外的任何值,以此在添加只讀副本之前啟用源數(shù)據(jù)庫(kù)實(shí)例的自動(dòng)備份。要使只讀副本能夠運(yùn)行,必須保持備份的啟用狀態(tài)。借助 Amazon RDS for MySQL、MariaDB、PostgreSQL 和 Oracle,最多可為給定的源數(shù)據(jù)庫(kù)實(shí)例創(chuàng)建 5 個(gè)只讀副本。Amazon RDS 支持跨區(qū)域只讀副本。數(shù)據(jù)寫入源數(shù)據(jù)庫(kù)實(shí)例與數(shù)據(jù)在只讀副本上可用之間的時(shí)間長(zhǎng)度取決于兩個(gè)區(qū)域之間的網(wǎng)絡(luò)延遲,只讀副本使用這些引擎的本機(jī)異步復(fù)制執(zhí)行。Amazon Aurora 使用的是一種不同但仍然是異步的復(fù)制機(jī)制。

10 HA

10.1 Load balancers

AWS上有3中不同類型的負(fù)載均衡器

· Application Load balancersàALB, 最適合于http & https流量的負(fù)載均衡,工作在layer7,即應(yīng)用層。你可以創(chuàng)建高級(jí)路由請(qǐng)求,將特定的請(qǐng)求發(fā)送到指定的 web server; ALBs are redundant across at least two subnets.

· Network Load balancersàNLB, 最適合于需要極端性能的TCP 流量的負(fù)載均衡,工作在網(wǎng)絡(luò)層(layer4),NLB能夠處理每秒百萬(wàn)級(jí)的請(qǐng)求,同時(shí)能維持極低的延遲。Network load balancers can handle the extremely high request load

· Classic Load balancersà ELB,這是傳統(tǒng)的彈性負(fù)載均衡器,可以均衡 http/https應(yīng)用層,如x-forward 和sticky會(huì)話;對(duì)于完全依賴于TCP協(xié)議的應(yīng)用程序,也可以用于嚴(yán)格的layer4負(fù)載均衡。

An ALB offers SSL termination and makes the SSL offload process very simple through tight integration with SSL processes. While an ELB will handle SSL termination, it does not offer the management features that ALBs do.

ALBs offer the most flexibility in routing and load distribution.

Classic load balancers support both IPv4 and IPv6. They support HTTP/1 and HTTP/1.1, but only application load balancers support HTTP/2. Further, you must register individual instances, rather than target groups, with classic load balancers; registering target groups is a functionality only available with application load balancers.

如果你的應(yīng)用程序停止了響應(yīng),ELB將響應(yīng)504 error。這意味著應(yīng)用程序有問(wèn)題,這可能是web server的問(wèn)題,也可能是 database的問(wèn)題。失敗應(yīng)用程序的故障點(diǎn),如果可能,可以進(jìn)行橫向或縱向擴(kuò)展。

· 被ELB監(jiān)控的實(shí)例都會(huì)上報(bào) InService, or OutService

· 健康檢查通過(guò)域?qū)嵗换z查實(shí)例健康狀況

· 負(fù)載均衡器有他們自己的DNS 名稱,不需要指定IP

Figure 42 No Cross AZ LB

Figure 43 Cross AZ LB

Figure 44 Cross AZ LB1

高級(jí)負(fù)載均衡器理論:

· ELB將每個(gè)請(qǐng)求獨(dú)立地路由到負(fù)載最小的已注冊(cè)的EC2實(shí)例

· 跨區(qū)負(fù)載均衡器,使你能夠跨越多個(gè)可用區(qū)進(jìn)行負(fù)載均衡

· Path patterns允許你根據(jù)請(qǐng)求中包含的url將流量定向到不同的EC2實(shí)例

Figure 45 Path pattern

· Sticky session允許你將用戶的會(huì)話綁定到特定的EC2實(shí)例。這確保了在會(huì)話期間來(lái)自用戶的所有請(qǐng)求都會(huì)發(fā)送到同樣的instance

· 你也可以為ALB啟用sticky session,但是流量會(huì)被發(fā)送到目標(biāo)組級(jí)別

· ALBs are redundant across at least two subnets.

Figure 46 sticky session

ELB

· Pre-Warming

· Connection Draining

· Client-Side SSL certificates

· Server Order Preference

· Cross-Zone

· SSL termination

· ELB HTTPS listener does not support Client-Side SSL certificates

10.2 Auto scaling group

通過(guò)使用 AWS Auto Scaling,您可以在幾分鐘內(nèi)為作為您的應(yīng)用程序的AWS 資源配置自動(dòng)擴(kuò)展。AWS Auto Scaling 控制臺(tái)提供了一個(gè)單一的用戶界面,可以統(tǒng)一管理多個(gè) AWS 服務(wù)的自動(dòng)擴(kuò)展功能。您可以為單個(gè)資源或整個(gè)應(yīng)用程序配置自動(dòng)擴(kuò)展。

AWS Auto Scaling 對(duì)流量存在每日或每周變化的應(yīng)用程序很有用,這包括:

· 周期性流量,例如正常營(yíng)業(yè)時(shí)間內(nèi)的高資源利用率和夜間的低資源利用率

· 打開和關(guān)閉工作負(fù)載模式,例如批處理、測(cè)試或定期分析

· 可變的流量模式,例如具有峰值增長(zhǎng)的營(yíng)銷活動(dòng)

對(duì)于auto scaling,用戶是希望每次伸縮都遵從一定的規(guī)則,比如說(shuō)基于CPU、memory、Disk的使用量,達(dá)到某個(gè)閾值在多長(zhǎng)時(shí)間范圍內(nèi),自動(dòng)彈起或關(guān)閉一定數(shù)量的instance,并進(jìn)行健康檢查。新的instance和existing instance 提供同樣的服務(wù),從而提高系統(tǒng)性能。

新建ASG launch configuration,這相當(dāng)于是為以后彈起的實(shí)例做了一個(gè)template,這就需要你按照業(yè)務(wù)需求,對(duì)實(shí)例進(jìn)行相應(yīng)的配置。

Figure 47 Create launch configuration

新建伸縮組ASG,這里需要指定已有的launch configuration,VPC及subnet(AZ)??紤]到高可用,可以指定幾個(gè)AZ。

Figure 48 Create ASG

進(jìn)一步設(shè)置 scaling policy, 包括范圍,實(shí)例數(shù)量,伸縮指標(biāo)等。

Figure 49 Config ASG

配置好以后的實(shí)際效果

Figure 50 ASG example

Exam tips:

· When creating an Auto Scaling group, you can specify the minimum and maximum size as well as a desired capacity and scaling policy. You cannot specify how many instances to add at once, nor the desired cost.

· While you can specify triggers that are used to grow or shrink the group, you can not specify a memory allocation or a minimum processing threshold (neither is an actual AWS term).

· A launch configuration contains an AMI ID, key pair, instance type, security groups, and possibly a block device mapping.

· A launch configuration needs a single AMI ID to use for all instances it launches.

· There are a number of valid scaling policies for Auto Scaling: Maintain current instance levels, manual scaling, schedule-based scaling, and demand-based scaling

§ You can choose to maintain current instance level at all times. This is essentially ensuring that no instances are added unless an instance fails its health checks and needs to be restarted or replaced.

§ Demand-based scaling allows you to specify parameters to control scaling. One of those parameters can be CPU utilization, so this is the policy you’d use for this use case.

§ Schedule-based scaling allows you to specify a particular time period during which resources should scale up or down.

§ Manual scaling allows you to specify a minimum and maximum number of instances as well as a desired capacity. The Auto Scaling policy then handles maintaining that capacity.

autoscaling

· Scheduled scaling cannot be overlap

· choose greatest impact when Multiple Policies

· cooldown period

· Termination Policy

10.3 API gateway

只需要在AWS管理控制臺(tái)中的幾次點(diǎn)擊,你就可以創(chuàng)建一個(gè)API當(dāng)作“前門”,為應(yīng)用程序訪問(wèn)數(shù)據(jù)、業(yè)務(wù)邏輯或從后臺(tái)服務(wù)的功能,如應(yīng)用程序運(yùn)行在AWS EC2上,代碼運(yùn)行在AWS lambda上或任意的web 應(yīng)用程序。

API網(wǎng)關(guān)的功能特性:

· 暴露https endpoint來(lái)定義RESTful API

· 無(wú)服務(wù)器地連接到類似Lambda和DynamoDB

· 將每個(gè)API endpoint發(fā)送到不同的目標(biāo)

· 低成本高效運(yùn)行

· 輕松伸縮

· 通過(guò)API key追蹤和控制使用情況

· 限制請(qǐng)求以防止攻擊

· 連接到CloudWatch記錄所有請(qǐng)求,用于監(jiān)控

· 維護(hù)多版本的API

如何配置API網(wǎng)關(guān):

· 定義API(容器)

· 定義資源和嵌套資源 (url路勁)

· 為每個(gè)資源

§ 選擇受支持的http方法

§ 設(shè)置安全

§ 選擇目標(biāo),如EC2, Lambda,DynamoDB等

§ 設(shè)置請(qǐng)求和響應(yīng)轉(zhuǎn)換

Same origin policy--同源策略

在計(jì)算中,同源策略是web應(yīng)用程序安全模型中的一個(gè)重要概念。根據(jù)該策略,web瀏覽器允許包含在第一個(gè)web頁(yè)面中的腳本訪問(wèn)第二個(gè)web頁(yè)面中的數(shù)據(jù),但前提是兩個(gè)web頁(yè)面具有相同的來(lái)源。這樣做是為了防止跨站點(diǎn)腳本攻擊

· 由web瀏覽器強(qiáng)制執(zhí)行

· 被Postman和curl這樣的工具忽略

CORS—Cross-origin resource sharing是另一端的服務(wù)器(而不是瀏覽器中的客戶端代碼)輕松訪問(wèn)同源策略的一種方式??缳Y源共享是一種機(jī)制,它允許從提供第一個(gè)資源的域之外的另一個(gè)域請(qǐng)求web頁(yè)面上的受限資源,例如fonts。

API網(wǎng)關(guān)考試提示:

· 記住API網(wǎng)關(guān)是High level的

· API 網(wǎng)關(guān)有緩存功能,以提高性能

· 低成本,可自動(dòng)擴(kuò)展

· 限制請(qǐng)求以防止攻擊

· 可以將結(jié)果記錄到CloudWatch

· 如果使用Javascript/AJAX,使用多域名的API網(wǎng)關(guān),確保啟用了CORS

· 客戶端可強(qiáng)制執(zhí)行CORS

10.4 HA—High Availability

HA—高可用,其設(shè)計(jì)目的是用于故障轉(zhuǎn)移和災(zāi)難恢復(fù)。如果條件允許,盡可能將你的應(yīng)用程序部署在不同的AZ,甚至在不同的region。一般情況,HA的設(shè)計(jì)至少含3個(gè)AZ,可以容忍其中的某個(gè)AZ故障,程序仍可以正常對(duì)外提供服務(wù)。

記住一下幾點(diǎn):

· HA總是為故障而設(shè)計(jì)

· 盡可能使用多個(gè)AZ和多個(gè)region

· 了解RDS Multi-AZ和 Read replicas之間的區(qū)別

§ Multi-AZ: 為了故障轉(zhuǎn)移和災(zāi)難恢復(fù)

§ Read replicas: 為了提升讀取性能

· 了解橫向擴(kuò)展和縱向擴(kuò)展的區(qū)別

§ 橫向擴(kuò)展:增加配置相同的機(jī)器,計(jì)算能力和帶寬同時(shí)擴(kuò)展

§ 縱向擴(kuò)展:增加本身機(jī)器的配置,如CPU, memory,可能會(huì)有網(wǎng)絡(luò)瓶頸

Figure 51 HA architecture

11 CloudFormation, Elastic Beanstalk and Lambda

11.1 CloudFormation

CloudFormation的好處:

· 基礎(chǔ)設(shè)施代碼(Infrastructure as code)

§ 不需要手動(dòng)創(chuàng)建資源,這對(duì)控制非常好

§ 可以使用git對(duì)代碼進(jìn)行版本控制

§ 對(duì)Infrastructure的更改,通過(guò)代碼進(jìn)行審查

· 成本 cost

§ 棧(stacks)中的每個(gè)資源都用一個(gè)標(biāo)識(shí)符標(biāo)記,因此你很容易看到一個(gè)棧要花費(fèi)多少錢

§ 你可以通過(guò)CloudFormation模板來(lái)估算資源成本

§ 節(jié)約策略:在開發(fā)中,你可以在下午5點(diǎn)自動(dòng)刪除模板,并在早上8點(diǎn)安全地重新創(chuàng)建

· Productivity

§ 能夠在云上破壞和重建一個(gè)infrastructure

§ 為你的模板自動(dòng)生成圖表(diagram)

§ 聲明式編程,不需要確定順序和編制

· 關(guān)注分離(separation): 為許多apps 和 layers創(chuàng)建許多堆棧(stacks)

§ VPC stacks

§ Network stacks

§ APP stacks

· 不用重新開發(fā) don’t re-invent the wheel

§ 利用web上現(xiàn)有的模板

§ 利用文檔

CloudFormation如何工作:

· 模板必須在S3中上傳,然后在CloudFormation中引用

· 要更新模板,我們不能編輯以前的版本,我們必須要上傳新版的模板到AWS

· Stacks通過(guò)名稱來(lái)標(biāo)識(shí)

· 刪除stack,將刪除由CloudFormation創(chuàng)建的每個(gè)組件

· CloudFormation模板部署

§ 手動(dòng)方式

§ 在CloudFormation設(shè)計(jì)器中編輯模板

§ 使用控制臺(tái)輸入?yún)?shù)

§ 自動(dòng)方式

§ 在YAML文件中編輯模板

§ 使用AWS CLI 部署模板

§ 當(dāng)你完全想要你的流程自動(dòng)化時(shí),推薦此方法

· CloudFormation的構(gòu)建模塊

§ 模板組件

§ 資源:在模板中聲明的AWS 資源 (Mandatory)

§ 參數(shù):模板動(dòng)態(tài)輸入

§ Mapping: 模板的靜態(tài)變量

§ 輸出: 參考已創(chuàng)建的內(nèi)容

§ 條件:列出對(duì)資源創(chuàng)建的條件

§ Metadata—元數(shù)據(jù)

§ 模板幫助器

§ 參考

§ 功能

CloudFormation allows you to automate provisioning and, in this case, to create standardized JSON scripts that can be lightly modified to stand up entire stacks for multiple applications that share a common structure.

By default, CloudFormation ensures all or nothing deployment. If there is an error at any step and CloudFormation is not able to proceed, then it will remove all AWS resources in a stack that were created by CloudFormation

11.2 Elastic Beanstalk

AWS Elastic Beanstalk 讓開發(fā)人員能夠更加輕松地在 AWS 云中快速部署和管理應(yīng)用程序。開發(fā)人員只需上傳應(yīng)用程序,Elastic Beanstalk 將自動(dòng)處理容量預(yù)配置、負(fù)載均衡、Auto Scaling 和應(yīng)用程序運(yùn)行狀況監(jiān)控的部署細(xì)節(jié)。

Elastic Beanstalk 支持在 Go、Java、.NET、Node.js、PHP、Python 和 Ruby 中開發(fā)的應(yīng)用程序。當(dāng)您部署應(yīng)用程序時(shí),Elastic Beanstalk 構(gòu)建選定的受支持的平臺(tái)版本并預(yù)置一個(gè)或多個(gè) AWS 資源(如 Amazon EC2 實(shí)例)來(lái)運(yùn)行您的應(yīng)用程序。您可以使用 Elastic Beanstalk 控制臺(tái)、AWS Command Line Interface (AWS CLI) 或 eb(為 Elastic Beanstalk 專門設(shè)計(jì)的高級(jí) CLI)與 Elastic Beanstalk 進(jìn)行交互。

Figure 52 Elastic Beanstalk work flow

AWS CloudFormation 與 AWS Elastic Beanstalk 有什么區(qū)別?

這些服務(wù)的設(shè)計(jì)目的是使二者相輔相成。AWS Elastic Beanstalk 提供了一個(gè)可在云中輕松部署和運(yùn)行應(yīng)用程序的環(huán)境。它與開發(fā)人員工具相集成,為您提供“一站式”的應(yīng)用程序生命周期管理體驗(yàn)。AWS CloudFormation 是一種便捷的預(yù)置機(jī)制,支持種類廣泛的 AWS 和第三方資源。它支持許多不同類型的應(yīng)用程序的基礎(chǔ)設(shè)施需求,如現(xiàn)有的企業(yè)級(jí)應(yīng)用程序、舊式應(yīng)用程序、使用各種 AWS 資源構(gòu)建的應(yīng)用程序,以及基于容器的解決方案(包括使用 AWS Elastic Beanstalk 構(gòu)建而成的解決方案)。

AWS CloudFormation 支持 Elastic Beanstalk 應(yīng)用程序環(huán)境,將其作為其中一種 AWS 資源類型。例如,這可使您創(chuàng)建和管理 AWS Elastic Beanstalk 托管的應(yīng)用程序,以及用于存儲(chǔ)應(yīng)用程序數(shù)據(jù)的 RDS 數(shù)據(jù)庫(kù)。除了 RDS 實(shí)例,還可向該組添加任何其他受支持的 AWS 資源。

Exam tips:

§ Elastic Beanstalk is focused on code deployment. It provides that, and in the process, load balancing, Auto Scaling, health monitoring, and capacity provisioning

§ Elastic Beanstalk is an Amazon service that spins up and manages a number of other services, in particular, compute. Even though you can configure other services, though, Beanstalk is considered to primarily be a code deployment tool and therefore is focused on compute services.

§ Elastic Beanstalk can deploy your code and handle capacity provisioning, load balancing, and setting up Auto Scaling and health checks, all with very little oversight. Note that you’d still need personnel to keep an application like this running, but Elastic Beanstalk can reduce initial resources needed for application deployment.

§ Rolling deployment – Updates a batch of instances. Each batch is taken out of service and available capacity is reduced by the number of instances in the batch. All at once deploys new version to all instances simultaneously. Instances are out of service for a short period. Rolling with additional batch – Launches additional batch of instances to maintain full capacity during deployment. It deploys version in batches. Immutable – Deploys new version to a fresh set of instances

11.3 Lambda

Lambda基礎(chǔ)

Lambda是最終的提取層:

· 數(shù)據(jù)中心

· 硬件

· 匯編代碼/協(xié)議

· 高級(jí)語(yǔ)言

· 操作系統(tǒng)

· 應(yīng)用層 /AWS APIs

· AWS lambda

你可以用以下方式來(lái)使用lambda:

· 作為一個(gè)事件驅(qū)動(dòng)的計(jì)算服務(wù),AWS運(yùn)行你的代碼以響應(yīng)事件。這些事件可以是對(duì)Amazon S3 bucket或Amazon DynamoDB表中的數(shù)據(jù)更改

· 作為一個(gè)計(jì)算服務(wù),運(yùn)行你的代碼以響應(yīng)使用API網(wǎng)關(guān)的HTTP請(qǐng)求或使用AWS sdk進(jìn)行的API調(diào)用。

Figure 53 Lambda classic

傳統(tǒng)架構(gòu) vs 無(wú)服務(wù)器架構(gòu)

Figure 54 Traditional vs serverless

Lambda考試提示:

· Lambda自動(dòng)進(jìn)行橫向擴(kuò)展,而不是縱向

· Lambda功能是獨(dú)立的,一個(gè)事件=一個(gè)功能

· Lambda是serverless

· Lambda功能可以觸發(fā)其他Lambda功能,這也就意味著一個(gè)事件可以等于多個(gè)功能

· Lambda架構(gòu)可以變得極其復(fù)雜,AWS X-ray允許你調(diào)試正在發(fā)生的事件

· Lambda可以做全局的事情,你可以用它把S3 bucket 備份到其他S3 bucket

· 清楚知道你的觸發(fā)器是什么

· By default, Lambda allows 1000 concurrent executions across all functions within a region. You can increase this limit by contacting support.

· By default, Lambda allows outbound calls to internet

· With Lambda, you have to choose amount of memory needed to execute your function. Based on the memory configuration, proportional CPU capacity is allocated.

· Lambda support versioning and you can maintain one or more versions of your lambda function. Each lambda function has a unique ARN. Lambda also supports Alias for each of your functions. Lambda alias is a pointer to a specific lambda function version. Alias enables you to promote new lambda function versions to production and if you need to rollback a function, you can simply update the alias to point to the desired version. Event source needs to use Alias ARN for invoking the lambda function.

Serverless website 案例

Figure 55 Serverless website example

12 Mornitoring

13 Other services

13.1 AWS Organizations

· 全局服務(wù)

· 允許管理多個(gè)AWS賬戶

· 主賬號(hào)是master account,你不能更改

· 其他賬戶是member account

· member account只能是一個(gè)organization的一部分

· 跨所有賬戶合并賬單à單一付款方法

· 從合并用量中得到價(jià)格優(yōu)惠(容量打折)

· API 可以用于自動(dòng)創(chuàng)建AWS 賬戶

OU & Service control policies (SCPs)

· Organization account 在organization unit(OU)中

§ 可以是任何事: dev/test/prod or finance /HR/IT

§ 可以嵌套OU

· 將SCPs用于OU

§ 允許/拒絕訪問(wèn)AWS

§ SCP的語(yǔ)法類似于IAM

§ 它是對(duì)IAM 的過(guò)濾

· 有助于創(chuàng)建 sandbox賬戶

· 有助于分離開發(fā)和產(chǎn)品資源

· 有助于只允許已批準(zhǔn)的服務(wù)

Figure 56 OU nest

13.2 AWS WorkSpaces

· 托管的,安全的云桌面

· 極大地消除了On-promise VDI的管理 VDI(Virtual desktop infrastructure)

· 按需的,根據(jù)使用付費(fèi) pay as you go

· 安全,加密,網(wǎng)絡(luò)隔離

· 與Microsoft Access Directory 集成

Figure 57 WorkSpaces

13.3 AWS AppSync

· 通過(guò)移動(dòng)和web應(yīng)用程序?qū)崟r(shí)存儲(chǔ)和同步數(shù)據(jù)

· 使用GraphQL (來(lái)自Facebook的移動(dòng)技術(shù))

· 客戶端代碼可自動(dòng)生成

· 實(shí)時(shí)訂閱

· 與DynamoDB / Lambda集成

· 離線數(shù)據(jù)同步 (代替Cognito 同步)

· 細(xì)粒度安全

13.4 AWS Single Sign On (SSO)

· 跨多個(gè)AWS賬戶和業(yè)務(wù)程序(office365,salesforce,box),集中管理單點(diǎn)登錄

· 一次登錄就能讓你安全地訪問(wèn)所有東西

· 與Microsoft Access Directory 集成

· 有助于減少公司設(shè)立SSO的過(guò)程

· 只對(duì) web 瀏覽器有幫助,支持SAML2.0 的應(yīng)用程序

13.5 ECSàElastic Container Service

13.5.1 ECS concept

ECS Cluster: 一系列EC2實(shí)例

ECS Service: 運(yùn)行在 ECS cluster上的應(yīng)用程序定義

ECS task + definition: 運(yùn)行容器用于創(chuàng)建應(yīng)用程序

ECS IAM roles: 分配給tasks的角色,用于與AWS交互

Figure 58 ECS cluster

· ECS是一個(gè)容器編制服務(wù)

· ECS幫助你在EC2實(shí)例上運(yùn)行docker容器

· ECS比較復(fù)雜,由以下組成:

§ ECS core:運(yùn)行ECS在用戶提供的EC2實(shí)例是

§ Fargate: 在由AWS 提供的計(jì)算服務(wù)上運(yùn)行ECS task (serverless)

§ EKS: 在AWS 驅(qū)動(dòng)的K8S(跑在EC2上) 上運(yùn)行ECS

§ ECR: 由AWS托管的docker 容器注冊(cè)表

· ECS和Docker都是非常流行的微服務(wù)

· 目前只有ECS core和ECR 在考試范圍

· IAM 和角色是在ECS任務(wù)級(jí)

· ECS Scheduler is responsible for placing the tasks on container instances. Service is where you configure long running tasks and how many containers you need.

· For each task copy, containers that are defined as part of a single task definition are placed together.

13.5.2 Docker

· Docker是一個(gè)容器技術(shù)

· 運(yùn)行容器程序在任意安裝了Docker的機(jī)器上

· 容器允許我們的運(yùn)用程序以相同的方式運(yùn)行在任何地方

· 容器是相互隔離的

· 你可控制分配容器的CPU和內(nèi)存

· 能夠做網(wǎng)絡(luò)規(guī)則限制

· 比虛擬機(jī)效率高

· 容器能看快速伸縮(秒級(jí))

AWS ECS use case

· 運(yùn)行微服務(wù)

§ 能夠在同一機(jī)器上運(yùn)行多個(gè)docker容器

§ 對(duì)于通訊增強(qiáng),可以輕松實(shí)現(xiàn)服務(wù)恢復(fù)

§ 直接與ALB集成

§ 自動(dòng)伸縮

· 運(yùn)行批處理 / 定時(shí)任務(wù)

§ 計(jì)劃ECS 容器來(lái)運(yùn)行 On-demand / reserved / spot 實(shí)例

· 遷移應(yīng)用程序到云上

§ 對(duì)在本地運(yùn)行的遺留應(yīng)用程序進(jìn)行dockerize (容器化)

§ 將docker容器移到ECS上運(yùn)行

13.5.3 AWS ECS 與ALB的集成:

· ALB與ECS 有直接集成的特性,叫“port mapping”端口映射

· 這允許由相同應(yīng)用程序的實(shí)例在同一個(gè)EC2機(jī)器上

· Use cases

§ 增加彈性,即時(shí)運(yùn)行在一個(gè)EC2 實(shí)例上

§ 最大化 CPU / cores的利用率

§ 能夠執(zhí)行升級(jí)回滾,而不影響應(yīng)用程序的運(yùn)行

Figure 59 ECS-ALB

ECS setup & config file

運(yùn)行EC2實(shí)例,安裝ECS代理和配置文件

使用ECS-Ready的AMI,也需要修改配置文件

ECS 配置文件: /etc/ecs/ecs.config

13.5.4 ECRàElastic Container Registry

· 在AWS 上存儲(chǔ),管理和部署你的容器

· 完全與IAM & ECS集成

· 用HTTPS 傳輸和靜態(tài)加密

Figure 60 ECR workflow

13.6 Amazon EMR

· EMRà Elastic MapReduce

· EMR幫助創(chuàng)建Hadoop集群(大數(shù)據(jù)),用于分析和處理大量數(shù)據(jù)

· 集群可由上百個(gè)EC2實(shí)例組成

· 支持Apache Spark,Hbase, Presto, Flink ……….

· EMR關(guān)注所有的Provisioning 和 configuration

· 自動(dòng)伸縮和與spot實(shí)例集成

· Use case: 數(shù)據(jù)處理,機(jī)器學(xué)習(xí),web 檢索,大數(shù)據(jù)

13.7 AWS Step Function

· 對(duì)編排的你的lambda function,構(gòu)建無(wú)服務(wù)器的可視化workflow

· 代表流為JSON 狀態(tài)機(jī)

· 特點(diǎn): 順序執(zhí)行,并行,條件,timeouts,錯(cuò)誤處理……

· 可以與EC2, ECS, On premise servers, API 網(wǎng)關(guān)集成

· 最大執(zhí)行時(shí)間是1年

· 有能力實(shí)施人為批復(fù)特性

· Use cases

§ 順序執(zhí)行 order fulfillment

§ 數(shù)據(jù)處理

§ Web 應(yīng)用程序

§ 任意workflow

Figure 61 Step function

13.8 AWS SWF – Simple workflow service

SWF是一種web 服務(wù),它可以方便地跨分布式應(yīng)用程序組件協(xié)調(diào)工作。SWF支持一序列的應(yīng)用程序,包括media處理,web程序后端,業(yè)務(wù)流程工作流和分析 pipeline,將其設(shè)計(jì)為任務(wù)的協(xié)調(diào)。任務(wù)表示應(yīng)用程序中的各種處理步驟,可由可執(zhí)行代碼、web服務(wù)調(diào)用、人工操作和腳本執(zhí)行。

· 協(xié)調(diào)運(yùn)用程序間的工作

· 代碼運(yùn)行在EC2上( not serverless)

· 最長(zhǎng)運(yùn)行時(shí)間是1年

· “Activity step” 和 “Decision step”

· 有人為干預(yù)的步驟

· 從web到warehouse交付是順序執(zhí)行的

· 對(duì)新的應(yīng)用程序,推薦使用step function, 除了:

§ 如果你需要外部信號(hào)在過(guò)程中進(jìn)行干預(yù)

§ 如果你需要返回值到父進(jìn)程的子進(jìn)程

SWF Actors

· Workflow starters--- 可以初始化啟動(dòng)工作流的應(yīng)用程序,這可以是電子商務(wù)網(wǎng)站下的訂單,也可以是移動(dòng)app 搜索公交時(shí)間等

· Deciders---控制工作流執(zhí)行中的活動(dòng)任務(wù)流,如果工作流中的某個(gè)任務(wù)完成或失敗了,Decider將決定下一步要做什么

· Activity workers---執(zhí)行活動(dòng)任務(wù)

Exam tips:

· SWF provides an API, but it is neither the AWS-specific API nor language specific. Instead, SWF supports standard HTTP requests and responses.

· SWF is typically thought of as an asynchronous service, but it also supports synchronous tasking when needed.

· A SWF domain is a collection of related workflows.

13.9 SQSà simple queue service

· SQS 是基于pull,而不是push

· 消息大小256kb

· 消息可以在隊(duì)列里保留從1分鐘到14天,缺省條件下的保存期是4天

· 可見超時(shí),是指讀取器獲取消息后,消息在SQS中是不可見的時(shí)間量。如果在可見超時(shí)過(guò)期前處理作業(yè),則消息將從隊(duì)列中刪除。如果在這段時(shí)間內(nèi)沒(méi)有處理作業(yè),則消息將再次可見,另一個(gè)讀取器將處理它。這可能導(dǎo)致相同消息被傳遞兩次

· 可見超時(shí)最長(zhǎng)12小時(shí)

· SQS保證你的消息將至少被處理一次

· SQS 長(zhǎng)輪詢是一種從SQS檢索消息的方法。常規(guī)的短輪詢是立即返回的,即使正在輪詢的消息隊(duì)列是空的,而長(zhǎng)輪詢直到消息到達(dá)消息隊(duì)列或長(zhǎng)輪詢超時(shí)才返回響應(yīng)

· QS queues only make an “attempt” to deliver messages in order (more or less a FIFO approach) but do not guarantee FIFO. If strict FIFO is needed, that option can be selected.

SWF vs SQS

· SQS的最長(zhǎng)保存期14天,SWF工作流執(zhí)行最多可持續(xù)1年

· SQS 提供一個(gè)面向消息message-oriented的API, SWF 提供一個(gè)面向任務(wù)task-oriented的API

· 使用SQS,需要處理重復(fù)消息,這可能需要確保消息只能被處理一次;SWF確保任務(wù)只分配一次,并且不會(huì)重復(fù)

· 使用SQS,你要實(shí)現(xiàn)自己的應(yīng)用程序級(jí)的跟蹤,特別是在應(yīng)用程序使用多個(gè)隊(duì)列的情況下, SWF跟蹤應(yīng)用程序中的所有任務(wù)和事件

13.10 SNS

· SNS--- Simple notification service

· 及時(shí)的,基于push的交付(無(wú)輪詢)

· 簡(jiǎn)單的APIs和易于集成的應(yīng)用程序

· 靈活的消息傳遞,多傳輸協(xié)議

· 便宜,按需付費(fèi),不用預(yù)付

· 基于web 的AWS 管理console,提供簡(jiǎn)單的 point-and-click接口

SNS vs SQS

· 都是AWS的消息服務(wù)

· SNS-- Push

· SQS—Pull

Messages in SWF are tasks; messages in SQS are messages; messages in SNS are notifications

13.11 Elastic transcoder

· 云上的media 編碼器

· 將media 從其原始格式轉(zhuǎn)換到不同的格式,可以在智能手機(jī)、平板電腦、個(gè)人電腦等上播放的不同格式

· 提供流行的輸出格式編碼預(yù)置,這意味著你不需要的猜測(cè)哪些設(shè)置在特使設(shè)備上工作的最好

· 根據(jù)你轉(zhuǎn)碼的分鐘數(shù)和轉(zhuǎn)碼的分辨率來(lái)支付

Figure 62 Elastic transcoder workflow

13.12 Kinesis

流式數(shù)據(jù)是由數(shù)千個(gè)數(shù)據(jù)源連續(xù)生成的數(shù)據(jù),這些數(shù)據(jù)源通常是同時(shí)發(fā)送數(shù)據(jù)記錄,并且是小尺寸的(kb 順序),如:

· 網(wǎng)購(gòu)

· 股票價(jià)格

· 游戲數(shù)據(jù)

· 社交網(wǎng)絡(luò)數(shù)據(jù)

· 地理空間數(shù)據(jù)(uber,didi)

· IoT傳感器數(shù)據(jù)

Kinesis是AWS上一個(gè)處理流式數(shù)據(jù)的平臺(tái),使加載和分析流數(shù)據(jù)變得容易,還提供了為業(yè)務(wù)需求構(gòu)建自定義應(yīng)用程序的能力。3種不同形式的kinesis:

· Kinesis stream

· Kinesis firehose

· Kinesis analytics

Kinesis Streams has a maximum retention of 7 days and Kinesis Firehose has a retention of 1 day

Figure 63 Kinesis stream

Kinesis stream 由shards組成:

· 對(duì)于讀取,每秒5個(gè)事務(wù),最大的總數(shù)據(jù)讀取速率為 每秒2MB

· 對(duì)于寫,每秒最多1000條記錄,最大的總數(shù)據(jù)寫速率為 每秒1MB,包括分區(qū)鍵

· Stream的數(shù)據(jù)容量是指定流的shards數(shù)量的函數(shù),總?cè)萘渴莝hards容量的總和

Figure 64 Kinesis Firehose

Kinesis stream數(shù)據(jù)可以持久,而Kinesis firehose 數(shù)據(jù)不能持久。

Figure 65 Kinesis Analytics

Figure 66 Kinesis components comparison

Kinesis Data Streams

Real-time data capture

Ingest and store data streams from hundreds of thousands of data sources:

  • Log and event data collection
  • IoT device data capture
  • Mobile data collection
  • Gaming data feed

Kinesis Data Firehose

Load real-time data

Load streaming data into data lakes, data stores, and analytics tools for:

  • Log and event analytics
  • IoT data analytics
  • Clickstream analytics
  • Security monitoring

Kinesis Data Analytics

Get insights in real time

Analyze streaming data and gain actionable insights in real time:

  • Real-time streaming ETL
  • Real-time log analytics
  • Ad tech and digital marketing analytics
  • Real-time IoT device monitoring

13.13 CloudFront

Delivery

· Request-Route53-edge location-Origin server

· Supports both static and dynamic content

RMTPà Real Time Messaging Protocol(實(shí)時(shí)消息傳輸協(xié)議)

· S3 bucket as the origin

· users view media files using the media player that is provided by cloudfront; not the locally installed

· Web distribution for media Player and RMTP distribution for media files

· private content

· OAIà Origin Access Identity

· add header in http server, Origin to verify the request has come from CloudFront

· feature

· signed URLs and signed cookies

· for RTMP distribution

· restrict access to individual files

· access to multiple restricted files

Caching Based on Request Headers

Geo Restriction

Compressed Files

· Content-Encoding header on the file must not be gzip

· viewer uncompresses the file

· multi-upload to S3

SNI

Server Name Indication, 同一個(gè)IP可用選擇多個(gè)hostname, 用自己的SSL證書時(shí)選擇,一般是客戶端瀏覽器的選項(xiàng)

Dedicated IP

專屬主機(jī)IP,不和其他hostname共用,傳統(tǒng)SSL使用,現(xiàn)在大部分用SNI

https with S3, s3不能獨(dú)立用https, 但是結(jié)合cloudfront, 用 ACMà Amazon Certificate Manager 生成的證書可以通訊

Price

· Charge with: data out, request, Invalidation request, SSL certificates

· CloudFront is intended to cache and deliver static files from your origin servers to users or clients. Dynamic content is also servable through CloudFront from EC2 or other web servers. as CloudFront is a distribution mechanism, not a storage facility.

· Edge locations are used by CloudFront distributions to store cached content, EC2 instances can serve content from processes.

· CloudFront is AWS’s distribution network. It’s a content caching system that is ultimately a networking component of your AWS buildout.

· CloudFront can front a number of AWS services: AWS Shield, S3, ELBs (including ALBs), and EC2 instances. It also most recently supports Lambda@Edge as an origin.

· As CloudFront is typically associated with performance, and not a lot else. However, CloudFront also provides deep integration with many managed AWS services, such as S3, EC2, ELBs, and even Route53

· CloudFront automatically provides AWS Shield (standard) to protect from DDoS, and it also can integrate with AWS WAF and AWS Shield advanced. These combine to secure content at the edge. HTTPS is not required, and there is no KMS involvement with CloudFront.

· Edge locations number more than both regions and availability zones

· CloudFront is easy to set up and lets you create a global content delivery network without contracts. It’s also a mechanism for distributing content at low latency. Creating websites and the actual file storage are not features of CloudFront but of LightSail (for example) and S3, respectively.

· When you create a CloudFront distribution, you register a domain name for your static and dynamic content. This domain should then be used by clients.

· CloudFront will always handle requests that it receives. It will either return the requested content if cached or retrieve that content by requesting it from an origin server. It will not redirect the client, nor will it pass the request on directly.

· There is no charge associated with data moving from any region to a CloudFront edge location.

· CloudFront can store and serve both static (HTML and CSS) and dynamic (PHP,) content. SQL queries cannot be directly returned, nor can an actual Lambda function. You can front the result of a Lambda@Edge function, but not the function itself.

· An edge location is a data center that delivers CloudFront content. Edge locations are spread across the world.

· A distribution is the setup including your origin servers and how the content from those servers is distributed via CloudFront. It does not specifically refer to cached content at any given point in time.

· Edge locations check for updated content every 24 hours by default, but this value can be changed.

· Edge locations can be set to have a 0-second expiration period, which effectively means no caching occurs.

· RDS instances cannot be origin servers

· A collection of edge locations is a distribution.

· An RTMP distribution is the Adobe Real-Time Messaging Protocol and is suitable for using S3 buckets as an origin server to serve streaming media

· CloudFront supports both web distributions and RTMP distributions.

· An Origin Access Identity is a special user that you will set up the CloudFront service to use to access you restricted content

· The invalidation API is the fastest way to remove a file or object, although it will typically incur additional cost.

· While edge locations are typically read from by clients, they are also writeable. You can store objects on edge locations as well as read from them.

· CloudFront will always handle requests that it receives. It will either return the requested content if cached (A) or retrieve that content by requesting it from an origin server (C). It will not redirect the client (D), nor will it pass the request on directly (B).

13.14 CloudWatch

CloudWatch provides disk read operations, CPU usage, and inbound network traffic but does not provide memory usage by default.

13.15 WAF & Shield

A PUT request is used for establishing a session with IMDS version 2. In response, IMDS issues a session token that is valid for TTL specified in the PUT call. With IMDS v2, all calls to metadata service must include the token in the X-aws-ec2-metadata-token header. PUT is used as several firewalls, and proxies do not forward PUTs. Besides, IMDS V2 does not issue a token when the PUT request has an X-Forwarded-For header.

13.15.1 WAFà Web Application Firewall

AWS WAF Protect your web applications from common web exploits

AWS WAF is a web application firewall service that lets you monitor web requests that are forwarded to an Amazon API Gateway API, an Amazon CloudFront distribution, or an Application Load Balancer. You can protect those resources based on conditions that you specify, such as the IP addresses that the requests originate from.

With WAF IP Address sets, you have a scalable solution for whitelisting or blacklisting. This solution supports 1000s of IP address blocks. The WAF IP Address sets and Regex Pattern Sets are reusable across different Web ACLs. Security Group has a limit of a few hundred entries, and Network ACL has a limit of a few 10s of entries.

13.15.2 Shield

AWS Shield provides expanded DDoS attack protection for your AWS resources. Get 24/7 support from our DDoS response team and detailed visibility into DDoS events.

As an AWS customer, you automatically have basic DDoS protection with the AWS Shield Standard plan, at no additional cost beyond what you already pay for AWS WAF and your other AWS services. For an additional cost, you can get advanced DDoS protection by activating the AWS Shield Advanced plan.

AWS Shield standard:

§ Protect agaist layer3 and 4 attacks

§ DDos and other infrastructure level attacks

§ Included for all customers

§ Free

UDP reflection attack (layer 3)

SYN Flood (layer 4)

13.16 Manage resources at scale

Systems Manager also provides a browser-based command line and shell interface for managing Windows and Linux instances. A big benefit is administrators can use IAM to grant and revoke access to the system. The allows you to control through IAM which user can access each instance including the option to provide non-root access. The users can connect to the system without SSH or RDP or Bastion host. This approach vastly simplifies your setup as you no longer need to manage SSH keys or passwords for the servers and eliminates the need for bastion hosts.

AWS config continuously monitors your infrastructure, checks for compliance, and alerts you of changes. Using the managed rules in Config, you can quickly get started with best practices to keep your infrastructure compliant with your enterprise policies. You can also customize by writing your own rules. CloudTrail maintains an audit trail of all changes to pinpoint who made the changes and when. With Systems Manager, you get visibility and control of your ec2 and on-premises server infrastructure. With AWS Trusted Advisor, you can benchmark your environment against AWS Best Practices.

With AWS Inspector, you can quickly find out security exposures and vulnerabilities in your EC2 instance. It can identify the ports that are reachable from outside of VPC, and it will also identify the process that is listening on the port. The inspector will compare the installed OS and software against known vulnerabilities in the CVE list. It evaluates your instance against the center for industry security (CIS) benchmarks for host hardening. The inspector also checks your instance against AWS security best practices. Inspector will prioritize the findings based on the severity

Trusted Advisor is an online tool that provides real-time guidance to help you provision your resources following AWS best practices. By following recommendations provided by Trusted Advisor regularly, you can provision your resources optimally

AWS Trusted Advisor is an online resource that helps you reduce cost as well as increase performance and improve security.

14 Cloud migration

Tools for cost estimation

AWS support plan

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
老司機(jī)避坑指南:如何快速搞定微服務(wù)架構(gòu)?
談?wù)勗趺醋龇?wù)隔離
服務(wù)化的未來(lái)
2020最新微服務(wù)架構(gòu)及設(shè)計(jì)模式總結(jié)
Oracle知識(shí)點(diǎn)總結(jié)二
深度|從SQL 2008 R2 遷移至Azure SQL 數(shù)據(jù)庫(kù),全靠這個(gè)指南了
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服