更新时间:2025-06-03 GMT+08:00
MgC专线无公网迁移操作指导
概述
本文介绍在“拉美-圣保罗一”Region通过MgC服务进行无公网迁移的详细操作指导。

本指导仅适用于“拉美-圣保罗一”Region。
步骤一:安装MgC迁移中心Agent
- 登录华为云管理控制台,在“拉美-圣保罗一”Region开通迁移中心 MgC服务。
- 进入迁移中心控制台后,在左侧导航树中选择“迁移中心Agent”,下载并安装Windows版的迁移中心Agent。
- 迁移中心Agent(MgC Agent)安装完成并注册用户成功后,将MgC Agent与MgC控制台建立连接,方法请参考连接迁移中心。
步骤二:下载SMS-Agent安装包
- 登录华为云“拉美-圣保罗一”Region的主机迁移服务管理控制台。
- 在左侧导航树中,单击“迁移Agent”,进入“迁移Agent”页面。
- 分别下载Linux和Windows版的SMS-Agent安装包及对应的SHA256校验文件。
- 将下载的所有SMS-Agent安装包和校验文件放置到安装MgC Agent的主机,并确保所有SMS-Agent安装包和校验文件在同一目录下。
步骤三:配置安装迁移中心Agent的主机为Web服务器
- 在安装MgC Agent的主机上打开Powershell ISE,复制并粘贴以下脚本内容。再对脚本内容进行如下修改:
- 将第一行的127.0.0.1替换为安装MgC Agent主机的内网IP地址。
- 将第二行的sitePath参数值替换为步骤二中SMS-Agent安装包放置的目录路径。
$SMSAgentServerEndpoint = "127.0.0.1:443" $sitePath = "C:\Users\Administrator\Downloads\SMS-Agent" # Install 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 MgC-Agent SMS download url $filePath = "C:\MgC-Agent\config\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 MgC-Agent Write-Output "Restarting MgC-Agent.Please wait for a while..." Restart-Service -Name "MgC-Agent" Write-Output "Starting MgC-Agent.Please wait about 30 seconds" Start-Sleep -Seconds 30 Write-Output "Start MgC-Agent successfully"
- 修改完成后,运行脚本。等待脚本运行完成,出现“Start MgC-Agent successfully”提示后,表示配置成功。