Share via


Windows Azure Pack: 네트워크 토폴로지

 

적용 대상: Windows Azure Pack

백업할 때와 동일한 이름 및 관리자 계정을 가진 서버에 복원하는 것이 좋습니다. 복원에 성공하려면 파일 서버와 SQL Server가 구성, 사용자 및 사용 권한 측면에서 백업할 때와 정확히 일치해야 합니다. 웹 사이트 서비스를 복원하는 경우 다음과 같은 순서를 사용합니다.

1. SQL Server 데이터베이스 복원

2. 파일 서버 복원

3. 웹 사이트 컨트롤러 복원

4. 모든 역할에 대한 복구 실행

스크립트를 사용하여 복원 작업을 수행할 수 있습니다. 단계는 아래에 자세히 설명되어 있습니다.

1. SQL Server 데이터베이스 복원

SQL Server 호스팅, 리소스 측정 및 master 데이터베이스를 복원합니다. SQL Server 이름이 백업할 때와 같아야 합니다.

샘플 SQL 복원 스크립트

다음 예제 스크립트는 설명 목적으로만 제공되며 지원되지 않습니다. 만든 스크립트를 관리자 권한으로 실행해야 합니다.

참고

이 스크립트는 Microsoft에서 지원되지 않습니다.

param ([string] $backupUser = "Administrator", $backupPassword, $sqlServer, $sqlUser = "sa", $sqlPassword, $backupLocation = "\\backupMachine\c$\backup" )
net use $backupLocation /user:$backupUser $backupPassword
xcopy /Y /q \\$backupMachine\c$\$backupLocation\Hosting.bak C:\HostingOfflineFeed\
xcopy /Y /q \\$backupMachine\c$\$backupLocation\ResourceMetering.bak C:\HostingOfflineFeed\
xcopy /Y /q $backupLocation\master.bak C:\HostingOfflineFeed\
net start "SQL Server (MSSQLSERVER)" /f
sqlcmd -S $sqlServer -U $sqlUser -P $sqlPassword -Q "RESTORE DATABASE [master] FROM DISK='C:\HostingOfflineFeed\master.bak' WITH REPLACE"
net stop "SQL Server (MSSQLSERVER)"
net start "SQL Server (MSSQLSERVER)"
sqlcmd -S $sqlServer -U $sqlUser -P $sqlPassword -Q "RESTORE DATABASE [Hosting] FROM DISK='C:\HostingOfflineFeed\Hosting.bak' WITH REPLACE"
sqlcmd -S $sqlServer -U $sqlUser -P $sqlPassword -Q "RESTORE DATABASE [ResourceMetering] FROM DISK='C:\HostingOfflineFeed\ResourceMetering.bak' WITH REPLACE"
del C:\HostingOfflineFeed\Hosting.bak
del C:\HostingOfflineFeed\ResourceMetering.bak
del C:\HostingOfflineFeed\master.bak

2. 파일 서버 복원

파일 서버 이름이 백업할 때와 같아야 합니다. 다음과 같은 순서로 파일 서버 구성 요소를 복원해야 합니다.

  1. 인증서 공유 복원

  2. 웹 사이트 공유 복원

  3. 필요한 경우 ACL 다시 적용

  4. 웹 사이트 공유에 FSRM 할당량 다시 적용

두 가지 샘플 스크립트가 제공됩니다. 하나는 위의 c단계에 대해, 하나는 WebSites 공유에 FSRM 할당량을 다시 적용하는 것입니다.

샘플 파일 서버 복원 스크립트

다음 예제 스크립트에는 위의 a-c단계가 포함됩니다(FSRM 할당량을 복원하지 않음). 이 스크립트는 설명 목적으로만 제공되며 지원되지 않습니다. 만든 스크립트를 관리자 권한으로 실행해야 합니다.

참고

이 스크립트는 Microsoft에서 지원되지 않습니다.

