2016年11月18日 星期五

AWS Associate SysOps準備(第二天)

Cloudformation


常見問答集

介紹
AWS CloudFormation 引入以下兩個概念:範本 (一種 JSON 或 YAML 格式的文字檔案,用於描述執行應用程式所需部署的所有 AWS 資源) 和堆疊 (AWS 資源集合,在 AWS CloudFormation 產生範本時,做為一個單位進行建立和管理)。

能否管理屬於 AWS CloudFormation 堆疊的個別 AWS 資源?
AWS CloudFormation 並不會阻礙您完全控制基礎設施中的所有元素。您可以繼續使用所有現有的 AWS 和第三方工具管理 AWS 資源。

堆疊中某個資源無法成功建立時會發生什麼情形?
預設情況下,會啟用「錯誤時自動復原」功能。這會刪除直到錯誤發生為止 AWS CloudFormation 為堆疊成功建立的所有 AWS 資源。

建立堆疊後,能否對其進行更新?
可以使用 AWS CloudFormation,以可控制且可預測的方式修改和更新現有堆疊中的資源。透過使用範本來管理堆疊變更,您就可以對 AWS 基礎設施套用版本控制,如同您對基礎設施上執行之軟體套用版本控制的方法一樣。

AWS CloudFormation 的費用是多少?
使用 AWS CloudFormation 並不收取其他費用。您只需為建立的 AWS 資源 (如 Amazon EC2 執行個體和 Elastic Load Balancing 負載平衡器等) 付費。

對於堆疊建立失敗期間復原的資源,我是否需要付費?
是。無論整個堆疊能否建立成功,範本產生實體期間建立的 AWS 資源均需收費。





CloudFront

提供兩種協定RTMP, HTTP

限制
不會快取對 POST、PUT、DELETE 和 PATCH 請求的回應,因為這些請求會透過代理傳回原始伺服器。您可以快取對 OPTIONS 請求的回應。

資訊安全
OAI ( Origin Access Identity) 僅讓cloudfront取得s3資料,而不是使s3 public後去取其資料

收費
根據以下四個方面的服務實際使用量進行收費:資料傳出、HTTP/HTTPS 請求、失效請求,以及與 CloudFront 分發相關聯的專用 IP 自訂 SSL 憑證(分為兩種,專用、SNI)。

限制存取位置
利用地理限制功能可以指定使用者可以存取內容的國家清單。或者,您也可以指定使用者不能存取內容的國家清單。在這兩種情況中,CloudFront 均以 HTTP 狀態碼 403 (禁止) 回應來自受限制國家的瀏覽者請求。

保護透過 CloudFront 交付的 Web 應用程式
可將 CloudFront 分發與 AWS WAF 整合,AWS WAF 是一種 Web 應用程式防火牆,可讓您根據 IP 地址、HTTP 標頭和自訂 URI 字串來設定規則,協助保護 Web 應用程式不受攻擊。

SNI自訂ssl與 專用ip自訂SSL

CloudFront 是否支援 gzip 壓縮?
CloudFront 將會自動壓縮您的文字或二進位資料。若要使用此功能,只要在想要 CloudFront 自動壓縮物件的快取行為設定內指定,並確保您的用戶端新增接受編碼的選項:要求標頭中的 gzip (大多數現代 Web 瀏覽器已預設此選項)。

自訂標頭
可以設定 Amazon CloudFront 新增自訂標頭或覆寫現有標頭的值到轉發至原始伺服器的請求。

Cloudfront cache的時間
預設情況下,如果沒有設定快取控制標頭,如果節點收到請求的時間與上次檢查原始伺服器以取得檔案變更的間隔超過 24 小時,則會檢查該檔案的更新版本。

可以透過在原始伺服器中的檔案設定快取控制標頭,將該過期時段設定為最短 0 秒或最長至您需要的任意時間。Amazon CloudFront 使用這些快取控制標頭來決定檢查原始伺服器中該檔案更新版本的頻率。

Amazon CloudFront 傳輸的檔案大小上限?
可以透過 Amazon CloudFront 傳輸的單一檔案大小上限為 20 GB。

