在 Compute Engine 上部署 Microsoft Exchange Server 2016


本教學課程說明如何在 Compute Engine 上部署 Microsoft Exchange Server 2016,並設定高可用性和網站復原能力

Exchange 部署作業會橫跨單一區域內的兩個可用區。您會在每個區域中部署郵件伺服器和邊緣轉送伺服器。信箱伺服器會成為資料庫可用性群組的一部分,以便信箱資料跨區域複製。

下圖說明瞭部署作業:

Microsoft Exchange 部署作業

本文假設您已在 Google Cloud 上部署 Active Directory,且具備 Exchange Server 2016、Active Directory 和 Compute Engine 的基本知識。

目標

  • 設定專案和虛擬私有雲網路,並準備部署 Exchange Server 2016。
  • 在兩個可用區部署 Exchange 信箱伺服器,並建立資料庫可用性群組
  • 在兩個可用區部署 Exchange 邊緣傳輸伺服器。
  • 設定負載平衡和防火牆規則。

費用

本教學課程使用 Google Cloud的計費元件,包括:

使用 Pricing Calculator 可根據您的預測使用量來產生費用預估。

事前準備

如要完成本指南,您需要:

  • 現有的 Active Directory 網域,其中至少有一個網域控制器。Active Directory 網域必須使用有效的公開可路由 DNS 網域名稱。您無法使用 corp.local 之類的本機網域名稱,或 example.com 之類的保留網域名稱

    如要進一步瞭解如何在 Compute Engine 上部署 Active Directory 環境,請參閱「部署容錯 Microsoft Active Directory 環境」。

  • Active Directory 的 DNS 網域名稱私人 DNS 轉送區域,可將 DNS 查詢轉送至網域控制站。

  • 擁有 Active Directory 網域的管理員存取權。

  • Google Cloud 可連線至 Active Directory 網域控制站的專案和 VPC。

  • 用於 Exchange VM 執行個體的子網路。子網路必須跨越至少兩個區域。

開始部署前,請先詳閱 Exchange Server 的高可用性和網站復原能力需求

  1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  2. Make sure that billing is enabled for your Google Cloud project.

When you finish the tasks that are described in this document, you can avoid continued billing by deleting the resources that you created. For more information, see Clean up.

準備專案和網路

如要為 Exchange Server 部署作業準備 Google Cloud 專案和虛擬私有雲,請按照下列步驟操作:

  1. 在 Google Cloud 主控台中切換至您的專案,然後開啟 Cloud Shell。

    開啟 Cloud Shell

  2. 初始化下列變數:

    VPC_NAME=VPC_NAME
    SUBNET_NAME=SUBNET_NAME
    SUBNET_REGION=SUBNET_REGION
    SUBNET_ZONE_1=$SUBNET_REGION-a
    SUBNET_ZONE_2=$SUBNET_REGION-b
    

    其中:

    • VPC_NAME 是 VPC 的名稱。
    • SUBNET_NAME 是子網路的名稱。
    • SUBNET_REGION 是子網路的地區。
  3. 設定預設的專案 ID

    gcloud config set project PROJECT_ID
    

    PROJECT_ID 替換為 Google Cloud 專案的 ID。

建立安裝磁碟

您現在可以建立包含 Exchange Server 安裝媒體的磁碟。建立可連接至多個 VM 執行個體的磁碟,即可避免個別將安裝媒體下載至每個 VM 執行個體。

  1. 請按照「透過 ISO 檔案建立映像檔」一節中的操作說明進行。請使用下列網址做為下載網址:

    https://download.microsoft.com/download/6/6/F/66F70200-E2E8-4E73-88F9-A1F6E3E04650/ExchangeServer2016-x64-cu11.iso
    
  2. 使用新的映像檔,在第一個可用區建立磁碟:

    gcloud compute disks create exchange-media-1 \
      --zone=$SUBNET_ZONE_1 \
      --image-project=$GOOGLE_CLOUD_PROJECT \
      --image=IMAGE
    

    IMAGE 替換為您在上一步中建立的映像檔名稱。

  3. 在第二個可用區建立磁碟:

    gcloud compute disks create exchange-media-2 \
      --zone=$SUBNET_ZONE_2 \
      --image-project=$GOOGLE_CLOUD_PROJECT \
      --image=IMAGE
    

    IMAGE 替換為您在第一步驟中建立的圖片名稱。

建立防火牆規則

