在 SharePoint Server 的資料庫間移動網站集合Move site collections between databases in SharePoint Server

摘要:了解如何準備網站集合並在 SharePoint Server 2016 和 SharePoint 2013 的資料庫之間移動網站集合。Summary: Learn how to prepare and move site collections between databases in SharePoint Server 2016 and SharePoint 2013.

在某些情況下,您可能會想要將一或多個網站集合移至不同的內容資料庫。例如,網站集合可能會成長,大到其所在的內容資料庫無法容納,而您必須將網站集合移至較大的內容資料庫。在 SharePoint Server 中將網站集合移到較大的資料庫時,應該先檢視此程序。Under some circumstances, you might want to move one or more site collections to a different content database. For example, a site collection can outgrow the content database on which it resides, and you would have to move the site collection to a larger content database. In SharePoint Server, you should view this procedure as moving the site collection to a larger database.

不過,若網站集合未成長至其預期容量,則將多個網站集合結合為一個內容資料庫可能會更方便使用。在 SharePoint Server 中,此程序不會合併內容資料庫,而是改為將網站集合會移至並加入到新的資料庫。However, if site collections do not grow to their expected capacity, it might be convenient to combine several site collections onto one content database. In SharePoint Server, this process does not merge content databases, instead the site collections are moved to and joined on a new database.

您可以使用 Microsoft PowerShell 在 SharePoint Server 伺服器陣列的資料庫之間移動網站集合。使用「備份與還原」程序也可以移動網站集合。如需如何執行的相關資訊,請參閱<在 SharePoint Server 中備份網站集合>和<在 SharePoint Server 中還原網站集合>。You can move site collections between databases in a SharePoint Server farm by using Microsoft PowerShell. You can also move site collections by using Backup and Restore procedures. For information about how to do this, see Back up site collections in SharePoint Server and Restore site collections in SharePoint Server.

開始之前Before you begin

開始這項作業之前,必須符合下列條件:Before you begin this operation, the following conditions must be true:

  • 目的地內容資料庫必須已存在。The destination content database must already exist.

  • 來源內容資料庫與目的地內容資料庫必須位在相同的 SQL Server 執行個體上。The source content database and destination content database must be located on the same instance of SQL Server.

  • 來源內容資料庫與目的地內容資料庫必須附加至相同的 Web 應用程式。如需如何將內容資料庫新增至 Web 應用程式的詳細資訊,請參閱<在 SharePoint Server 中新增內容資料庫>。The source content database and destination content database must be attached to the same web application. For more information about how to add a content database to a web application, see Add content databases in SharePoint Server.

決定來源網站集合的大小Determining the size of the source site collection

將網站集合移到另一個內容資料庫時,會複製稽核資料。稽核資料的大小會因為網路集合的事件集合設定而有所不同。如果稽核資料很大,您可以先將資料移到另一個資料庫,然後再移動網站集合。若要這樣做,請使用<使用 Microsoft PowerShell 封存和裁剪稽核資料>程序。When you move site collections to another content database the auditing data is copied. The size of the auditing data varies depending on the event collection settings for the site collection. If the auditing data is large, you can move the data to another database before you move the site collection. To do this, use the To archive and trim audit data by using Microsoft PowerShell procedure.

不論移動網站集合的原因為何,一律應先從決定要移動的網站集合大小開始。接著,確定目的地硬碟可以足夠地包含網站集合內容。請確認目的地硬碟的可用空間至少是網站集合所需空間的三倍。Regardless of the reason for moving a site collection, you should always begin the task by determining the size of the site collection that is to be moved. You can then be sure that the destination hard disk can sufficiently contain the site collection contents. Verify that the destination hard disk has at least three times the free space that is required for the site collection.

提示

[!提示] 您可以建立網站配額與電子郵件提醒,了解網站集合所用空間的最新資訊。You can stay current about the space that site collections are using by creating site quotas and e-mail alerts..

使用 PowerShell 決定網站集合的大小To determine the size of the site collection 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 commands:

    $used = (Get-SPSiteAdministration -Identity <http://ServerName/Sites/SiteName>).DiskUsed
    
    $used
    

    其中:Where:

    • <http://ServerName/Sites/SiteName> 是網站集合的名稱。<http://ServerName/Sites/SiteName> is the name of the site collection.

      指定網站集合目前所使用的磁碟空間量,會儲存在 $used 變數中,且會在執行第二個命令時顯示於命令提示字元中。The amount of disk space that is being used by the specified site collection is stored in the $used variable, and is displayed at the command prompt when the second command is run.

      注意

      [!附註] 顯示的磁碟空間量並沒有包含與網路集合一起移動的稽核資料使用的磁碟空間。The amount of disk space that is displayed does not include the disk space that is used by the auditing data that will be moved with the site collection.

如需詳細資訊,請參閱<Get-SPSiteAdministration>。For more information, see Get-SPSiteAdministration.

封存和裁剪稽核資料使用 PowerShellTo archive and trim audit data 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:

    (Get-SPSite -Identity <http://ServerName/Sites/SiteName>).Audit.TrimAuditLog(deleteEndDate)
    

    其中:Where:

    • <http://ServerName/Sites/SiteName> 是網站集合的名稱。<http://ServerName/Sites/SiteName> is the name of the site collection.

      若要在未封存稽核資料前就刪除它,請輸入下列命令:To delete the audit data without archiving it first, type the following command:

    (Get-SPSite -Identity <http://ServerName/Sites/SiteName>).Audit.DeleteEntries(deleteEndDate)
    

如需詳細資訊,請參閱<Get-SPSite>。For more information, see Get-SPSite.

注意

[!附註] 建議您在執行命令列管理工作時使用 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.

在內容資料庫之間移動網站集合Moving site collections between content databases

您可以使用 PowerShell 命令 Move-SPSite ,在內容資料庫之間移動網站集合。此處提供兩個程序。第一個程序會將單一網站集合移至新的內容資料庫,而第二個程序會將多個網站集合移至新的內容資料庫。You can use the PowerShell command Move-SPSite to move site collections between content databases. Two procedures are provided here. The first procedure moves a single site collection to a new content database, and the second procedure moves multiple site collections to a new content database.

移動單一網站集合To move a single site collection

  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:

    Move-SPSite <http://ServerName/Sites/SiteName> -DestinationDatabase <DestinationContentDb>
    

    其中:Where:

    • <http://ServerName/Sites/SiteName> 是網站集合的名稱。<http://ServerName/Sites/SiteName> is the name of the site collection.

    • <DestinationContentDb> 是目的地內容資料庫的名稱。<DestinationContentDb> is the name of the destination content database.

移動多個網站集合To move multiple site collections

  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:

    Get-SPSite -ContentDatabase <SourceContentDb> | Move-SPSite -DestinationDatabase <DestinationContentDb>
    

    其中:Where:

    • <SourceContentDb> 是來源內容資料庫的名稱。<SourceContentDb> is the name of the original content database.

    • <DestinationContentDb> 是目的地內容資料庫的名稱。<DestinationContentDb> is the name of the destination content database.

      此命令會將所有網站集合從來源內容資料庫移至目的地內容資料庫。This command moves all site collections from the source content database to the destination content database.

如需詳細資訊,請參閱<Move-SPSite>。For more information, see Move-SPSite.

注意

[!附註] 建議您在執行命令列管理工作時使用 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 中新增內容資料庫Add content databases in SharePoint Server