2016年11月20日 星期日

AWS Associate SysOps準備(第四天)

Elastic Compute Cloud


AMI創建的流程

連線錯誤可能的原因

若要將EC2 Instance內容從 az 移轉到另一個az,需要先製作該instance的ami,然後使用該ami在另一個az啟用

較長的 EC2、EBS 和 Storage Gateway 資源 ID
EC2 執行個體與保留 ID,還有 EBS 與 Storage Gateway的磁碟區與快照 ID,都正要變更為較長的格式。較長執行個體與保留 ID 的轉換已於 2016 年 1 月開始進行,且將持續至 2016 年 12 月初,較長磁碟區與快照 ID 的轉換則於 2016 年 4 月至 2016 年 12 月初之間持續進行。

依循目前識別符格式的模式,但長度較長。新的格式為 <資源識別符>-<17 個字元>,例如:“i-1234567890abcdef0” (EC2 執行個體) 或 “snap-1234567890abcdef0” (EBS 快照)。

EC2 若設定 保護,但又在開啟時指定STOP即為terminate, 則使用者關閉機器時,則關機。

EC2-VPC與 EC2-Classic的差異 (看表)

windows on ec2 看log的方式 (q104)

EC2 有兩種 check方式,一為system status check,一為instance status check,請查涵義
system status check : 檢查real host 的狀況
  • Loss of network connectivity
  • Loss of system power
  • Software issues on the physical host
  • HardWare issues on the physical host
  • Best way to resolve issues is to stop and then start the VM again

instance status check :  檢查instance的狀況
  • Failed system status checks
  • Misconfigured networking or startup configuration
  • Exhausted memory
  • Corrupted file system
  • Incompatible kernel
  • Best way to trouble shoot is by rebooting the instance or by making modifications in ur operating system

創建ec2時,建議不指定az,讓它自由分配
When you launch an instance, you can optionally specify an Availability Zone in the region that you are using. If you do not specify an Availability Zone, we select one for you. When you launch your initial instances, we recommend that you accept the default Availability Zone, because this enables us to select the best Availability Zone for you based on system health and available capacity. If you launch additional instances, only specify an Availability Zone if your new instances must be close to, or separated from, your running instances.

維運及資料備份
不會自動備分, 備份時會降低EC2效能, 快照會存在S3, 可透過CLI or python 做自動備分, 是增量備分, snapshot only store incremental changes since last snapshot, only charged for incredmental storage, each snapshot still contains the base snapshot data

Ec2 snapshot 是異步且增量備分

Placement Group
  • 將某一個az(不能跨AZ)的指定的ec2機器們群組化,使得那些機器間相互通信為low-latency, 10Gbps,建議用於要做low network latency, high network throughput的情境,PG的命名有在aws帳號內有唯一性,限制部分類型的機台才能使用。建議在同一個PG的機型都一樣,不可以合併PG,也不能移動已經存在的Ec2 Instance進入PG

問:從 EC2 執行個體中發送電子郵件是否有任何限制?
是。為了保持用於發送電子郵件的 EC2 地址的品質,我們對可以從 EC2 帳戶發送的電子郵件數量實施預設限制。如果希望從 EC2 發送更大數量的電子郵件,您可以透過填寫此表來申請從您的帳戶中取消這些限制。

使用公有 IP 地址在可用區域之間傳輸資料,是否會重複收取區域資料傳輸費用 (一次是因為跨區域,另一次是因為使用公有 IP 地址)?
否。只有至少滿足以下條件之一時才會收取區域數據傳輸費,但是即使同時滿足這兩個條件,也只會對指定的執行個體收取一次費用:
  • 另一執行個體在不同的可用區域內,無論使用何種地址類型。
  • 使用公有或彈性 IP 地址,無論另一執行個體處於哪個可用區域。

增強型聯網
使用 SR-IOV (單一根 I/O 虛擬化) 支援增強型聯網功能。SR-IOV 是一種裝置虛擬化方法,與傳統實作相比,它不僅能提高 I/O 效能,同時還能降低 CPU 利用率。對於受支援的 Amazon EC2 執行個體,此功能可提高每秒資料包數 (PPS) 效能、縮短執行個體間的延遲,並大幅降低網路抖動。有限機型,僅 Amazon VPC 支援增強型聯網。

使用增強型聯網是否需要支付額外的費用?
不需要,增強型聯網沒有額外費用。要利用增強型聯網,必須在 VPC 中受支援的執行個體類型上啟動相應的 AMI。