如要允許用戶端連線至 Exchange,並啟用 Exchange 伺服器之間的通訊,您需要建立幾個防火牆規則。為簡化這些防火牆規則的建立程序,您可以使用網路標記

  • Edge 傳輸伺服器會加上 exchange-transport 標記。
  • 信箱伺服器會加上 exchange-mailbox 標記。
  • 見證伺服器會加上 exchange-witness 標記。
  • 所有伺服器都會加上 exchange 標記。

建立使用這些網路標記的防火牆規則:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 為信箱伺服器建立防火牆規則:

    gcloud compute firewall-rules create allow-all-between-exchange-servers \
      --direction=INGRESS \
      --action=allow \
      --rules=tcp,udp,icmp \
      --enable-logging \
      --source-tags=exchange \
      --target-tags=exchange \
      --network=$VPC_NAME \
      --priority 10000
    
    gcloud compute firewall-rules create allow-smtp-from-transport-to-mailbox \
      --direction=INGRESS \
      --action=allow \
      --rules=tcp:25 \
      --enable-logging \
      --source-tags=exchange-transport \
      --target-tags=exchange-mailbox \
      --network=$VPC_NAME \
      --priority 10000
    
    gcloud compute firewall-rules create allow-edgesync-from-mailbox-to-transport \
      --direction=INGRESS \
      --action=allow \
      --rules=tcp:50636 \
      --enable-logging \
      --source-tags=exchange-mailbox \
      --target-tags=exchange-transport \
      --network=$VPC_NAME \
      --priority 10000
    
    gcloud compute firewall-rules create allow-mail-to-mailbox \
      --direction=INGRESS \
      --action=allow \
      --rules=tcp:25,tcp:110,tcp:135,tcp:143,tcp:443,tcp:993,tcp:995 \
      --enable-logging \
      --target-tags=exchange-mailbox \
      --network=$VPC_NAME \
      --priority 10000
    
    gcloud compute firewall-rules create allow-smb-within-dag \
      --direction=INGRESS \
      --action=allow \
      --rules=tcp:135,tcp:445,udp:445,tcp:49152-65535 \
      --enable-logging \
      --source-tags=exchange-mailbox,exchange-witness \
      --target-tags=exchange-mailbox,exchange-witness \
      --network=$VPC_NAME \
      --priority 10000
    
  3. 為邊緣傳輸伺服器建立防火牆規則:

    gcloud compute firewall-rules create allow-smtp-to-transport \
      --direction=INGRESS \
      --action=allow \
      --rules=tcp:25 \
      --enable-logging \
      --target-tags=exchange-transport \
      --network=$VPC_NAME \
      --priority 10000
    

專案和 VPC 現已準備好部署 Exchange Server。

部署信箱角色

您現在可以部署信箱伺服器,以及用於管理 Exchange 的管理伺服器。

VM 執行個體會使用 n1-standard-8 機器類型。如要進一步分析您的需求和系統需求,請參閱「找出執行任何 Exchange 指令碼所需的權限」。

部署管理伺服器