param ([string] $backupUser = "Administrator", $backupPassword, $certificateFolder = "C:\Certificates", $websiteFolder = "C:\websites", $backupLocation = "\\backupMachine\c$\backup" )
net use $backupLocation /user:$backupUser $backupPassword
mkdir $certificateFolder
mkdir $websiteFolder
xcopy /Y /q /E $backupLocation\ $certificateFolder
xcopy /Y /q /E $backupLocation\ $websiteFolder

FSRM 할당량을 복원하는 샘플 스크립트

다음 예제 스크립트는 FSRM 할당량을 복원합니다. 이 스크립트는 설명 목적으로만 제공되며 지원되지 않습니다. 만든 스크립트를 관리자 권한으로 실행해야 합니다.

참고

이 스크립트는 Microsoft에서 지원되지 않습니다.

param ([string] $backupUser = "Administrator", $backupPassword, $backupLocation = "\\backupMachine\c$\backup" )
net use $backupLocation /user:$backupUser $backupPassword
xcopy /Y /q $backupLocation\templates.xml C:\templates.xml
dirquota template import /File:C:\templates.xml
net stop srmReports
net stop srmSvc
net stop quota
net stop Datascrn
robocopy $backupLocation\SRM "C:\System Volume Information\SRM" /E /ZB /R:3 /W:5
net start Datascrn
net start quota
net start srmSvc
net start srmReports

3. 웹 사이트 컨트롤러 복원

웹 사이트 컨트롤러를 복원하기 위해 이 섹션에 제공된 Restore.ps1 PowerShell 스크립트를 사용할 수 있습니다.

Restore.ps1 스크립트를 웹 사이트 컨트롤러에 복사하고 관리자 권한으로 다음 명령을 실행합니다.

net use /Y $backupLocation /user:$backupMachineAdmin $backupMachinePassword
.\Restore.ps1 $backupLocation $encryptionKey

참고

$encryptionKey 플래그는 백업 시 사용한 경우에만 필요합니다.

Restore.ps1 스크립트는 다음과 같습니다.

##  Re-install and restore the controller from a backup

param ($backupPath,$password)

function ShowHelp
{
    Write-Host '===================== RESTORE.PS1 HELP ====================='
    Write-Host 'This is a script that restores based on a backup from the Hosting VSS writer'
    Write-Host 'Invoke it using .\Restore.ps1'
    Write-Host 'It can also be invoked as follows:'
    Write-Host '.\Restore.ps1 <backup path (e.g. \\backupmachine\C$\backuplocation)> <password for keys file>' 
    Write-Host ("Note: before running this script you may need to run:`r`n" + ' "net use /Y <backup path> /user:<username> <password>"')
    Write-Host '============================================================'
}

function CreateFeedWebAppIfNeeded ([string] $localFeedLocation)
{
    import-module WebAdministration
    $app = Get-WebApplication -Name HostingOfflineFeed 
    if ($app -eq $null) 
    {
        New-WebApplication -Name HostingOfflineFeed -Site 'Default Web Site' -PhysicalPath $localFeedLocation -ApplicationPool DefaultAppPool -Force
    }
    # Add mime types needed for downloading .msp files for offline installations
    $msp = Get-WebConfiguration //staticContent/* | where {$_.fileExtension -eq '.msp'}
    if ($msp -eq $null) 
    {
        Add-WebConfiguration //staticContent -Value @{fileExtension=".msp";mimeType="application/octet-stream"}
    }

    # Add mime types needed for downloading .msu files for offline installations
    $msu = Get-WebConfiguration //staticContent/* | where {$_.fileExtension -eq '.msu'}
    if ($msu -eq $null) 
    {
        Add-WebConfiguration //staticContent -Value @{fileExtension=".msu";mimeType="application/octet-stream"}
    }
}