何時能在預留執行個體市場展示出售預留執行個體?
符合下列情形即可展售預留執行個體:
  • 您已在預留執行個體市場註冊為賣方。
  • 您已購買預留執行個體。
  • 您持有預留執行個體超過 30 天。

如果 Amazon EC2 在未滿一小時前終止了我的競價型執行個體,是否仍會向我收取費用?
否。如果競價型執行個體是由 Amazon EC2 終止,則您無需支付未滿一小時的使用費。不過,如果是您自己終止執行個體,則您需支付該執行個體所有執行時數的費用。

什麼是競價型叢集?
競價型叢集讓您可以自動競標和管理多個競價型執行個體,這些執行個體可以針對叢集或應用程式 (如批次處理任務、Hadoop 工作流程或 HPC 網格運算任務) 的每單位容量提供最低價格。進一步了解競價型叢集

微系列機型用途
微型執行個體提供少量持續的 CPU 資源,但您可用其他週期在短時間內將 CPU 容量突增至 2 個 ECU。它們非常適合具備下述特點的較低輸送量應用程式和網站:定期消耗大量的運算週期,但在其他時間中只消耗極少的 CPU 來用於背景處理程序和協助程式等。

什麼是叢集運算執行個體?
叢集運算執行個體將高運算資源和高效能聯網兩者相結合,適合高效能運算 (HPC) 應用程式和其他高要求的網路綁定型應用程式。叢集運算執行個體提供與其他 Amazon EC2 執行個體相似的功能,但經過了專門設計,能夠提供高效能聯網功能。

觀察T系列cpu積分指標
可以在 Amazon CloudWatch 的 EC2 每一執行個體指標看到每個 T2 執行個體的 CPU 積分餘額。T2 執行個體有兩個新的指標:CPUCreditUsage CPUCreditBalanceCPUCreditUsage 指出已使用的 CPU 積分數量。CPUCreditBalance 指出 CPU 積分的餘額。

VM Import/Export?
客戶可以透過使用 VM Import/Export 匯入虛擬機器 (VM) 映像來建立 Amazon EC2 執行個體。此外,客戶還可以透過匯出以前匯入的 EC2 執行個體來建立 VM。

ElatiCache

常見問答集

提供四種監測
CPU utilization、Swap Usage、 Evictions 及 Concurrent Connections

Swap usage
the amount of the Swap file that is used

Evictions
處理Evictions時,可透過scale up or out
tenants in an apartment building. An Eviction occurs when a new item is added and an old item must be removed due to lack of free space in the system

維護時段?我的快取節點在軟體維護期間是否可用?
您可以將 Amazon ElastiCache 維護時段視為在請求或需要的情況下控制何時執行軟體修補的機會。如果在某星期排定了「維護」事件,則將在您指定的 60 分鐘維護時段的某個時間點啟動和完成維護。
如果排定軟體修補,您的快取節點將在維護時段內出現短暫停機。

自己資料中心伺服器內執行的程式是否可存取 Amazon ElastiCache?
否。目前,ElastiCache 叢集的所有用戶端都必須位於 Amazon EC2 網路中,並按照此處所述透過安全群組授權。

如何控制對 Amazon ElastiCache 的存取?
不使用 VPC 時,Amazon ElastiCache 允許您透過快取安全群組來控制對快取叢集的存取。
如果 ElastiCache 叢集是在 VPC 內部建立,則該 VPC 內的 EC2 執行個體可以存取此 Amazon ElastiCache。

使用DNS連結ElastiCache
建議您使用 DNS 名稱來連接 ElastiCache 節點,因為基礎 IP 地址可能會發生變化 (例如,在快取節點置換後)。


快取子網路群組?為什麼我需要這種子網路群組?
快取子網路群組是您必須為 VPC 內的 Amazon ElastiCache 叢集指定的子網路集合。
每個快取子網路群組至少應包括一個子網路。Amazon ElastiCache 使用快取子網路群組來選擇子網路。之後,所選子網路的 IP 地址將與該快取節點的終端節點相關聯。

Memcached

Memcached 的 Amazon ElastiCache 可以用來快取什麼內容?
快取多種物件
永久資料存放區中的內容 (如 Amazon RDS、SimpleDB 或 EC2 上託管的自我受管型資料庫等)、動態產生的網頁 (例如使用 Nginx),或者可能不需要永久備份存放區的暫時工作階段資料。您也可以使用它來實施高頻計數器,以便在高容量 Web 應用程式中部署許可控制。

