AWS MGN (Application Migration Service) 功能討論

Jerry’s Notes
What’s next?
Published in
15 min readMar 26, 2023

AWS Application Migration Service 該功能的前身是 CloudEndure,一般來說從外部VM要匯入到AWS中,除了使用 VM import/export 外,您還可以使用 MGN 來達到這個目的。AWS MGN 透過自動將來源伺服器從實體、虛擬或雲端基礎設施轉換為在 AWS 上原生執行,來簡化並加速遷移至 AWS。

[+] What Is AWS Application Migration Service?
https://docs.aws.amazon.com/mgn/latest/ug/what-is-application-migration-service.html

MGN 運行說明

1) 首先要確認網路的連通性,要確保之間的 TCP 443/1500 Port 一定要通。

[+] Network requirements:
https://docs.aws.amazon.com/mgn/latest/ug/preparing-environments.html

[+] Troubleshooting communication errors:
https://docs.aws.amazon.com/mgn/latest/ug/Troubleshooting-Communication-Errors.html

2) 接下來在 source server (節點上)去安裝代理(agent),也可以透過 vcenter agent-less 的方式來同步資料。

[+] Troubleshooting agent issues:
https://docs.aws.amazon.com/mgn/latest/ug/Troubleshooting-Agent-Issues.html

3) 接下來來源端的機器,會透過代理(agent)的方式,以 block 的方式,將數據同步至在 AWS 上 Repliication server,該機器會掛載多個 EBS 卷,每一個 EBS 卷會直接,會透過代理(agent)直接同步上面的數據,到對應的 EBS 卷上面。

[+] Troubleshooting agentless replication issues:
https://docs.aws.amazon.com/mgn/latest/ug/agentless-troubleshooting.html

4) 當同步完成處於 Ready for testing 階段,客戶去執行測試時,MGN 會對 Repliication server 上的 EBS 卷,來執行快照備份的動作,然後創建實例去掛載相對應的 EBS 卷,此時會進入 Test in progress 階段。

!!! 此時代理(agent)若是正常的,會持續同步數據到 AWS 上 Replication server 中。

進一步說明,當 Data Replication State[+] 處於正常的狀態,您就可以用 Test 功能,來測試您實例上應用程序的功能。
當您執行 Test 時,MGN 會使用復寫後的數據,去產生一個新的測試實例,讓您來執行測試的動作,而每次 Test 都會有一個新的測試實例,使用的當前的同步數據。

例如:
假設在 13:00,執行 Test,去產生一個 A 實例,裡面會是來源機器 13:00 時的數據狀態,接下來在您測試完成後,您把測試這個實例刪除掉。
然後在 18:00 的時候,如果又再執行一次 Test 動作,此時會創建另一個 B 實例,而裡面的數據會來自於源機器 18:00 時的狀態。

[+] Data replication status:
https://docs.aws.amazon.com/mgn/latest/ug/data-replication-stat.html

5) 在 Test in progress 階段後,當您完成的 “功能試測” (請注意測試機器上的數據是舊的,所以還要再做一次最終切換),接下來進入 “Cutover / Ready for cutover” 階段。

!!! 此時會刪除舊的 test 機器,然後您必需指定一個業務 “切換的時間點”,正式將服務切到 AWS 上面實例上。

6) 最後請先確認 “Data replication status” 是 Healthy (持續同步) 的狀態,然後 MGN 會使用最終/最近的 EBS 卷,及快照來啟用一台 Cutover instance,該實例就是最終 AWS 上的正常實例。

[+] Test and cutover menu:
https://docs.aws.amazon.com/mgn/latest/ug/server-test-cutover-main.html

其他補充說明

代理程式安裝
透過在來源伺服器上安裝 AWS 複寫代理程式來開始實作。安裝後,即可檢視和定義複寫設定。AWS Application Migration Service (AWS MGN) 使用這些設定來建立和管理具有輕量型 Amazon EC2 執行個體 (充當複寫伺服器) 和低成本暫存 Amazon EBS 磁碟區的暫存區域子網路。

持續複寫
複寫伺服器從來源伺服器上執行的代理程式接收資料,並將此資料寫入暫存 Amazon EBS 磁碟區。您複寫的資料會動態壓縮和加密,且可使用 EBS 加密靜態加密。AWS Application Migration Service 使用連續的區塊級資料複寫使您的來源伺服器在 AWS 上保持最新。開展不中斷測試或執行切換時,它可使用您定義的啟動設定來啟動執行個體。

測試和切換
啟動測試或切換執行個體時,AWS Application Migration Service 會自動將來源伺服器轉換為在 AWS 上原生開機並執行。確認啟動的執行個體在 AWS 上正常運作時,可以解除委任來源伺服器。然後可選擇透過利用其他 AWS 服務和功能來將應用程式現代化。

Source servers
來源端機器,可以使用 agent 的方式,而這個方式是在機器上安裝代理(agent)程序來執行,也可以透過 vcenter agentless 的方式來同步數據及資料。

Replication server / Replication settings
同步機器(Replication server),主要用於同步來源的數據,機器是在 Stating Area Subnet,而該機器是由 AWS 全託管,所以用戶是無法去存取這台實例的,但仍可以去配置大小等等。

!!! 請注意,MGN 所同步的 EBS volume 預設是有開啟 EBS encryption。

[+] Replication settings:
https://docs.aws.amazon.com/mgn/latest/ug/replication-settings-template.html

[+] Amazon EBS encryption:
https://docs.aws.amazon.com/mgn/latest/ug/ebs-encryption.html

