快速入門:在隔離的 Hyper-V 環境中部署單一伺服器 (SharePoint Server 2010)

 

適用版本: SharePoint Foundation 2010, SharePoint Server 2010

上次修改主題的時間: 2016-11-30

您可以使用隔離且安全的 Hyper-V 虛擬機器,測試 SharePoint Server 2010 的功能與行為。這種方法使用最少的硬體資源,且可讓 SharePoint Server 2010 測試系統與實際執行環境之間有所隔離。建議使用此隔離環境,以降低公司網路與伺服器環境的潛在安全性威脅。

您可以使用手動步驟或本文所提供的 Windows PowerShell 2.0 命令,在使用下列其中一個資料庫的單一伺服器上快速部署 SharePoint Server 2010:

  • SharePoint Server 隨附內建的 SQL Server 2008 Express 和 SQL Server 2008 R2 Express 資料庫

  • 已安裝 Service Pack 3 (SP3) 與累積更新 3 的 Microsoft SQL Server 2005

  • Microsoft SQL Server 2008 Service Pack 1 (SP1) 與累計更新 2

重要

本文所述的單一伺服器 SharePoint Server 部署,僅適用於評估與測試目的,不應於實際執行環境中使用。

本文內容:

  • 需求與建議

  • 必要的權限

  • 部署前的工作

  • 手動部署 SharePoint Server 2010

  • 使用 Windows PowerShell 指令碼部署 SharePoint Server 2010

需求與建議

下列 Hyper-V 虛擬化伺服器、虛擬機器與部署環境的需求與建議,僅適用於本文所述的單一伺服器部署情況。

虛擬化伺服器與虛擬機器設定

下表提供虛擬化伺服器及虛擬機器的基本與建議設定。這些設定支援單一伺服器部署所提供的資料庫選項。

資源 基本 建議

CPU

雙處理器,2 GHz

雙處理器,2 GHz

記憶體

4 GB

8 GB

硬碟

容量為 40 GB 之固定大小的虛擬硬碟

提示

若要加速建立固定大小的虛擬硬碟,請在一開始便將硬碟設定為動態擴充。安裝所有必要軟體 (包括 SharePoint Server) 之後,再將虛擬硬碟轉換為固定大小的硬碟。

容量為 80 GB 之固定大小的虛擬硬碟

網路介面卡類型

綜合

綜合

網路類型

內部,以確保虛擬機器有所隔離,並啟用虛擬化伺服器與虛擬機器之間的通訊

提示

為便於存取 (及安裝) 必要與建議的軟體,請使用外部網路。當您準備好要安裝 SharePoint Server 時,請設定虛擬機器使用內部網路。

內部,以確保虛擬機器有所隔離,並啟用虛擬化伺服器與虛擬機器之間的通訊

以下提供虛擬化伺服器的設定指導:

  • 邏輯與虛擬處理器 (核心) 的比例應儘量降低,最佳比例為 1:1。

  • 使用 1:1 的邏輯與虛擬處理器比例時,應將虛擬化伺服器設定為讓虛擬機器上的處理器總數,少於實體核心總數。例如,使用四核心虛擬化伺服器的最佳作法,是建立三部使用單一處理器的虛擬機器,或一部有兩個處理器的虛擬機器加上一部使用一個處理器的虛擬機器。這兩種設定都會保留一個核心,用於虛擬化伺服器處理序。

除了前述虛擬環境的需求之外,請檢閱<硬體及軟體需求 (SharePoint Server 2010)>一文,再開始部署虛擬機器上的 SharePoint Server 2010。

部署環境

部署 SharePoint Server 2010 時需要網域。

若無可供部署 SharePoint Server 2010 的虛擬隔離網域,則必須在設定為使用下列項目的 Hyper-V 上建立虛擬網域:

  • 使用 Active Directory 網域服務 (AD DS) 的網域控制站

  • 使用 DNS 伺服器的網域控制站

您可以在網域控制站上部署 SharePoint Server,但需進行某些設定。請使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell,然後執行下列命令在網域控制站上啟用部署:

$acl = Get-Acl HKLM:\System\CurrentControlSet\Control\ComputerName 
$person = [System.Security.Principal.NTAccount]"Users" 
$access = [System.Security.AccessControl.RegistryRights]::FullControl 
$inheritance = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit" 
$propagation = [System.Security.AccessControl.PropagationFlags]::None 
$type = [System.Security.AccessControl.AccessControlType]::Allow 
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($person, $access, $inheritance, $propagation, $type) 
$acl.AddAccessRule($rule) 
Set-Acl HKLM:\System\CurrentControlSet\Control\ComputerName $acl

必要的權限

若要安裝 SharePoint Server 2010,您在虛擬機器上使用的登入帳戶必須是下列群組或角色的成員:

  • 虛擬機器上的本機管理員群組

  • SQL Server dbcreator 固定伺服器角色

  • SQL Server securityadmin 伺服器角色

如需詳細資訊,請參閱<管理帳戶與服務帳戶 (SharePoint Server 2010)>。

部署前的工作