請按照下列步驟建立用於管理伺服器的 VM 執行個體:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 為 VM 執行個體建立專屬指令碼。指令碼會在 VM 初始化期間執行,並安裝 Exchange 2016 管理工具的用戶端必要條件

    cat << "EOF" > specialize-admin.ps1
    
    $ErrorActionPreference = "stop"
    
    # Install required Windows features
    Install-WindowsFeature RSAT-ADDS,RSAT-DNS-Server
    Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementScriptingTools, `
        IIS-ManagementScriptingTools, `
        IIS-IIS6ManagementCompatibility, `
        IIS-LegacySnapIn, `
        IIS-ManagementConsole, `
        IIS-Metabase, `
        IIS-WebServerManagementTools, `
        IIS-WebServerRole
    
    # Install Visual C++ Redistributable Package for Visual Studio 2012
    (New-Object System.Net.WebClient).DownloadFile(
        'http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU3/vcredist_x64.exe',
        "$env:Temp\vcredist_2012_x64.exe")
    & $env:Temp\vcredist_2012_x64.exe /passive /norestart | Out-Default
    
    EOF
    
  3. 建立使用 specialize-admin.ps1 做為 specialize 指令碼的 VM 執行個體,並將 Exchange 安裝磁碟連結為次要磁碟。您稍後會使用次要磁碟安裝 Exchange 管理工具:

    gcloud compute instances create exchange-admin \
      --image-family=windows-2019 \
      --image-project=windows-cloud \
      --machine-type=n1-standard-2 \
      --subnet=$SUBNET_NAME \
      --zone=$SUBNET_ZONE_1 \
      --tags=exchange \
      --disk=name=exchange-media-1,auto-delete=no,mode=ro \
      --metadata-from-file=sysprep-specialize-script-ps1=specialize-admin.ps1
    
  4. 查看 VM 的序列埠輸出內容,監控 VM 的初始化程序:

    gcloud compute instances tail-serial-port-output exchange-admin --zone=$SUBNET_ZONE_1
    

    請等待約 5 分鐘,直到您看到輸出 Instance setup finished 為止,然後按下 Ctrl+C。此時,VM 執行個體已可供使用。

  5. 為 VM 執行個體建立使用者名稱和密碼

  6. 使用遠端桌面連線至 VM,然後使用先前步驟中建立的使用者名稱和密碼登入。

  7. 在「開始」按鈕上按一下滑鼠右鍵 (或按下 Win + X 鍵),然後按一下「命令提示字元 (系統管理員權限)」

  8. 按一下「是」,確認權限提升提示。

  9. 在提升權限的命令提示字元中,啟動 PowerShell 工作階段:

    powershell
    
  10. 將電腦加入 Active Directory 網域:

    Add-Computer -Domain DOMAIN
    

    DOMAIN 替換為 Active Directory 網域的 DNS 名稱。

  11. 重新啟動電腦:

    Restart-Computer
    

    請等待約 1 分鐘,讓重新啟動程序完成。

  12. 使用遠端桌面連線至 VM,然後使用屬於企業管理員群組的網域使用者登入。

  13. 請按照這篇文章的操作說明,為 Exchange Server 準備 Active Directory 結構定義和網域。您可以在 D: 磁碟上找到 Exchange 安裝媒體。

  14. 按照操作說明安裝 Exchange 管理工具

部署信箱伺服器

您現在可以部署用於郵件伺服器的 VM 執行個體:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 為 VM 執行個體建立 specialize 指令碼。指令碼會在 VM 初始化期間執行,並安裝安裝郵件伺服器的先決條件

    cat << "EOF" > specialize-mailbox.ps1
    
    $ErrorActionPreference = "stop"
    
    # Install required Windows features
    Install-WindowsFeature RSAT-ADDS
    Install-WindowsFeature `
        NET-Framework-45-Features, `
        Server-Media-Foundation, `
        RPC-over-HTTP-proxy, `
        RSAT-Clustering, `
        RSAT-Clustering-CmdInterface, `
        RSAT-Clustering-Mgmt, `
        RSAT-Clustering-PowerShell, `
        WAS-Process-Model, `
        Web-Asp-Net45, `
        Web-Basic-Auth, `
        Web-Client-Auth, `
        Web-Digest-Auth, `
        Web-Dir-Browsing, `
        Web-Dyn-Compression, `
        Web-Http-Errors, `
        Web-Http-Logging, `
        Web-Http-Redirect, `
        Web-Http-Tracing, `
        Web-ISAPI-Ext, `
        Web-ISAPI-Filter, `
        Web-Lgcy-Mgmt-Console, `
        Web-Metabase, `
        Web-Mgmt-Console, `
        Web-Mgmt-Service, `
        Web-Net-Ext45, `
        Web-Request-Monitor, `
        Web-Server, `
        Web-Stat-Compression, `
        Web-Static-Content, `
        Web-Windows-Auth, `
        Web-WMI, `
        Windows-Identity-Foundation, `
        RSAT-ADDS
    
    # Install Visual C++ Redistributable Package for Visual Studio 2012
    (New-Object System.Net.WebClient).DownloadFile(
        'http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU3/vcredist_x64.exe',
        "$env:Temp\vcredist_2012_x64.exe")
    & $env:Temp\vcredist_2012_x64.exe /passive /norestart | Out-Default
    
    # Visual C++ Redistributable Package for Visual Studio 2013
    (New-Object System.Net.WebClient).DownloadFile(
        'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe',
        "$env:Temp\vcredist_2013_x64.exe")
    & $env:Temp\vcredist_2013_x64.exe /passive /norestart | Out-Default
    
    # Install Microsoft Unified Communications Managed API
    (New-Object System.Net.WebClient).DownloadFile(
        'https://download.microsoft.com/download/2/C/4/2C47A5C1-A1F3-4843-B9FE-84C0032C61EC/UcmaRuntimeSetup.exe',
        "$env:Temp\UcmaRuntimeSetup.exe")
    & $env:Temp\UcmaRuntimeSetup.exe /passive /norestart | Out-Default
    
    EOF
    
  3. 請在第一個可用區中建立 VM 執行個體,並將 specialize-mailbox.ps1 傳遞為 specialize 指令碼。將 Exchange 安裝磁碟連接為次要磁碟。您稍後會使用次要磁碟安裝 Exchange Server 信箱角色:

    gcloud compute instances create mailbox-1-a \
      --image-family=windows-2016 \
      --image-project=windows-cloud \
      --machine-type=n1-standard-8 \
      --subnet=$SUBNET_NAME \
      --tags exchange,exchange-mailbox \
      --zone=$SUBNET_ZONE_1 \
      --boot-disk-type pd-ssd \
      --disk=name=exchange-media-1,auto-delete=no,mode=ro \
      --metadata-from-file=sysprep-specialize-script-ps1=specialize-mailbox.ps1
    
  4. 在第二個區域中建立另一個 VM 執行個體:

    gcloud compute instances create mailbox-1-b \
      --image-family=windows-2016 \
      --image-project=windows-cloud \
      --machine-type=n1-standard-8 \
      --subnet=$SUBNET_NAME \
      --tags exchange,exchange-mailbox \
      --zone=$SUBNET_ZONE_2 \
      --boot-disk-type pd-ssd \
      --disk=name=exchange-media-2,auto-delete=no,mode=ro \
      --metadata-from-file=sysprep-specialize-script-ps1=specialize-mailbox.ps1
    
  5. 查看 VM 的序列埠輸出內容,監控 VM 的初始化程序:

    gcloud compute instances tail-serial-port-output mailbox-1-b --zone=$SUBNET_ZONE_2
    

    請等待約 5 分鐘,直到您看到輸出 Instance setup finished,然後按下 Ctrl+C。此時,VM 執行個體已可供使用。

  6. 針對兩個 VM 執行個體,執行下列步驟:

    1. 為 VM 執行個體建立使用者名稱和密碼
    2. 使用遠端桌面連線至 VM,然後使用先前步驟中建立的使用者名稱和密碼登入。
    3. 在「開始」按鈕上按一下滑鼠右鍵 (或按下 Win + X 鍵),然後按一下「命令提示字元 (系統管理員權限)」
    4. 按一下「是」,確認權限提升提示。
    5. 在提升權限的命令提示字元中,啟動 PowerShell 工作階段:

      powershell
      
    6. 將電腦加入 Active Directory 網域:

      Add-Computer -Domain DOMAIN
      

      DOMAIN 替換為 Active Directory 網域的 DNS 名稱。

    7. 重新啟動電腦:

      Restart-Computer
      

      等待約 1 分鐘,讓重新啟動程序完成。

    8. 使用遠端桌面連線至 VM,然後使用屬於企業管理員群組的網域使用者登入。

    9. 使用設定精靈無人值勤模式安裝 Exchange Server 信箱角色。您可以在 D: 磁碟上找到 Exchange 安裝媒體。