function InstallController ([string]$offlineFeedUrl, [string]$customFeed) 
{
    $WebPiCmd = ([System.Environment]::ExpandEnvironmentVariables("%ProgramW6432%\Microsoft\Web Platform Installer\WebpiCmd.exe"))    
    if (!(Test-Path $WebPiCmd))
    {
        $WebPiCmd = Join-Path -Path $localFeedLocation -ChildPath "bin\WebpiCmd.exe"
    }
    Invoke-Command -ScriptBlock { & $WebPiCmd /Install /Products:HostingController /AcceptEula /XML:$offlineFeedUrl /SuppressReboot /Log:HostingController.log }

    if ($lastexitcode -ne $null -And $lastexitcode -ne 0) 
    {
        Write-Host "ERROR: There was a problem installing using WebPI!"
        exit $lastexitcode
    }
}

function DecodeBase64($string)
{
    return [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($string))
}

function DecryptString($EncryptedFile, $Passphrase, $salt, $init) 
{ 
    $encryptedStrings = (Get-Content $EncryptedFile)
    $ret = @()
    foreach ($Encrypted in $encryptedStrings)
    {
        # If the value in the Encrypted is a string, convert it to Base64 
        if($Encrypted -is [string])
        { 
            $Encrypted = [Convert]::FromBase64String($Encrypted) 
        } 
        # Create a COM Object for RijndaelManaged Cryptography 
        $r = new-Object System.Security.Cryptography.RijndaelManaged 
        # Convert the Passphrase to UTF8 Bytes 
        $pass = [Text.Encoding]::UTF8.GetBytes($Passphrase) 
        # Convert the Salt to UTF Bytes 
        $salt = [Text.Encoding]::UTF8.GetBytes($salt) 
        # Create the Encryption Key using the passphrase, salt and SHA1 algorithm at 256 bits 
        $r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, "SHA1", 5).GetBytes(32) #256/8 
        # Create the Intersecting Vector Cryptology Hash with the init 
        $r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($init) )[0..15]
        # Create a new Decryptor 
        $d = $r.CreateDecryptor() 
        # Create a New memory stream with the encrypted value. 
        $ms = new-Object IO.MemoryStream @(,$Encrypted)
        # Read the new memory stream and read it in the cryptology stream 
        $cs = new-Object Security.Cryptography.CryptoStream $ms,$d,"Read" 
        # Read the new decrypted stream 
        $sr = new-Object IO.StreamReader $cs 
        # Return from the function the stream 
        $ret += $sr.ReadToEnd()
        # Stops the stream
        $sr.Close() 
        # Stops the crypology stream 
        $cs.Close() 
        # Stops the memory stream 
        $ms.Close() 
        # Clears the RijndaelManaged Cryptology IV and Key 
        $r.Clear() 
    }
    return $ret
}

if ($backupPath -and $backupPath.Contains('/?'))
{ 
    ShowHelp
    return
}

Write-Host 'Starting the hosting restore process. Run with /? to see help.'
Write-Host ("Note: before running this script you may need to run:`r`n" + ' "net use /Y <backupPath> /user:<username> <password>"')
# argument parsing
if (!$backupPath)
{
    $backupPath = Read-Host "Please enter the name of the backup path (e.g. \\backupmachine\C$\backuplocation)"
}
if (!$password)
{
    $password = Read-Host "Please enter the password of the keys file" -AsSecureString
    $password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
}

