Help Center/ Server Migration Service/ Best Practices/ Using MgC to Migrate Servers Without Internet Access over Private Lines
Updated on 2024-11-14 GMT+08:00

Using MgC to Migrate Servers Without Internet Access over Private Lines

Overview

This section explains how to use Migration Center (MgC) to migrate servers without Internet access to the LA-Sao Paulo1 region.

This solution only applies to migration to the LA-Sao Paulo1 region.

Step 1: Install Edge, an MgC Tool

  1. Log in to the Huawei Cloud console and enable MgC in the LA-Sao Paulo1 region.
  2. On the MgC console, choose Tools in the navigation pane. Download and install the Edge for Windows.

    Figure 1 Downloading Edge

  3. After the Edge is installed, register an account and connect Edge to MgC.

Step 2: Download the SMS-Agent Installation Packages

  1. Log in to the SMS console and switch to the LA-Sao Paulo1 region.
  2. In the navigation pane, choose Agents.
  3. Choose the MgC Migration over Private Lines card and download the SMS-Agent installation packages and SHA256 verification files for Linux and Windows.

    Figure 2 Downloading the Agent

  4. Save all the downloaded SMS-Agent installation packages and verification files into the same directory on the server where Edge is installed.

Step 3: Configure the Server with Edge Installed as a Web Server

  1. On the server with Edge installed, open PowerShell ISE, and copy and paste the following script content. Then modify the script as follows:

    • Replace 127.0.0.1 in the first line with the internal IP address of the server with Edge installed.
    • Replace the value of sitePath in the second line with the directory where the SMS-Agent installation packages are stored from step 2.
      $SMSAgentServerEndpoint = "127.0.0.1:443"
      $sitePath = "C:\Users\Administrator\Downloads\SMS-Agent"
      
      # Instal IIS
      Install-WindowsFeature -name Web-Server -IncludeManagementTools
      
      # Create Website content
      if (-Not (Test-Path $sitePath)) {
          New-Item -Path $sitePath -ItemType Directory
      }
      
      # Add IIS website
      Import-Module WebAdministration
      New-Item "IIS:\Sites\SMSAgentServer" -bindings @{protocol="http";bindingInformation="$SMSAgentServerEndpoint" + ":"} -physicalPath $sitePath
      
      # Enable content browse
      Set-WebConfigurationProperty -filter "system.webServer/directoryBrowse" -name "enabled" -value "true" -PSPath "IIS:\Sites\SMSAgentServer"
      
      # Set folder permissions
      $acl = Get-Acl $sitePath
      $acl.SetAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("IUSR","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow")))
      $acl.SetAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow")))
      Add-WebConfigurationProperty -PSPath 'IIS:\Sites\SMSAgentServer' -filter 'system.webServer/staticContent' -name '.' -value @{fileExtension='.sha256'; mimeType='application/sha256'}
      
      Set-Acl $sitePath $acl
      
      # Restart IIS service
      Restart-Service -Name "W3SVC"
      $response = Invoke-WebRequest -Uri $SMSAgentServerEndpoint -UseBasicParsing
      if ($response.StatusCode -eq 200) {
          Write-Output "Construct SMS agent server successfully!"
      }
      
      #Replace Edge SMS download url
      $filePath = "C:\Edge\tools\SecAs-1.2.29\webmanagementapps\edge-server-0.0.1\WEB-INF\classes\application.yml"
      $urlPattern = "sms-agent-url:.*"
      $newUrl = "sms-agent-url: http://" + $SMSAgentServerEndpoint
      $fileContent = Get-Content -Path $filePath -Encoding UTF8
      $fileContent = $fileContent -replace $urlPattern, $newUrl
      Set-Content -Path $filePath -Value $fileContent -Encoding UTF8
      
      #Restart Edge
      Write-Output "Restart Edge server, please wait for a while..."
      Restart-Service -Name "Edge_tomcat"
      $edgeProcessStatus = Get-Service -Name "Edge_tomcat" | Select-Object Status
      if ($edgeProcessStatus.Status -eq "Running") {
          Write-Output "Restart edge successfully"
      }

  2. Run the script and wait until the script execution is complete. If the message "Restart edge successfully" is displayed, the configuration is successful.

Step 4: Create a Server Migration Workflow on MgC

Go to the MgC console and create a server migration workflow by referring to Migrating On-premises Servers to Huawei Cloud.