部署見證伺服器

如要為兩個郵件伺服器設定資料庫可用性群組 (DAG),您需要額外的 VM 執行個體做為見證伺服器。如要部署見證伺服器,請按照下列步驟操作:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 在第一個可用區建立見證伺服器:

    gcloud compute instances create witness \
      --image-family=windows-2016 \
      --image-project=windows-cloud \
      --machine-type n1-standard-8 \
      --subnet $SUBNET_NAME \
      --tags exchange,exchange-witness \
      --zone $SUBNET_ZONE_1 \
      --boot-disk-type pd-ssd \
      "--metadata=sysprep-specialize-script-ps1=add-windowsfeature FS-FileServer"
    
  3. 查看 VM 的序列埠輸出內容,監控 VM 的初始化程序:

    gcloud compute instances tail-serial-port-output witness --zone=$SUBNET_ZONE_1
    

    請等待約 3 分鐘,直到您看到輸出 Instance setup finished,然後按下 Ctrl+C。此時,VM 執行個體已可供使用。

  4. 為 VM 執行個體建立使用者名稱和密碼

  5. 使用遠端桌面連線至 VM,然後使用先前步驟中建立的使用者名稱和密碼登入。

  6. 在「開始」按鈕上按一下滑鼠右鍵 (或按下 Win + X 鍵),然後按一下「命令提示字元 (系統管理員權限)」

  7. 按一下「是」,確認權限提升提示。

  8. 在提升權限的命令提示字元中,啟動 PowerShell 工作階段:

    powershell
    
  9. 將電腦加入 Active Directory 網域:

    Add-Computer -Domain DOMAIN
    

    DOMAIN 替換為 Active Directory 網域的 DNS 名稱。

  10. 重新啟動電腦:

    Restart-Computer
    

    請等待約 1 分鐘,讓重新啟動程序完成。

  11. 使用遠端桌面連線至 VM,然後使用屬於企業管理員群組的網域使用者登入。

  12. 在「開始」按鈕上按一下滑鼠右鍵 (或按下 Win + X 鍵),然後按一下「命令提示字元 (系統管理員權限)」

  13. 按一下「是」,確認權限提升提示。

  14. 在提升權限的命令提示字元中,啟動 PowerShell 工作階段:

    powershell
    
  15. Exchange Trusted Subsystem 通用安全性群組新增至本機 Administrators 群組:

    Add-LocalGroupMember -Group Administrators -Member "DOMAIN\Exchange Trusted Subsystem"
    

    DOMAIN 替換成 Active Directory 網域的 NetBIOS 名稱。