$systemDrive = [System.Environment]::ExpandEnvironmentVariables('%systemdrive%\')
# Fetch restore data from remote machine
$localFeedLocation = ($systemDrive +'HostingOfflineFeed\')
$c = 0
do
{ 
    $c++
    "D" | xcopy /q /Y (Join-Path -Path $backupPath -ChildPath "HostingOfflineFeed") "$localFeedLocation" /E
} while ($c -lt 10 -and !$?)
# Install the IIS cmdlets
$dismLocation = Join-Path -Path $systemDrive -ChildPath 'Windows\System32\dism.exe'
& $dismLocation /online /enable-feature /featurename:IIS-ManagementScriptingTools /all
CreateFeedWebAppIfNeeded $localFeedLocation

Stop-Service ResourceMetering -ErrorAction SilentlyContinue
# install webpi
$wpi = (dir ($systemDrive + 'hostingofflinefeed\installers\HostingWebPlatformInstaller') -r -i 'wpi.msi').DirectoryName
if ($wpi.Count -gt 1)
{
    $wpi = $wpi[0]
}
$wpi = Join-Path -Path $wpi -ChildPath "wpi.msi"
msiexec /quiet /i $wpi
$offlineFeedUrl = 'https://localhost/HostingOfflineFeed/feeds/latest/WebSites0.9.0.xml'
InstallController $offlineFeedUrl
$keys = DecryptString (Join-Path -Path $backupPath -ChildPath 'encryptedkeys.txt') $password 'salt12345' 'init12345'
Stop-Service WebFarmService -ErrorAction SilentlyContinue
Add-PSSnapIn WebHostingSnapIn
# Restore the keys
# Keys are Base64 encoded
Set-ControllerConnectionString -ConnectionString (DecodeBase64($keys[0])) 3>$null
# Set-MeteringConnectionString -MeteringConnectionString (DecodeBase64($keys[1])) -ServerName (HostName)
Set-SymmetricKey -SymmetricKeyName SystemCore -SymmetricKey (DecodeBase64($keys[1])) 3>$null
Set-SymmetricKey -SymmetricKeyName SiteRuntime -SymmetricKey (DecodeBase64($keys[2])) 3>$null
Set-MeteringConnectionString -MeteringConnectionString ([Microsoft.Web.Hosting.SiteManager]::GetMeteringConnectionString()) -ServerName (HostName) 3>$null

Start-Service WebFarmService -ErrorAction SilentlyContinue

다른 이름 또는 관리자 계정을 가진 비파일 서버로 복원

파일 서버 또는 SQL Server가 아닌 서버를 원본과 다른 서버 이름 또는 관리자 계정을 가진 서버로 복원해야 하는 경우 다음을 수행해야 합니다.

  1. 웹 사이트 모듈 가져오기

  2. 자격 증명 업데이트

  3. 팜에서 이전 서버 이름 제거

  4. 해당 팜에 새 서버 추가

  1. 먼저 다른 명령을 실행하기 전에 웹 사이트 모듈을 가져옵니다.

    Import-Module WebSites
    

    이제 컨트롤러에서 관리자로 2-4 명령을 실행합니다.

  2. RoleType> 역할에< 대한 자격 증명이 변경된 경우 변경된 각 자격 증명에 대해 다음을 실행합니다.

    Set-WebSitesConfig Credential -CredentialName <RoleType> Credential -UserName <RoleAdminUser> -Password <RoleAdminPassword>
    

    참고

    Set-WebSitesConfig 명령에서 RoleType>에 사용할< 수 있는 값은 ManagementServer, FileServer, FrontEnd, Publisher 및 Worker입니다.

  3. 더 이상 사용되지 않는 각 이전 서버 이름 <OldName> 에 대해 다음을 실행합니다.

    Remove-WebSitesServer -Name <OldName>
    
  4. RoleType> 역할<의 새 서버 이름 <NewName>마다 다음을 실행합니다.

    New-WebSitesServer -Name <NewName> -ServerType <RoleType>
    

    참고

    New-WebSitesServer 명령에서 RoleType>의 가능한 값<은 ManagementServer, FileServer, LoadBalancer, Publisher 및 WebWorker입니다.

예제

"OldWorker"라는 이전 웹 작업자 역할과 "NewWorker"라는 새 웹 작업자 역할이 있고 WebWorker 자격 증명을 "WebWorkerAdmin"으로 업데이트한 경우 다음을 실행합니다.

Import-Module WebSites

Set-WebSitesConfig Credential -CredentialName WorkerCredential -UserName WebWorkerAdmin -Password $WebWorkerPassword

Remove-WebSitesServer -Name OldWorker

New-WebSitesServer -Name NewWorker -ServerType WebWorker

4. 모든 역할에 대한 복구 실행

복원을 완료한 후 모든 역할에 대해 복구를 실행하고 모니터링하여 상태가 양호한지 확인합니다.

참고 항목

Windows Azure Pack: 네트워크 토폴로지
Windows Azure Pack: 네트워크 토폴로지