是否可以取得請求日誌的存取權,以存取透過 Amazon CloudFront 傳輸的內容?
會將 W3C 擴展格式的詳細日誌資訊寫入您指定的 Amazon S3 儲存貯體。存取日誌包含針對您的內容提出之每個請求的詳細資訊,包括請求的物件、請求的日期和時間、處理請求的節點、用戶端 IP 地址、推薦網站、使用者代理、Cookie 標頭以及結果類型 (例如快取命中/未命中/錯誤)。

CloudFront with cloudwatch
可看有哪些metric


CloudTrail


常見問答集

當我們使用cdw或其他service 的api之後,可以透過CloudTrail來追蹤

CloudTrail with CloudWatch
your trail to send logs to a CloudWatch Logs log group

CloudWatch does not monitor CloudTrail


Cloudwatch

cloudwatch 專刊


何謂Namespaces, metrics and dimension

NameSpaces 可想像成是圖表的key,依此key可找出多個圖表 metric
metric 有時間順序的資料集合
Namespaces are containers for metrics. Metrics, which are time-ordered sets of data points, are isolated from one another in different namespaces so that metrics from different applications are not mistakenly aggregated into the same statistics. each metric has a dimension, which is a name/value pair that helps you to uniquely identify a metric.


在使用Cloudwatch custome namespace時,不認來源,同一時間段內想要把數據回傳,AWS會整併成數據的統計資訊
aggregate the data with statistics, such as Min, max, Average, Sum and Sample data and send the data to cdw

Amazon CloudWatch does not differentiate the source of a metric when receiving custom data. If the user is publishing a metric with the same namespace and dimensions from different sources, CloudWatch will treat them as a single metric. If the data is coming with the same timezone within a minute, CloudWatch will aggregate the data. It treats these as a single metric, allowing the user to get the statistics, such as minimum, maximum, average, and the sum of all across all servers.

Cloudwatch 若資料不足時,狀態會顯示insufficient data,故若要避免的話,傳一個無意義值維持即可

cloudwatch的metric可調整縱軸極限值,以利觀察
You can test an alarm by setting it to any state using the SetAlarmState API (mon-set-alarm-state command). This temporary state change lasts only until the next alarm comparison occurs.

windows server的log 會展示三種 
The AWS EC2 console provides a useful tool called Console output for problem diagnosis. It is useful to find out any kernel issues, termination reasons or service configuration issues. For a Windows instance it lists the last three system event log errors. For Linux it displays the exact console output.

模擬Alarm警告
當想做一些警告測試時,未必要讓資源衝到警告限制,直接使用AWS的API 發出警告通知即可

請查詢cdw data in console的反應時間(15分鐘)


Cloudwatch 傳輸log大小的限制
cdw再使用PutMetricData api的時候,HTTP GET的 request (8kB) 與 HTTP Post的 post (40KB)

Cloudwatch 可以儲存查詢的圖表,讓其他同事也能看

CloudWatch detail monitoring 一分鐘回報一次數據,要額外付費

Cloudwatch 針對不同服務,有不同時間傳輸方式



Cloudwatch 必須Customer metric 記憶體使用率 跟硬碟空間使用率

Amazon CloudWatch 為已終止的 Amazon EC2 執行個體或已刪除的 Elastic Load Balancer 存放 2 週的指標資料。

不能只授與使用者對一組特定執行個體或特定 LoadBalancer 的 CloudWatch 資料存取權限。

無法刪除指標,但是如果 2 週以上沒有新資料發佈到指標,它們就會自動到期。

Amazon CloudWatch 為已終止的 Amazon EC2 執行個體或已刪除的 Elastic Load Balancer 存放 2 週的指標資料。

可以使用 Amazon CloudWatch 監控由自有應用程式、指令碼及服務產生的資料。自訂指標是您提供給 Amazon CloudWatch 的任何指標。例如,您可以使用自訂指標來監控載入網頁的時間、請求錯誤率、執行個體的處理程序或執行緒數量,或應用程式執行的工作量。

CloudWatch Logs 可導入、彙總及監控任何文字型通用日誌資料或 JSON 格式的日誌。

什麼是CloudWatch Events?
Amazon CloudWatch Events (CWE) 是描述 AWS 資源變更的系統事件串流。事件串流強化了現有的 CloudWatch Metrics 和 Logs 串流,為應用程式的運作狀況和狀態提供更完整的藍圖。

cloudwatch logs 限制
每秒五個事務

沒有留言:

張貼留言