兩個郵件伺服器和見證伺服器現在已完全部署,但您仍需將這些伺服器加入資料庫可用性群組。

建立資料庫可用性群組

如要建立 DAG,請按照下列步驟操作:

  1. 使用遠端桌面連線至管理 VM,然後使用屬於「Enterprise Admins」群組的網域使用者登入。
  2. 在「開始」按鈕上按一下滑鼠右鍵 (或按下 Win + X 鍵),然後按一下「命令提示字元 (系統管理員權限)」
  3. 按一下「是」,確認權限提升提示。
  4. 在提升權限的命令提示字元中,啟動 PowerShell 工作階段:

    powershell
    
  5. 下載及安裝 Chrome 瀏覽器:

    Start-BitsTransfer `
        -Source 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' `
        -Destination "$env:Temp\chrome_installer.exe"
    & $env:Temp\chrome_installer.exe
    
  6. 如要開啟 Exchange 管理中心 (EAC),請啟動 Chrome 並前往以下網址:

    https://mailbox-1-a/ecp/?ExchClientVer=15
    
  7. 使用屬於「企業管理員」群組的網域使用者登入。

  8. 在 EAC 選單中,依序選取「伺服器」>「資料庫可用性群組」

  9. 按一下 [+]。

  10. 在對話方塊中輸入下列設定,即可建立資料庫可用性群組

    1. 資料庫可用性群組名稱:mailbox
    2. 見證伺服器:witness
  11. 按一下 [儲存]

  12. 按一下「Managed DAG membership」圖示。

  13. 在對話方塊中,按一下 + 新增成員伺服器。

  14. 選取「mailbox-1-a」和「mailbox-1-b」,然後按一下「新增」

  15. 按一下 [確定]

  16. 按一下 [儲存]

視需要執行任何 Exchange Server 安裝後工作

設定負載平衡

為讓用戶端連線至郵件伺服器,您現在可以建立內部負載平衡器資源:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 為每個區域建立一個非代管執行個體群組

    gcloud compute instance-groups unmanaged create mailbox-a --zone=$SUBNET_ZONE_1
    gcloud compute instance-groups unmanaged create mailbox-b --zone=$SUBNET_ZONE_2
    
  3. 將執行郵件伺服器的 VM 執行個體新增至執行個體群組:

    gcloud compute instance-groups unmanaged add-instances mailbox-a \
      --zone=$SUBNET_ZONE_1 \
      --instances=mailbox-1-a
    gcloud compute instance-groups unmanaged add-instances mailbox-b \
      --zone=$SUBNET_ZONE_2 \
      --instances=mailbox-1-b
    
  4. 建立健康狀態檢查,探測 HTTP 路徑 /owa/healthcheck.htm

    gcloud compute health-checks create http http-80\
      --port=80 \
      --request-path=/owa/healthcheck.htm
    
  5. 建立負載平衡器後端並新增兩個執行個體群組:

    gcloud compute backend-services create mailbox-backend \
      --load-balancing-scheme=internal \
      --protocol=tcp \
      --region=$SUBNET_REGION \
      --health-checks=http-80 \
      --session-affinity=CLIENT_IP_PORT_PROTO
    
    gcloud compute backend-services add-backend mailbox-backend \
      --region=$SUBNET_REGION \
      --instance-group=mailbox-a \
      --instance-group-zone=$SUBNET_ZONE_1
    
    gcloud compute backend-services add-backend mailbox-backend \
      --region=$SUBNET_REGION \
      --instance-group=mailbox-b \
      --instance-group-zone=$SUBNET_ZONE_2
    
  6. 為負載平衡器保留靜態 IP 位址:

    gcloud compute addresses create mailbox-frontend \
      --region=$SUBNET_REGION \
      --subnet=$SUBNET_NAME
    
  7. 為負載平衡器建立轉寄規則:

    gcloud compute forwarding-rules create mailbox-frontend \
      --region=$SUBNET_REGION \
      --address=mailbox-frontend  \
      --load-balancing-scheme=internal \
      --network=$VPC_NAME \
      --subnet=$SUBNET_NAME \
      --ip-protocol=TCP \
      --ports=ALL \
      --backend-service=mailbox-backend  \
      --backend-service-region=$SUBNET_REGION
    
  8. 查詢負載平衡器的 IP 位址:

    gcloud compute addresses describe mailbox-frontend  \
      --region=$SUBNET_REGION \
      --format=value\(address\)
    

