

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

# 使用 Transfer 系列將大型主機檔案直接移至 Amazon S3
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family"></a>

*Luis Gustavo Dantas，Amazon Web Services*

## 總結
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family-summary"></a>

在現代化旅程中，您可能會面臨在內部部署伺服器與 Amazon Web Services (AWS) 雲端之間傳輸檔案的挑戰。從大型主機傳輸資料可能是一項重大挑戰，因為大型主機通常無法存取現代資料存放區，例如 Amazon Simple Storage Service (Amazon S3)、Amazon Elastic Block Store (Amazon EBS) 或 Amazon Elastic File System (Amazon EFS)。

許多客戶使用內部部署 Linux、Unix 或 Windows 伺服器等中繼預備資源，將檔案傳輸至 AWS 雲端。您可以避免這種間接方法，方法是使用 AWS Transfer Family 搭配 Secure Shell (SSH) 檔案傳輸通訊協定 (SFTP)，將大型主機檔案直接上傳至 Amazon S3。

## 先決條件和限制
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family-prereqs"></a>

**先決條件**
+ 作用中的 AWS 帳戶
+ 虛擬私有雲端 (VPC)，具有傳統平台可存取的子網路
+ VPC 的 Transfer Family 端點
+ 大型主機虛擬儲存存取方法 (VSAM) 檔案轉換為循序、[固定長度的檔案 ](https://www.ibm.com/docs/en/zos/2.1.0?topic=reports-converting-vb-fb)(IBM 文件）

**限制**
+ 根據預設，SFTP 會以二進位模式傳輸檔案，這表示檔案會上傳到 Amazon S3 並保留 EBCDIC 編碼。如果您的檔案不包含二進位或封裝資料，則可以使用 **sftpascii**[ 子命令](https://www.ibm.com/docs/en/zos/2.3.0?topic=version-what-zos-openssh-supports) (IBM 文件） 在傳輸期間將檔案轉換為文字。
+ 您必須[解壓縮包含封裝和二進位內容的大型主機檔案](https://apg-library.amazonaws.com/content/f5907bfe-7dff-4cd0-8523-57015ad48c4b) (AWS 規範指引），才能在目標環境中使用這些檔案。
+ Amazon S3 物件的大小範圍從最小 0 個位元組到最大 5 TB。如需 Amazon S3 功能的詳細資訊，請參閱 [Amazon S3 FAQs](https://aws.amazon.com/s3/faqs/?nc1=h_ls)。

## Architecture
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family-architecture"></a>

**來源技術堆疊**
+ 工作控制語言 (JCL)
+ z/OS Unix shell 和 ISPF
+ SFTP
+ VSAM 和一般檔案

**目標技術堆疊**
+ Transfer 系列
+ Amazon S3
+ Amazon Virtual Private Cloud (Amazon VPC)

**目標架構**

下圖顯示使用 Transfer Family 搭配 SFTP 將大型主機檔案直接上傳至 S3 儲存貯體的參考架構。

![使用 Transfer Family 搭配 SFTP，將大型主機檔案直接上傳至 S3 儲存貯體](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/1f4fa1fd-b681-41bc-81d8-d556426b14c2/images/110491d5-b58d-4451-8de9-e742756bb192.png)


該圖顯示以下工作流程：

1. 您可以使用 JCL 任務，透過 Direct Connect 將大型主機檔案從舊版大型主機傳輸到 AWS 雲端。

1. Direct Connect 可讓您的網路流量保留在 AWS 全球網路上，並略過公有網際網路。Direct Connect 也會增強網路速度，從 50 Mbps 開始，擴展到 100 Gbps。

1. VPC 端點可在不使用公有網際網路的情況下，啟用 VPC 資源與支援的 服務之間的連線。存取 Transfer Family 和 Amazon S3 可透過位於兩個私有子網路和可用區域的彈性網路界面實現高可用性。

1. Transfer Family 會驗證使用者，並使用 SFTP 從舊版環境接收您的檔案，並將其移至 S3 儲存貯體。

**自動化和擴展**

使用 Transfer Family 服務後，您可以使用 JCL 任務做為 SFTP 用戶端，將無限數量的檔案從大型主機傳輸到 Amazon S3。您也可以使用大型主機批次任務排程器，在準備好傳輸大型主機檔案時執行 SFTP 任務，以自動化檔案傳輸。

## 工具
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family-tools"></a>
+ [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) 是一種雲端型物件儲存服務，可協助您儲存、保護和擷取任何數量的資料。
+ [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 可協助您在已定義的虛擬網路中啟動 AWS 資源。這個虛擬網路類似於您在自己的資料中心內操作的傳統網路，具有使用可擴展的 AWS 基礎設施的優勢。
+ [AWS Transfer Family](https://docs.aws.amazon.com/transfer/latest/userguide/what-is-aws-transfer-family.html) 可讓您使用 SFTP、FTPS 和 FTP 通訊協定，安全地將週期business-to-business檔案傳輸至 Amazon S3 和 Amazon EFS。 Amazon S3 

## 史詩
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family-epics"></a>

### 建立 S3 儲存貯體和存取政策
<a name="create-the-s3-bucket-and-the-access-policy"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 S3 儲存貯體。 | [建立 S3 儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)體以託管您從舊版環境傳輸的檔案。 | 一般 AWS | 
| 建立 IAM 角色和政策。 | Transfer Family 使用您的 AWS Identity and Access Management (IAM) 角色，授予您先前建立的 S3 儲存貯體存取權。<br />[建立包含下列 IAM 政策的 IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)： [https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)<pre>{<br />    "Version": "2012-10-17",		 	 	 <br />    "Statement": [<br />        {<br />            "Sid": "UserFolderListing",<br />            "Action": [<br />                "s3:ListBucket",<br />                "s3:GetBucketLocation"<br />            ],<br />            "Effect": "Allow",<br />            "Resource": [<br />                "arn:aws:s3:::<your-bucket-name>"<br />            ]<br />        },<br />        {<br />            "Sid": "HomeDirObjectAccess",<br />            "Effect": "Allow",<br />            "Action": [<br />                "s3:PutObject",<br />                "s3:GetObjectAcl",<br />                "s3:GetObject",<br />                "s3:DeleteObjectVersion",<br />                "s3:DeleteObject",<br />                "s3:PutObjectAcl",<br />                "s3:GetObjectVersion"<br />            ],<br />            "Resource": "arn:aws:s3:::<your-bucket-name>/*"<br />        }<br />    ]<br />}</pre>建立 IAM 角色時，您必須選擇轉移使用案例。 | 一般 AWS | 

### 定義傳輸服務
<a name="define-the-transfer-service"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 SFTP 伺服器。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/move-mainframe-files-directly-to-amazon-s3-using-transfer-family.html)如需如何設定 SFTP 伺服器的詳細資訊，請參閱[建立啟用 SFTP 的伺服器](https://docs.aws.amazon.com/transfer/latest/userguide/create-server-sftp.html) (AWS Transfer Family 使用者指南）。 | 一般 AWS | 
| 取得伺服器地址。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/move-mainframe-files-directly-to-amazon-s3-using-transfer-family.html) | 一般 AWS | 
| 建立 SFTP 用戶端金鑰對。 | 為 [Microsoft Windows](https://docs.aws.amazon.com/transfer/latest/userguide/key-management.html#windows-ssh) 或 [macOS/Linux/UNIX](https://docs.aws.amazon.com/transfer/latest/userguide/key-management.html#macOS-linux-unix-ssh) 建立 SSH 金鑰對。 | 一般 AWS、SSH | 
| 建立 SFTP 使用者。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/move-mainframe-files-directly-to-amazon-s3-using-transfer-family.html) | 一般 AWS | 

### 傳輸大型主機檔案
<a name="transfer-the-mainframe-file"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 將 SSH 私有金鑰傳送至大型主機。 | 使用 SFTP 或 SCP 將 SSH 私有金鑰傳送至舊版環境。<br />SFTP 範例：<pre>sftp [USERNAME@mainframeIP]<br />[password]<br />cd [/u/USERNAME]<br />put [your-key-pair-file]</pre><br />SCP 範例：<pre>scp [your-key-pair-file] [USERNAME@MainframeIP]:/[u/USERNAME]</pre><br />接著，將 SSH 金鑰存放在 z/OS Unix 檔案系統中，並使用稍後將執行檔案傳輸批次任務的使用者名稱 （例如，`/u/CONTROLM`)。 如需 z/OS Unix shell 的詳細資訊，請參閱 [z/OS shell 簡介 ](https://www.ibm.com/docs/en/zos/2.2.0?topic=shells-introduction-zos)(IBM 文件）。 | Mainframe、z/OS Unix shell、FTP、SCP | 
| 建立 JCL SFTP 用戶端。 | 由於大型主機沒有原生 SFTP 用戶端，您必須使用 BPXBATCH 公用程式從 z/OS Unix shell 執行 SFTP 用戶端。<br />在 ISPF 編輯器中，建立 JCL SFTP 用戶端。例如：<pre>//JOBNAM JOB ...<br />//**********************************************************************<br />//SFTP EXEC PGM=BPXBATCH,REGION=0M <br />//STDPARM DD * <br />SH cp "//'MAINFRAME.FILE.NAME'" filename.txt; <br />echo 'put filename.txt' > uplcmd; <br />sftp -b uplcmd -i ssh_private_key_file ssh_username@<transfer service ip or DNS>; <br />//SYSPRINT DD SYSOUT=* <br />//STDOUT DD SYSOUT=* <br />//STDENV DD * <br />//STDERR DD SYSOUT=*</pre>如需如何在 z/OS Unix shell 中執行命令的詳細資訊，請參閱 [BPXBATCH 公用程式](https://www.ibm.com/docs/en/zos/2.2.0?topic=ispf-bpxbatch-utility) (IBM 文件）。如需如何在 z/OS 中建立或編輯 JCL 任務的詳細資訊，請參閱[什麼是 ISPF？](https://www.ibm.com/docs/en/zos-basic-skills?topic=interfaces-what-is-ispf)和 [ISPF 編輯器](https://www.ibm.com/docs/en/zos-basic-skills?topic=ispf-editor) (IBM 文件）。 | JCL、大型主機、z/OS Unix shell | 
| 執行 JCL SFTP 用戶端。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/move-mainframe-files-directly-to-amazon-s3-using-transfer-family.html)如需如何檢查批次任務活動的詳細資訊，請參閱 [z/OS SDSF 使用者指南 ](https://www.ibm.com/docs/en/zos/2.4.0?topic=sdsf-zos-users-guide)(IBM 文件）。 | Mainframe、JCL、ISPF | 
| 驗證檔案傳輸。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/move-mainframe-files-directly-to-amazon-s3-using-transfer-family.html) | 一般 AWS | 
| 自動化 JCL SFTP 用戶端。 | 使用任務排程器自動觸發 JCL SFTP 用戶端。您可以使用大型主機任務排程器，例如 [BMC Control-M](https://www.bmcsoftware.pt/it-solutions/control-m.html) 或 [CA 工作負載自動化](https://www.broadcom.com/products/mainframe/workload-automation/ca7)，根據時間和其他批次任務相依性來自動化檔案傳輸的批次任務。 | 任務排程器 | 

## 相關資源
<a name="move-mainframe-files-directly-to-amazon-s3-using-transfer-family-resources"></a>
+ [AWS Transfer 系列的運作方式](https://docs.aws.amazon.com/transfer/latest/userguide/how-aws-transfer-works.html)