

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon EC2 單一節點架構上的 SQL Server
<a name="single-node"></a>

下圖說明 Amazon Elastic Compute Cloud (Amazon EC2) 上單一節點 SQL Server 的建議架構，然後再新增高可用性 (HA) 和災難復原 (DR) 的支援。

在此架構中，SQL Server 資料庫會使用 SQL Server 的 Amazon Machine Image (AMI) 和作業系統、DATA、LOG 和備份的個別磁碟區，部署至 EC2 執行個體。非揮發性記憶體快速 (NVMe) 儲存直接連接到 EC2 執行個體，並用於 SQL Server tempdb 資料庫。 AWS Directory Service 用於設定 SQL Server 資料庫的 Windows 身分驗證。您也可以使用 AWS Systems Manager 來偵測和安裝 SQL Server 修補程式和更新。

![\[HA/DR 之前 Amazon EC2 上的單一節點 SQL Server 架構\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/images/single-node.png)


下表摘要說明設定此架構的建議。這些建議會在以下各節中詳細說明。


****  

|  |  | 
| --- |--- |
| 執行個體類型/AMI | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 
| SQL Server 版本 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 
| 儲存體類型 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 
| 磁碟區 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 
| DR 選項 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 

## 執行個體類型
<a name="instance-type"></a>

AWS 為您的 SQL Server 工作負載提供一系列[執行個體類別](https://aws.amazon.com/ec2/instance-types/)。您可以選擇運算最佳化、記憶體最佳化、儲存最佳化、一般用途和其他類型，具體取決於資料庫伺服器上的預期工作負載、版本、HA/DR 選項、所需的核心和授權考量。建議您為 SQL Server 選擇 Amazon EBS 最佳化執行個體類型。這些在專用網路中提供連接 EBS 磁碟區的最佳輸送量，這對於可能有大量資料存取需求的 SQL Server 工作負載至關重要。對於標準資料庫工作負載，您可以執行記憶體最佳化執行個體類別，例如 R5, R5b, R5d和 R5n。您也可以包含執行個體儲存體或 NVMe 儲存體。這些都非常適合 tempdb，並為資料庫工作負載提供平衡的效能。

對於關鍵工作負載，高效能 [z1d 執行個體](https://aws.amazon.com/ec2/instance-types/z1d/)針對具有高授權成本的工作負載進行最佳化，例如 SQL Server。z1d 執行個體採用自訂 Intel Xeon 可擴充處理器，可提供高達 4.0 GHz 的持續全核心渦輪頻率，比其他執行個體快得多。對於需要更快速循序處理的工作負載，您可以使用 z1d 執行個體執行較少的核心，並獲得與具有更多核心的其他執行個體相同或更好的效能。

Amazon 也[為 Microsoft Windows Server 上的 SQL Server 提供專用 AMIs](https://aws.amazon.com/windows/resources/amis/)，協助您在 Amazon EC2 上託管最新的 SQL Server 版本。

## 儲存
<a name="storage"></a>

有些執行個體類型提供 NVMe [執行個體存放區磁碟區](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes)。NVMe 是暫時 （周邊） 儲存選項。此儲存直接連接到 EC2 執行個體。雖然 NVMe 儲存體是暫時的，且資料在重新開機時遺失，但可提供最佳的效能。因此，它適用於具有高 I/O 和隨機資料存取模式的 SQL Server tempdb 資料庫。針對 tempdb 使用 NVMe 執行個體存放區無需額外費用。

Amazon EBS 是一種耐用的儲存解決方案，符合 SQL Server 對快速可用儲存的需求。Microsoft 建議將資料和日誌磁碟區分開，以獲得最佳效能。此分隔的原因包括下列項目：
+ 不同的資料存取方法。資料磁碟區使用線上交易處理 (OLTP) 隨機資料存取，而日誌磁碟區則使用序列存取。
+ 更好的復原選項。遺失一個磁碟區不會影響另一個磁碟區，並有助於復原資料。
+ 不同的工作負載類型。資料磁碟區適用於 OLTP 工作負載，而日誌磁碟區則以線上分析處理 (OLAP) 工作負載為目標。
+ 不同的效能需求。資料和日誌磁碟區具有不同的 IOPS 和延遲要求、最低輸送量速率，以及類似的效能基準。

若要選取正確的 [Amazon EBS 磁碟區類型](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html)，您應該分析資料庫存取方法、IOPS 和輸送量。在標準工作時間和尖峰用量期間收集指標。SQL Server 使用範圍來存放資料。SQL Server 中的儲存體原子單位是頁面，大小為 8 KB。八個實體連續頁面組成一個範圍，大小為 64 KB。因此，在 SQL Server 機器上，託管 SQL 資料庫檔案 （包括 tempdb) 的 NTFS 配置單位大小應為 64 KB。

EBS 磁碟區的選擇取決於工作負載，也就是資料庫是讀取密集型還是寫入密集型，需要高 IOPS、封存儲存以及類似的考量。下表顯示範例組態。


****  

| Amazon EBS 資源 | Type | 說明 | 
| --- | --- | --- | 
| 作業系統磁碟 | `gp3` | 一般用途儲存。 | 
| DATA 磁碟 | `io1`/`io2` | 寫入密集型儲存。 | 
| LOG 磁碟 | `gp3` 或 `io2` | 密集工作負載的一般用途儲存。 | 
| 備份磁碟 | `st1` | 較便宜的封存儲存。為了獲得更好的效能，如果備份定期複製到 Amazon Simple Storage Service (Amazon S3)，也可以儲存在更快的磁碟上。 | 

## Amazon EBS 和 Amazon S3 考量事項
<a name="ebs-s3"></a>

下表顯示 Amazon EBS 和 Amazon S3 儲存體的比較。使用此資訊來了解這兩種服務與 之間的差異，為您的使用案例選擇最佳方法。


****  

| 服務 | 可用性 | 耐久性 | 備註 | 
| --- | --- | --- | --- | 
| Amazon EBS | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 
| Amazon S3 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/sql-server-ec2-ha-dr/single-node.html) | 

## Amazon FSx for Windows File Server 上的 SQL Server
<a name="fsx"></a>

[Amazon FSx for Windows File Server](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/sql-server.html) 提供快速的效能，每個檔案系統的基準輸送量最高可達 2 GB/秒、數十萬個 IOPS，以及一致的次毫秒延遲。若要為 SQL Server 執行個體提供適當的效能，您可以選擇與檔案系統大小無關的輸送量層級。更高層級的輸送量容量也具有更高層級的 IOPS，檔案伺服器可以提供給存取它的 SQL Server 執行個體。儲存容量不僅決定您可以儲存多少資料，還決定您可以對儲存執行多少每秒 I/O 操作 (IOPS)，每個 GB 的儲存提供 3 個 IOPS。您可以佈建每個檔案系統的大小上限為 64 TiB （相較於 Amazon EBS 的 16 TiB)。您也可以使用 Amazon FSx 系統做為 Windows Server 容錯移轉叢集 (WSFC) 部署的檔案共用見證。