SwapUsage的量應當設為0或者不超過50Mb,而若超過了50Mb,必須調整memcached_connections_overhead這個參數

Auto Discovery (for Memcached)

Auto Discovery 可透過用戶端自動發現快取節點。利用 Auto Discovery,除了與 Memcached 協定向後相容以外,Amazon ElastiCache 還提供用戶端有關快取叢集成員資格的資訊。用戶端能夠處理更多資訊,無需任何初始化即可自我重新設定,以使用 Amazon ElastiCache 叢集的最新節點。

若要使用 Auto Discovery 功能,您需要有具備 Auto Discovery 功能的用戶端。您可以從 Amazon ElastiCache 主控台下載適用於 Java 和 PHP 的 Auto Discovery 用戶端。完成初始化後,用戶端將使用組態終端節點自動確定 Amazon ElastiCache 叢集的最新成員。

Redis
不提供SwapUsage metric,改提供reserved-memory

處理Evictions時,只能透過scale up

 Redis 的 Amazon ElastiCache 是否支援 Redis 的密碼功能?
否,適用於 Redis 的 Amazon ElastiCache 不支援 Redis 密碼。

Redis唯讀副本
可以在另一個 AWS 可用區域中建立僅供讀取複本。主節點發生故障時,我們將佈建一個新的主節點。在無法佈建主節點的情況下,您可以決定將哪一個僅供讀取複本提升為新的主節點

僅供讀取複本執行 Redis 快取節點代表什麼意義?
僅供讀取複本在 Redis 有兩個用途:
  • 故障處理
  • 讀取擴展

ElastiCache 叢集的所有用戶端都必須位於 Amazon EC2 網路中

購買數量軟連結

可以在每個區域執行 50 個快取節點,可申請上限。最多可以購買 20 個預留快取節點。如果要執行 20 個以上快取節點,需申請。

Elastic Load Balancer


常見問答集

何時該使用 Classic Load Balancer,何時又該使用 Application Load Balancer?
Classic Load Balancer 適用於跨多個 EC2 執行個體的流量簡易負載平衡,而 Application Load Balancer 則適用於需要進階路由功能、微型服務和以容器為基礎架構的應用程式。

何時該使用傳統負載平衡器,何時又該使用應用程式負載平衡器?
傳統負載平衡器適用於在多個 EC2 執行個體執行簡易的流量負載平衡,而應用程式負載平衡器則適用於微型服務或以容器為基礎的架構,因為它們需要將流量路由到多個服務,或者在相同 EC2 執行個體的多個連接埠執行負載平衡。

傳統負載平衡器是否支援 SSL 終止?
是,您可以在傳統負載平衡器上終止 SSL。您必須在每個負載平衡器上安裝 SSL 憑證。負載平衡器使用此憑證終止連接,然後解密用戶端的請求,再將它們傳送到後端執行個體。

ELB支援的SSL Negotiation, TLS1.0 1.1 1.2 SSL 3.0

ELB 支援的兩種安全策略
ELB supports two policies:
1. Predefined Security Policy, which comes with predefined cipher and SSL protocols;
2. Custom Security Policy, which allows the user to configure a policy.

應用程式負載平衡器是否支援 HTTP/2?
是。應用程式負載平衡器原本就已啟用 HTTP/2 支援。

應用程式負載平衡器是否支援 HTTPS 終止?
是。您可以在應用程式負載平衡器上終止 HTTPS 連接。您必須在負載平衡器上安裝 SSL 憑證。負載平衡器使用此憑證終止連接,然後解密用戶端的請求,再將它們傳送到目標。

應用程式負載平衡器定價的運作方式?
按應用程式負載平衡器執行小時數及每小時使用的負載平衡器容量單位 (LCU) 數計算,不足一小時按一小時計費。

什麼是負載平衡器容量單位 (LCU)?
LCU 是決定應用程式負載平衡器付費方式的新指標。LCU 可定義應用程式負載平衡器處理流量時在各定價方式 (新的連接、作用中連接和頻寬) 消耗的最高資源量。

傳統負載平衡器是否依 LCU 計費?
否。傳統負載平衡器將持續以頻寬和每小時用量計費。

ELB在創建的時候,會套用一個SG,這個SG是可以選擇,或使用預設的

Elastic Load balancr 若被刪除了,與其相關的Instance仍然會繼續運行。


Enable Access Logs for ur Load Balancer 流程
開啟s3 bucket → 設定 S3 bucket policy → 透過console,啟用access log 