Launch template / Default EC2 launch template
部署範本,主要用於在決定創建 EC2 實例,要在那一個網段(Subnet)、用那一個安全組(Secruity Group)、那一種實例類型(Instacne type)、那一個 EBS 卷(EBS volume)等等配置。

[+] Launch template:
https://docs.aws.amazon.com/mgn/latest/ug/launch-template.html

Monitor metrics and Events on MGN
MGN 有提供多個指標及事件,可以用於了解目前同步是否有 Backlog (同步延遲),或是 jobs 執行的狀態及時間點。

[+] Monitoring Application Migration Service:
https://docs.aws.amazon.com/mgn/latest/ug/monitoring-overview.html

Security on MGN
需要配置 IAM user/policy,並且需要配置合適的安全組。

[+] Security in Application Migration Service:
https://docs.aws.amazon.com/mgn/latest/ug/security.html

實際測試記錄

  1. Replication Server:
    在開始複製時,AWS會Launch一台複製機EC2 ( Replication server )來幫你執行硬碟複寫,假設Source machine上有3顆硬碟分別為OS , App , DB,那麼這台Replication server上也有一樣的3顆硬碟,還有一顆EC2本身的root volume,共4顆硬碟
  2. Conversion Server:
    轉換機:協助Launch Test/Cutover EC2載入程序及安裝Driver的機器
  3. Staging Area:
    暫存區域
  1. IAM access key ID Info

    User name : mgn-agent-installer
    Policy : AWSApplicationMigrationAgentInstallationPolicy
    Access key ID : AKxxx5J
    Secret access key : UyhxxxAF/nz
  2. Download the installer using this command:
    wget -O ./aws-replication-installer-init.py https://aws-application-migration-service-us-west-2.s3.us-west-2.amazonaws.com/latest/linux/aws-replication-installer-init.py
  3. Copy and input the command below into the command line on your source server
    sudo python3 aws-replication-installer-init.py — region us-west-2 — aws-access-key-id AKxxx5J — aws-secret-access-key UyhxxxAF/nz — no-prompt

The installation of the AWS Replication Agent has started.
Identifying volumes for replication.
Identified volume for replication: /dev/xvda of size 8 GiB
Identified volume for replication: /dev/xvdb of size 10 GiB
All volumes for replication were successfully identified.
Downloading the AWS Replication Agent onto the source server… Finished.
Installing the AWS Replication Agent onto the source server…
Finished.
Syncing the source server with the Application Migration Service Console… Finished.
The following is the source server ID: s-5466ecf442c7eb516.
You now have 1 active source server out of a total quota of 20.
Learn more about increasing source servers limit at https://docs.aws.amazon.com/mgn/latest/ug/MGN-service-limits.html
The AWS Replication Agent was successfully installed.

!!! 此時您可以在AWS控制台上,去查看這一筆同步作業的執行狀況

本機上有跑那些服務

# systemctl
aws-replication-agent.service
aws-replication-run-migration-scripts.service
aws-replication-shutdown.service
aws-replication-tailer.service
aws-replication-update-volumes.service
# systemctl status aws-replication-agent.service
● aws-replication-agent.service - AWS Replication Agent
Loaded: loaded (/etc/systemd/system/aws-replication-agent.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2023-03-13 02:45:01 UTC; 1min 13s ago
Main PID: 27655 (java)
CGroup: /system.slice/aws-replication-agent.service

在AWS EC2 控制看到的狀況

若 Agent 出現問題,或是停止的狀況

Alert : Lagging -> Stalled

# systemctl stop aws-replication-agent.service

!!! MGN Alerts 就會出現 Lagging 的提示,代表同步延遲問題。

!!! 上面也可以看到 Lagging 的狀態

!!! 上面就是同步延遲的時間差。

[+] Data replication status:
https://docs.aws.amazon.com/mgn/latest/ug/data-replication-stat.html

重新再把 agent 服務拉起來

```
[ec2-user@ip-10–0–201–183 ~]$ sudo systemctl start aws-replication-agent.service
[ec2-user@ip-10–0–201–183 ~]$ sudo systemctl status aws-replication-agent.service
● aws-replication-agent.service — AWS Replication Agent
Loaded: loaded (/etc/systemd/system/aws-replication-agent.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2023–03–13 06:04:29 UTC; 14s ago
```

Data replication status == Rescanning 的狀態

Data replication status
Rescanning -> Healthy

!!! 若 【Data replication status】有異常,有可能是 agent 有問題、或是之間網路連接性有問題。

最後同步完成後,記得要刪除舊的資源

  1. 同步用的機器會刪除,測試機也要透過 jobs 來刪除

2. 快照要手動刪除

3. EBS 卷記得也要手動刪除

[+] AWS Application Migration Service 常見問答集:
https://aws.amazon.com/tw/application-migration-service/faqs/

問:AWS Application Migration Service 支援哪些無代理程式複寫?
是。AWS Application Migration Service 支援從 VMware vCenter 6.7 和 7.0 版到 AWS 的無伺服器複寫。您可以透過在 vCenter 環境中安裝 AWS MGN vCenter 用戶端,來執行從 vCenter 來源環境到 AWS 的無代理程式快照複寫

問:AWS Application Migration Service 是如何收費的?
針對要遷移的每個來源伺服器,可以免費使用 AWS Application Migration Service 2,160 小時,即連續使用 90 天。
免費期間從您在來源伺服器上安裝 AWS 複寫代理程式時開始,並在有效來源伺服器複寫期間繼續。
>> 會有中間的 replication 用的機器,另外在測試階段,也會產生實例、EBS卷、EBS快照等等資源的費用。

--

--

Jerry’s Notes
What’s next?

An cloud support engineer focus on troubleshooting with customer reported issue ,and cloud solution architecture.