了解如何在 SharePoint Server 中附加及還原唯讀的內容資料庫Attach and restore read-only content databases in SharePoint Server

摘要: 了解如何在 SharePoint 2013 和 SharePoint Server 2016 中附加及還原唯讀的內容資料庫。Summary: Learn how to attach and restore a read-only content database in SharePoint 2013 and SharePoint Server 2016.

在 SharePoint Server 中,您可以使用 PowerShell 附加及還原唯讀的內容資料庫。You can attach and restore a read-only content database in SharePoint Server by using PowerShell.

開始之前Before you begin

在 SharePoint Server 伺服器陣列中設為唯讀的內容資料庫,可能會是執行鏡像或記錄傳送之失敗復原環境中的一部分,也可能是高可用性維護或可以在其他版本之伺服器陣列更新時,讓使用者存取的修補環境。A SharePoint Server farm in which content databases are set to be read-only can be part of a failure recovery environment that runs against mirrored or log-shipped content databases or part of a highly available maintenance or patching environment that provides user access when another version of the farm is being updated.

開始這項作業之前,請參閱下列有關先決條件的資訊:Before you begin this operation, review the following information about prerequisites:

使用 PowerShell 附加及還原唯讀的內容資料庫Using PowerShell to attach and restore a read-only content database

您可以使用 PowerShell 附加及還原唯讀的內容資料庫。You can use only PowerShell to attach and restore a read-only content database.

使用 PowerShell 附加及還原唯讀內容資料庫To attach and restore a read-only content database by using PowerShell

  1. 確認您具備下列成員身分:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running the PowerShell cmdlets.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 PowerShell 命令提示字元中,輸入下列命令:At the PowerShell command prompt, type the following command:

    Mount-SPContentDatabase -Name <DatabaseName> -WebApplication <WebApplicationID> [-Verbose]
    

    其中:Where:

    • <DatabaseName> 是唯讀資料庫的名稱。<DatabaseName> is name of the read-only database.

    • <WebApplicationID> 是指派給唯讀資料庫的識別碼。<WebApplicationID> is ID assigned to the read-only database.

      注意

      使用 Mount-SPContentDatabase Cmdlet 附加內容資料庫不同於在 SQL Server 中使用 SQL Server 工具附加資料庫。 Mount-SPContentDatabase 會關聯內容資料庫與 Web 應用程式,讓內容可供讀取。Attaching a content database by using the Mount-SPContentDatabase cmdlet differs from attaching a database in SQL Server by using SQL Server tools. Mount-SPContentDatabase associates the content database with a Web application so that the contents can be read.

如需詳細資訊,請參閱 Mount-SPContentDatabaseFor more information, see Mount-SPContentDatabase.

注意

建議您在執行命令列管理工作時使用 Windows PowerShell。Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

請參閱See also

概念Concepts

SharePoint Server 的備份與復原概觀Overview of backup and recovery in SharePoint Server