測試信箱伺服器

如要確認郵件伺服器是否已成功部署,請執行下列步驟:

  1. 在管理 VM 上開啟 Chrome,然後前往 https://<var>IP</var>/owa/,其中 IP 是您先前查詢的負載平衡器 IP 位址。
  2. 使用網域使用者登入。

    您現在應該會看到 Outlook Web Access 的使用者介面。

部署邊緣運輸角色

您現在可以部署邊緣傳輸伺服器。邊緣傳輸伺服器會處理所有傳入和傳出郵件流程

與信箱伺服器不同,邊緣傳輸伺服器會公開於網際網路。因此,在內部部署中,您可以將邊緣傳輸伺服器部署至防火牆與內部網路隔離的邊界網路。

在 Google Cloud上,您不必將邊緣傳輸伺服器部署至獨立的虛擬私有雲或子網路。您可以改用防火牆規則來微分網路,並限制與邊緣傳輸伺服器之間的網路通訊。

與郵件匣伺服器不同,邊緣傳輸伺服器並非 Active Directory 網域的組件。

VM 執行個體會使用 n1-standard-8 機器類型。視您要如何使用 Exchange 部署作業而定,您可能需要使用較大的機器類型。請參閱「找出執行任何 Exchange 指令碼所需的權限」,進一步分析您的需求和系統需求。

部署邊緣傳輸伺服器

如要部署邊緣傳輸伺服器,請按照下列步驟操作:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 為 VM 執行個體建立專屬指令碼。指令碼會在 VM 初始化期間執行,並安裝安裝邊緣傳輸伺服器的先決條件

    cat << "EOF" > specialize-transport.ps1
    
    # Install required Windows features
    Install-WindowsFeature ADLDS
    
    # Install Visual C++ Redistributable Package for Visual Studio 2012
    (New-Object System.Net.WebClient).DownloadFile(
        'http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU3/vcredist_x64.exe',
        "$env:Temp\vcredist_2012_x64.exe")
    & $env:Temp\vcredist_2012_x64.exe /passive /norestart | Out-Default
    
    EOF
    
  3. 請在第一個可用區中建立 VM 執行個體,並將 specialize-transport.ps1 傳遞為 specialize 指令碼。請以唯讀模式附加 Exchange 安裝磁碟,以便日後安裝 Exchange Server 傳輸伺服器角色:

    gcloud compute instances create transport-1-a \
      --image-family=windows-2016 \
      --image-project=windows-cloud \
      --machine-type=n1-standard-8 \
      --subnet=$SUBNET_NAME \
      --tags exchange,exchange-transport \
      --zone=$SUBNET_ZONE_1 \
      --boot-disk-type pd-ssd \
      --disk=name=exchange-media-1,auto-delete=no,mode=ro \
      --metadata-from-file=sysprep-specialize-script-ps1=specialize-transport.ps1
    
  4. 在第二個區域中建立另一個 VM 執行個體:

    gcloud compute instances create transport-1-b \
      --image-family=windows-2016 \
      --image-project=windows-cloud \
      --machine-type=n1-standard-8 \
      --subnet=$SUBNET_NAME \
      --tags exchange,exchange-transport \
      --zone=$SUBNET_ZONE_2 \
      --boot-disk-type pd-ssd \
      --disk=name=exchange-media-2,auto-delete=no,mode=ro \
      --metadata-from-file=sysprep-specialize-script-ps1=specialize-transport.ps1
    
  5. 查看 VM 的序列埠輸出內容,監控 VM 的初始化程序:

    gcloud compute instances tail-serial-port-output transport-1-b --zone=$SUBNET_ZONE_2
    

    請等候約 5 分鐘,直到您看到輸出 Instance setup finished 為止,然後按下 Ctrl+C。此時,VM 執行個體已可供使用。

  6. 針對兩個邊緣運輸伺服器 VM 執行個體,執行下列步驟:

    1. 為 VM 執行個體建立使用者名稱和密碼
    2. 使用遠端桌面連線至 VM,然後使用先前步驟中建立的使用者名稱和密碼登入。
    3. 設定主要 DNS 後置字串,以符合 Active Directory 網域使用的 DNS 網域名稱。
    4. 請使用設定精靈無人值勤模式,安裝 Exchange Server 邊緣傳輸伺服器角色。您可以在 D: 磁碟上找到 Exchange 安裝媒體。