ELB access log 會自動記錄的欄位,  the time the request was received, the client's IP address, latencies, request paths, and server responses等等(請看官網) 不用額外付費,僅需付儲存在s3的成本。
bucket[/prefix]/AWSLogs/aws-account-id/elasticloadbalancing/region/yyyy/mm/dd/aws-account-id_elasticloadbalancing_region_load-balancer-name_end-time_ip-address_random-string.log 

Elastic Load Balancing access logs capture detailed information for all the requests made to the load balancer. Each request will have details, such as client IP, request path, ELB IP, time, and latencies. The time will have information, such as Request Processing time, Backend Processing time and Response Processing time.

Public ELB需要有個公開域名,提供連線
An Internet-facing load balancer has a publicly resolvable DNS name, so it can route requests from clients over the Internet to the EC2 instances that are registered with the load balancer.

用戶可透過 ipv4 or ipv6 來跟 ELB溝通,而ELB跟內部機器溝通是透過ipv4
The base public DNS name returns only IPv4 records. The public DNS name with theipv6 prefix returns only IPv6 records. The public DNS name with the dualstack prefix returns both IPv4 and IPv6 records. We recommend that you enable IPv6 support by using the DNS name with the dualstack prefix to ensure that clients can access the load balancer using either IPv4 or IPv6.

Clients can connect to your load balancer in EC2-Classic using either IPv4 or IPv6. However, communication between the load balancer and its back-end instances uses only IPv4, regardless of how the client communicates with your load balancer.

Application Elastic Load Balancer


Elastic Load balancer 做sticky session的流程

須查Sticky session 由elb or server來處理的做法

分為兩種 
Duration Based Session Stickiness
依照Session 內的cookie,若該request無cookie,elb chooses an application instance based on the existing load balancing algorithm and adds a new cookie in to the response

Application-Controlled Session Stickiness



Connection draining
設定ELB與de-registered instance的保持連線時間
因為可能還有一些存在的connection 與 de-registered的instance做溝通
auto scaling 會特別等這些request完畢,但最長就是一小時(1–3600秒) 預設300秒
If your instances are part of an Auto Scaling group and connection draining is enabled for your load balancer, Auto Scaling waits for the in-flight requests to complete, or for the maximum timeout to expire, before terminating instances due to a scaling event or health check replacement.

ELB 的 SSL 溝通方式

ELB的Listener 處理封包的方式
經典ELB
ec2 - Classic 支援四種協定 HTTP, HTTPS, TCP, SSL(secure TCP) 
若為VPC 則支援1–65535 port

若本來已經register elb的 EC2,關機後重啟會自動register 回elb

elb的log 命名格式

查ELB的分流方式

ELB的 SurgeQueueLength, SpilloverCount 的意思-

SurgeQueueLength 
衡量所有的request 
the account of the number of total requests that are pending a submission to the register instance, so this can be useful, basically, ur elastic load balancer is trying to fade a connection through to ur EC2 instances.

spilloverCount 
當queue滿的時候,被拒絕的request數量
it's going to measure the number of requests that are rejected due to the queue being full.

elb  pre-warm要帶的屬性

ec2-vpc 與 ec2-classic限制
下列 TCP 連接埠執行負載平衡:
  • [EC2-VPC] 1-65535
  • [EC2-Classic] 25, 80, 443, 465, 587, 1024-65535

CloudWatch Metrics for Your Classic Load Balancer

BackendConnectionErrors  
The number of connections that were not successfully established between the load balancer and the registered instances.

HealthyHostCount , UnHealthyHostCount
The number of healthy and unhealthy instances registered with your load balancer.

HTTPCode_Backend_2XX`,HTTPCode_Backend_3XX,HTTPCode_Backend_4XX,HTTPCode_Backend_5XX 
[HTTP listener] The number of HTTP response codes generated by registered instances. 

HTTPCode_ELB_4XX
[HTTP listener] The number of HTTP 4XX client error codes generated by the load balancer. 

HTTPCode_ELB_5XX
[HTTP listener] The number of HTTP 5XX server error codes generated by the load balancer.

Latency
[HTTP listener] The time elapsed, in seconds, after the request leaves the load balancer until the headers of the response are received.

RequestCount
The number of requests completed or connections made during the specified interval (1 or 5 minutes).

SpilloverCount        
The total number of requests that were rejected because the surge queue is full.

SurgeQueueLength
The total number of requests that are pending routing. 

沒有留言:

張貼留言