請先完成下列工作,再部署 SharePoint Server 2010:

  • 在虛擬化伺服器上,建立包含 SharePoint Server 軟體的安裝點,或提供可從虛擬機器存取的媒體,例如 ISO 映像。

  • 建立符合本文前述<需求與建議>一節所列基本需求的虛擬機器。

  • 在虛擬機器上:

手動部署 SharePoint Server 2010

如需如何在單一伺服器上手動部署 SharePoint Server 2010 的資訊,請參閱<以內建資料庫部署單一伺服器 (SharePoint Server 2010)>或<以 SQL Server 部署單一伺服器 (SharePoint Server 2010)>。

使用 Windows PowerShell 指令碼部署 SharePoint Server 2010

您可以使用 Windows PowerShell 指令碼在單一伺服器上部署 SharePoint Server 2010。

安全性提示Security Note
最佳作法是不應執行未簽署的指令碼。
如需簽署 Windows PowerShell 指令碼的詳細資訊,請參閱 TechNet Magazine 中的 Windows PowerShell:請在此簽名 (https://go.microsoft.com/fwlink/?linkid=160357&clcid=0x404)。如需一般的程式碼簽署之詳細資訊,請參閱 MSDN 上的程式碼簽署簡介(可能為英文網頁) (https://go.microsoft.com/fwlink/?linkid=59273&clcid=0x404)(可能為英文網頁)。如需設定您專屬之憑證授權單位 (CA) 的詳細資訊,請參閱 TechNet Library 中的 Active Directory 憑證服務(可能為英文網頁) (https://go.microsoft.com/fwlink/?linkid=136444&clcid=0x404)(可能為英文網頁)。

建立並使用下列其中一個 Windows PowerShell 指令碼檔案,在單一伺服器上部署 SharePoint Server。

  • simplesingleserver.ps1:使用內建資料庫安裝 SharePoint Server 2010,以儲存設定資訊與文件。

  • simplefarm.ps1:使用 SQL Server 2005 或 SQL Server 2008 安裝 SharePoint Server 2010,以儲存設定資訊與文件。

simplesingleserver.ps1

此指令碼會在使用內建資料庫的單一伺服器上,部署 SharePoint Server 2010。

請將下列程式碼複製到文字編輯器,並在您所選擇的目錄中將其儲存為 simplesingleserver.ps1:



$SetupPath         = Read-Host -Prompt "Please specify the path to the install media (D:)"
        
## Here is the script to install SharePoint Server 2010 with SQL Express and create Central Admin ##
& $SetupPath\PrerequisiteInstaller.exe /unattended | Write-Host
if( $lastexitcode -eq 0 ) {
    & $SetupPath\setup.exe /config $SetupPath\Files\SetupSilent\config.xml | Write-Host
    if( $lastexitcode -eq 0 ) {
        Write-Host "Install successful..."
    } else { Write-Error "ERROR: $lastexitcode" }
} else { Write-Error "ERROR: $lastexitcode" }

執行 simplesingleserver.ps1

  1. 瀏覽至安裝來源上的 Files\SetupSilent 目錄,並使用文字編輯器開啟 config.xml。

  2. 請找出 <!--<PIDKEY Value="Enter Product Key Here" />--> 一行。

  3. 以下列其中一個 PIDKEY 取代 "Enter Product Key Here" (於此輸入產品金鑰):PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY 或 BV7VC-RMR6B-26P6Y-BTQDG-DX2KQ

  4. 移除您編輯之程式碼行的註解標記,然後儲存 config.xml 檔案。

  5. 使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell 2.0。

  6. 瀏覽至您儲存 simplesingleserver.ps1 的目錄。

  7. 從 Windows PowerShell 命令提示字元處執行 .\simplesingleserver.ps1。

simplefarm.ps1

此指令碼會在使用 SQL Server 資料庫的單一伺服器上,部署 SharePoint Server 2010。請將下列程式碼複製到文字編輯器,並在您所選擇的目錄中將其儲存為 simplefarm.ps1:


## Settings you may want to change ##
$err = $null
$SetupPath         = Read-Host -Prompt "Please specify the path to the install media (D:)"
Write-Host "Please specify the Farm Administrator credentials"
$FarmCredential    = Get-Credential "DOMAIN\<Farm Admin>"
$DBServer          = Read-Host -Prompt "Please enter the name of your database server"
$Passphrase        = Read-Host -Prompt "Please enter the farm passphrase (optional)" -AsSecureString
$FarmName          = Read-Host -Prompt "Please enter a farm name (optional)"
$CAPort            = Read-Host -Prompt "Please enter the Central Administration port number (optional)"

if ([String]::IsNullOrEmpty($SetupPath))
{
    Write-Error "You must enter the install media path"
    return
}
if ([String]::IsNullOrEmpty($FarmCredential))
{
    Write-Error "You must enter a Farm Administrator's user name and password"
    return
}
if ([String]::IsNullOrEmpty($DBServer))
{
    Write-Error "You must enter a database server"
    return
}
if ($Passphrase.Length -eq 0)
{
    Write-Warning "You didn't enter a farm passphrase, using the Farm Administrator's password instead"
    $Passphrase = $FarmCredential.Password
}
if ([String]::IsNullOrEmpty($FarmName))
{
    Write-Warning "You didn't enter a farm name, using the machine name instead"
    $FarmName = $env:COMPUTERNAME
}
if ([String]::IsNullOrEmpty($CAPort))
{
    Write-Warning "You didn't enter a Central Administration port number, using 5000 instead"
    $CAPort = 5000
}

## Here is the script to install SharePoint Server 2010 and create Central Admin ##
Write-Host "[1/15] Running prerequisite installer..." 
& $SetupPath\PrerequisiteInstaller.exe /unattended | Write-Host
if( $lastexitcode -eq 0 ) {
    Write-Host "[2/15] Running silent farm binary installation... (this will take some time)" 
    & $SetupPath\setup.exe /config $SetupPath\Files\SetupFarmSilent\config.xml | Write-Host
    Write-Host "[3/15] Completed silent farm binary installation." 
    if( $lastexitcode -eq 0 ) {
        Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
        Write-Host "[4/15] Creating new configuration database..." 
        New-SPConfigurationDatabase -DatabaseName ("{0}_SharePoint_Configuration_DB" -f $FarmName) -DatabaseServer $DBServer -AdministrationContentDatabaseName ("{0}_AdminContent_DB" -f $FarmName) -FarmCredentials $FarmCredential -Passphrase $Passphrase -ErrorVariable err
        Write-Host "[5/15] Verifying farm creation..." 
        $spfarm = get-spfarm
            if ($spfarm -ne $null) {
            Write-Host "[6/15] ACLing SharePoint Resources..." 
            Initialize-SPResourceSecurity -ErrorVariable err
            if ([String]::IsNullOrEmpty($err) -eq $true) {
                Write-Host "[7/15] Installing Services..." 
                Install-SPService -ErrorVariable err
                    if ([String]::IsNullOrEmpty($err) -eq $true) {
                    Write-Host "[8/15] Installing Features..." 
                    Install-SPFeature -AllExistingFeatures -ErrorVariable err
                    if ([String]::IsNullOrEmpty($err) -eq $true) {
                        Write-Host "[9/15] Provisioning Central Administration..." 
                        New-SPCentralAdministration -Port $CAPort -WindowsAuthProvider "NTLM" -ErrorVariable err
                        if ([String]::IsNullOrEmpty($err) -eq $true) {
                            Write-Host "[10/15] Installing Help..." 
                            Install-SPHelpCollection -All -ErrorVariable err
                            if ([String]::IsNullOrEmpty($err) -eq $true) {
                                Write-Host "[11/15] Installing Application Content..." 
                                Install-SPApplicationContent -ErrorVariable err
                                if ([String]::IsNullOrEmpty($err) -eq $true) {
                                    Write-Host "[12/15] Basic configuration completed." 
                                    $SPManagedAccount = Get-SPManagedAccount $FarmCredential.UserName
                                    Write-Host "[13/15] Creating Web Application and Application Pool..." 
                                    $webApp = New-SPWebApplication -Name "SharePoint - 80" -ApplicationPool "SharePoint - 80" -ApplicationPoolAccount $SPManagedAccount -DatabaseServer $DBServer -DatabaseName ("{0}_Content_DB" -f $FarmName) -Url "https://localhost" -ErrorVariable err
                                    if ([String]::IsNullOrEmpty($err) -eq $true) {
                                        Write-Host "[14/15] Creating site collection..." 
                                        $SPSite = New-SPSite -url "https://localhost" -OwnerAlias $FarmCredential.UserName -ErrorVariable err
                                        if ([String]::IsNullOrEmpty($err) -eq $true) {
                                            Write-Host "[15/15] Port 80 Web application and site collect created.  Browse to https://localhost to pick a template for the Web..."
                                        } else { Write-Error "ERROR: $err" }
                                    } else { Write-Error "ERROR: $err" }
                                } else { Write-Error "ERROR: $err" }
                            } else { Write-Error "ERROR: $err" }
                        } else { Write-Error "ERROR: $err" }
                    } else { Write-Error "ERROR: $err" }
                } else { Write-Error "ERROR: $err" }
            } else { Write-Error "ERROR: $err" }
        } else { Write-Error "ERROR: $err" }
    } else { Write-Error "ERROR: $lastexitcode" }
} else { Write-Error "ERROR: $lastexitcode" }
 
$exitprompt = Read-Host -Prompt "Press Enter to exit..."

執行 simplefarm.ps1

  1. 瀏覽至安裝來源上的 Files\SetupSilent 目錄,並使用文字編輯器開啟 config.xml。

  2. 請找出 <!--<PIDKEY Value="Enter Product Key Here" />--> 一行。

  3. 以下列其中一個 PIDKEY 取代 "Enter Product Key Here" (於此輸入產品金鑰):PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY 或 BV7VC-RMR6B-26P6Y-BTQDG-DX2KQ

  4. 移除您編輯之程式碼行的註解標記,然後儲存 config.xml 檔案。

  5. 使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell 2.0。

  6. 瀏覽至您儲存 simplefarm.ps1 的目錄。

  7. 從 Windows PowerShell 命令提示字元處執行 .\simplefarm.ps1。