在 DNS 中註冊邊緣轉送伺服器

您必須先為邊緣傳輸伺服器指派 DNS 名稱,才能為邊緣傳輸伺服器設定邊緣訂閱。由於邊緣傳輸伺服器並非 Active Directory 網域的組員,因此您必須手動指派這些名稱:

  1. 在管理伺服器上開啟 PowerShell 主控台。
  2. transport-1-atransport-1-b 建立 CNAME 記錄:

    Add-DnsServerResourceRecordCName `
      -ComputerName (Get-ADDomainController).Hostname `
      -HostNameAlias "transport-1-a.REGION-a.c.PROJECT-ID.internal." `
      -Name "transport-1-a" `
      -ZoneName "DOMAIN"
    
    Add-DnsServerResourceRecordCName `
      -ComputerName (Get-ADDomainController).Hostname `
      -HostNameAlias "transport-1-b.REGION-b.c.PROJECT-ID.internal." `
      -Name "transport-1-b" `
      -ZoneName "DOMAIN"
    

    其中:

    • PROJECT-ID 是 Exchange VM 執行個體部署專案的專案 ID。
    • REGION 是 Exchange VM 執行個體部署所在的區域。
    • DOMAIN 是 Active Directory 網域的 DNS 網域。

設定邊緣訂閱

如要在邊緣傳輸伺服器上使用 Active Directory 資料填入 Active Directory Lightweight Directory Services (AD LDS) 例項,請現在設定邊緣訂閱項目

  1. 在「開始」 >「Exchange Management Shell」上按一下滑鼠右鍵,然後依序選取「更多」 >「以系統管理員身分執行」,即可開啟權限提升的 Exchange 管理殼層。
  2. 建立邊緣訂閱項目:

    New-EdgeSubscription -FileName "$env:UserProfile\Desktop\EdgeSubscriptionInfo-$env:computername.xml"
    

    你現在應該會在電腦上看到訂閱檔案。

  3. 匯出 Exchange AD LDS 伺服器憑證:

    1. 按一下「開始」 >「執行」,輸入 mmc 並選取「確定」,即可開啟 Microsoft 管理主控台。
    2. 依序選取「檔案」 >「新增/移除小工具」
    3. 在外掛程式清單中選取「憑證」,然後按一下「新增」
    4. 選取「服務帳戶」,然後按一下「下一步」
    5. 選取「本機電腦」,然後點選「下一步」
    6. 選取「Microsoft Exchange ADAM」,然後按一下「完成」
    7. 按一下 [確定]
    8. 在左側窗格中,依序前往「憑證」 >「ADAM_MSExchange\Personal」 >「憑證」
    9. 在右側窗格中按一下證書的滑鼠右鍵,然後依序選取「All tasks」 >「Export」
    10. 點按「Next」
    11. 選取「否,不要匯出私密金鑰」,然後按一下「下一步」
    12. 選取「Base-64 編碼 X.509 (.cer)」,然後按一下「下一步」
    13. 選取要儲存憑證的位置,然後點選「下一步」
  4. 針對兩個郵件伺服器 VM 執行個體,執行下列步驟:

    1. 將兩部邊緣傳輸伺服器的 Exchange AD LDS 伺服器憑證複製到暫時位置。
    2. 將兩個邊緣傳輸伺服器的訂閱檔案複製到暫存位置。
    3. 在「開始」 >「Exchange Management Shell」上按一下滑鼠右鍵,然後依序選取「更多」 >「以系統管理員身分執行」,即可開啟權限提升的 Exchange 管理殼層。
    4. 匯入 transport-1-a 的 Exchange AD LDS 伺服器憑證:

      Import-Certificate -FilePath "PATH" -CertStoreLocation cert:\LocalMachine\Root
      

      PATH 替換為 transport-1-a 的 Exchange AD LDS 伺服器憑證路徑。

    5. 匯入 transport-1-b 的 Exchange AD LDS 伺服器憑證:

      Import-Certificate -FilePath "PATH" -CertStoreLocation cert:\LocalMachine\Root
      

      PATH 替換為 transport-1-b 的 Exchange AD LDS 伺服器憑證路徑。

    6. 匯入 transport-1-atransport-1-b 的 Edge Subscription 檔案

    7. 在信箱伺服器上手動啟動 EdgeSync 程序,並確認同步作業是否成功

設定內送郵件流量的負載平衡

如要啟用 Edge Transport Server 的入站電子郵件流量,請建立網路負載平衡器資源:

  1. 返回現有的 Cloud Shell 工作階段。
  2. 建立目標集區:

    gcloud compute target-pools create transport-pool --region $SUBNET_REGION
    
  3. 將邊緣運輸伺服器 VM 執行個體新增至目標集區:

    gcloud compute target-pools add-instances transport-pool \
      --instances-zone $SUBNET_ZONE_1 \
      --instances transport-1-a
    
    gcloud compute target-pools add-instances transport-pool \
      --instances-zone $SUBNET_ZONE_2 \
      --instances transport-1-b
    
  4. 為負載平衡器保留外部 IP 位址:

    gcloud compute addresses create transport-frontend --region=$SUBNET_REGION
    
  5. 建立轉送規則:

    gcloud compute forwarding-rules create www-rule \
      --region $SUBNET_REGION \
      --ports 25 \
      --address transport-frontend \
      --target-pool transport-pool
    
  6. 查詢負載平衡器的 IP 位址:

    gcloud compute addresses describe transport-frontend  \
      --region=$SUBNET_REGION \
      --format=value\(address\)
    

    傳輸伺服器現在可透過這個 IP 位址的 25 號通訊埠接收電子郵件,並將傳入的電子郵件傳送至信箱伺服器。

  7. 按照「使用 Telnet 測試 Exchange 伺服器上的 SMTP 通訊」一文中的指示,確認電子郵件傳送功能是否正常運作。

  8. 如要完成邊緣傳輸伺服器的設定,請按照「在 Exchange 伺服器上設定郵件傳送和用戶端存取權」一文中的步驟操作。

使用 SendGrid 設定外寄電子郵件流程

由於 Google Cloud 不允許通訊埠 25 的傳出連線,您現在可以設定自訂傳送連接器來處理外寄電子郵件。

  1. 使用 Google Cloud Marketplace 註冊 SendGrid 電子郵件服務。
  2. 在 SendGrid 網站上建立新的 API 金鑰。
  3. 將 VM 執行個體 transport-1-atransport-1-b 的公開 IP 位址加入允許 IP 位址清單。

建立傳送連接器

您現在可以建立外送傳送連接器,使用 SendGrid 做為智慧主機:

  1. 返回 Exchange 管理中心 (EAC)。
  2. 在 EAC 選單中,依序選取「郵件流程」 >「傳送連接器」
  3. 按一下 [+]。
  4. 在「新增傳送連接器」對話方塊中,輸入下列設定:
    • Name (名稱):SendGrid
    • 類型網路 (例如傳送網路郵件)
  5. 點按「Next」
  6. 在「網路設定」下方,選取「透過智慧主機路由傳送郵件」,然後按一下「+」
  7. 在「新增智慧主機」頁面中輸入 smtp.sendgrid.net
  8. 按一下 [儲存]
  9. 點按「Next」
  10. 在「智慧主機驗證」下方,選取「基本驗證」
  11. 輸入下列資訊:
    • 使用者名稱apikey
    • 密碼:貼上您在 SendGrid 網站上建立的 API 金鑰
  12. 點按「Next」
  13. 按一下「位址空間」下方的「+」
  14. 輸入下列資訊:
    • 類型:SMTP
    • 完整網域名稱 (FQDN)*
    • 費用1
  15. 點按「Next」
  16. 在「來源伺服器」下方,按一下「+」
  17. 選取 transport-1-atransport-1-b,然後按一下「OK」
  18. 按一下「完成」

變更 SMTP 通訊埠

您現在可以設定傳送連接器以使用自訂通訊埠:

  1. 在任一信箱伺服器上,按一下「開始」 >「Exchange 管理主控台」,開啟 Exchange 管理主控台。
  2. 修改傳送連接器,以便使用 2525 通訊埠:

    Set-SendConnector -Identity "SendGrid" -port 2525
    
  3. 觸發邊緣同步處理,確保設定變更會傳播至所有邊緣運輸伺服器:

    Start-EdgeSynchronization -ForceFullSync
    

清除所用資源

如要避免在完成本教學課程後繼續產生費用,請刪除您已建立的實體。

刪除 Google Cloud 專案

  1. In the Google Cloud console, go to the Manage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

後續步驟

  • 探索 Google Cloud 的參考架構、圖表和最佳做法。歡迎瀏覽我們的雲端架構中心