在 SharePoint Server 中設定 Usage and Health Data CollectionConfigure usage and health data collection in SharePoint Server

摘要: 了解如何設定 SharePoint Server 2016 和 SharePoint Server 2013 中的使用狀況與健康情況資料收集。Summary: Learn how to configure usage and health data collection in SharePoint Server 2016 and SharePoint Server 2013.

SharePoint Server 將使用狀況和健康情況資料寫入記錄資料夾及記錄資料庫。您可以使用 SharePoint 管理中心網站設定健康情況資料收集設定。SharePoint Server writes usage and health data to the logging folder and to the logging database. You can use the SharePoint Central Administration website to configure health data collection settings.

開始之前Before you begin

注意

管理員通常會使用 SharePoint 管理中心網站和 SharePoint 管理命令介面來管理部署。如需管理員之協助工具的資訊,請參閱< Accessibility for SharePoint 2013>。 > 因為 SharePoint Server 在 Internet Information Services (IIS) 中以網站形式運作,所以管理員與使用者均依賴瀏覽器提供的協助工具功能。SharePoint Server 支援所支援瀏覽器的協助工具功能。如需詳細資訊,請參閱下列資源: > 在 SharePoint Server 2016 中規劃瀏覽器支援> SharePoint 的協助工具功能> 鍵盤捷徑> 觸控Administrators typically use the SharePoint Central Administration website and the SharePoint Management Shell to manage deployments. For information about accessibility for administrators, see Accessibility for SharePoint 2013. > Because SharePoint Server runs as websites in Internet Information Services (IIS), administrators and users depend on the accessibility features that browsers provide. SharePoint Server supports the accessibility features of supported browsers. For more information, see the following resources: > Plan browser support in SharePoint Server 2016> Accessibility features in SharePoint> Keyboard shortcuts> Touch

使用管理中心設定 Usage and Health Data CollectionConfigure usage and health data collection by using Central Administration

使用狀況與健康情況資料設定為全伺服器陣列設定,因此無法設定伺服器陣列中的個別伺服器。The usage and health data settings are farm-wide and cannot be set for individual servers in the farm.

使用管理中心設定使用狀況與健康情況資料收集:To configure usage and health data collection by using Central Administration:

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that user account performing this procedure is a member of the Farm Administrators group.

    The

  2. 在管理中心首頁上,按一下 [監視]****。In Central Administration, on the Home page, click Monitoring.

  3. 在 [監視] 頁面上,按一下 [報告]**** 區段中的 [設定 Usage and Health Data Collection]****。On the Monitoring page, in the Reporting section, click Configure usage and health data collection.

  4. 在 [設定 Usage and Health Data Collection] 頁面的 [使用狀況資料收集]**** 區段中,選取 [啟用使用狀況資料收集]**** 核取方塊。On the Configure usage and health data collection page, in the Usage Data Collection section, select the Enable usage data collection check box.

  5. 在 [事件選擇]**** 區段中,選取要記錄之事件的核取方塊。In the Event Selection section, select the check boxes of the events that you want to log.

    記錄使用系統資源,可能會影響效能與磁碟使用量。請只記錄需要定期報告的事件。Logging uses system resources and can affect performance and disk usage. Only log those events for which you want regular reports.

    若是進行即興報告或調查,請啟用事件的記錄,然後在報告或調查完成後停用事件的記錄。如需詳細資訊,請參閱<使用 Windows PowerShell 設定事件的使用狀況資料收集>。For impromptu reports or investigations, enable logging for events, and then disable logging for the events after the report or investigation is complete. For more information, see Configure usage data collection for events by using Windows PowerShell.

  6. 在 [使用狀況資料收集設定]**** 區段的 [記錄檔位置]**** 方塊中,輸入寫入使用狀況與健康情況資訊的目的地資料夾路徑。指定的路徑必須存在於伺服器陣列的每部伺服器上。In the Usage Data Collection Settings section, type the path of the folder to which you want usage and health information to be written in the Log file location box. The path that you specify must exist on each server in the farm.

    這些設定會套用至所有的事件。These settings are applied to all events.

  7. 在 [健康情況資料收集]**** 區段中,選取 [啟用健康情況資料收集]**** 核取方塊。若要變更收集排程,請按一下 [狀況記錄排程]****。您會看到收集健康情況資料的計時器工作清單。按一下任何的計時器工作,即可變更排程或停用計時器工作。如果停用計時器工作,即會停止收集對應的狀況資料。如需詳細資訊,請參閱<適用於 SharePoint Server 2016 的計時器工作參考>。In the Health Data Collection section, select the Enable health data collection check box. To change the collection schedules, click Health Logging Schedule. You can see a list of timer jobs that collect health data. Click any of the timer jobs to change its schedule, or disable that timer job. If you disable a timer job, it stops collecting corresponding health data. For more information, see Timer job reference.

  8. 若要變更記錄收集排程,請按一下 [記錄收集排程]****,然後按一下任何計時器工作,即可變更其排程或停用該計時器工作。如果停用計時器工作,即會停止收集對應的記錄資料。To change log collection schedules, click Log Collection Schedule, and then click any of the timer jobs to change its schedule, or disable that timer job. If you disable a timer job, it stops collecting corresponding log data.

  9. 在 [記錄資料庫伺服器]**** 區段中,若要變更驗證方法,請選取 [Windows 驗證]**** 或 [SQL 驗證]**** 選項。In the Logging Database Server section, to change the authentication method, select either the Windows authentication or SQL authentication option.

    若要變更 [資料庫伺服器]**** 與 [資料庫名稱]**** 的值,您必須使用 PowerShell。如需詳細資訊,請參閱<使用 Windows PowerShell 記錄其他記錄資料庫中的使用狀況資料>。To change the Database Server and Database Name values, you must use PowerShell_2nd_NoVer. For more information, see Log usage data in a different Logging Database by using Windows PowerShell.

使用 Windows PowerShell 設定使用狀況資料收集Configure usage data collection by using Windows PowerShell

使用 Windows PowerShell 設定使用狀況資料收集:To configure usage data collection by using Windows 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 2013 產品 Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint 2013 Products 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.

  1. 在 [開始]**** 功能表上,按一下 [所有程式]****。On the Start menu, click All Programs.

  2. 按一下 [SharePoint 2016]****。Click SharePoint 2016.

  3. 按一下 [SharePoint 2016 管理命令介面]****。Click SharePoint 2016 Management Shell.

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

Set-SPUsageService [-LoggingEnabled {1 | 0}] [-UsageLogLocation <Path>] [-Verbose]
<span data-ttu-id="5d3c4-156">其中  _\<Path\>_ 是存在於伺服器陣列之每部電腦上的路徑。</span><span class="sxs-lookup"><span data-stu-id="5d3c4-156">Where  _\<Path\>_ is a path that exists on each computer in the farm.</span></span> 

<span data-ttu-id="5d3c4-157">若要檢視命令的進度,請使用 **Verbose** 參數。</span><span class="sxs-lookup"><span data-stu-id="5d3c4-157">To view the progress of the command, use the **Verbose** parameter.</span></span> 

<span data-ttu-id="5d3c4-158">輸入以啟用使用狀況資料記錄。</span><span class="sxs-lookup"><span data-stu-id="5d3c4-158">Enable usage data logging by typing.</span></span> 
Set-SPUsageService -LoggingEnabled 1

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

使用 Windows PowerShell 設定事件的使用狀況資料收集Configure usage data collection for events by using Windows PowerShell

在管理中心中的 [設定 Usage and Health Data Collection] 頁面上,所列出的事件類型與 PowerShell 中的使用狀況定義相同。您只能使用 PowerShell 個別設定使用狀況定義。此外,您只能設定 DaysRetained 參數。The event types that are listed on the Configure usage and health data collection page in Central Administration are the same as Usage Definitions in PowerShell. You can use only PowerShell to configure usage definitions individually. Moreover, you can configure only the DaysRetained parameter.

若要使用 Windows PowerShell 設定事件的使用狀況資料記錄:To configure usage data logging for events by using Windows 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 2013 產品 Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint 2013 Products 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.

  1. 在 [開始]**** 功能表上,按一下 [所有程式]****。On the Start menu, click All Programs.

  2. 按一下 [SharePoint 2016]****。Click SharePoint 2016.

  3. 按一下 [SharePoint 2016 管理命令介面]****。Click SharePoint 2016 Management Shell.

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

Set-SPUsageDefinition -Identity <SPUsageDefinitionPipeBind> [-Enable] [-DaysRetained <0-31>] [-Verbose]
<span data-ttu-id="5d3c4-p112">其中  _\<SPUsageDefinitionPipeBind\>_ 指定您要更新的使用狀況定義物件。此類型必須是格式為 12345678-90ab-cdef-1234-567890bcdefgh 的有效 GUID、有效的使用狀況定義名稱 (例如 SiteSubscriptionConfig1),或有效之 **SPUsageDefinition** 物件的執行個體。您可以使用 PowerShell **Get-SPUsageDefinition** Cmdlet 取得此 GUID。如需詳細資訊,請參閱 [Get-SPUsageDefinition](http://technet.microsoft.com/library/674e89f1-309b-4901-80db-6be02618e79f.aspx)。</span><span class="sxs-lookup"><span data-stu-id="5d3c4-p112">Where  _\<SPUsageDefinitionPipeBind\>_ specifies the usage definition object that you want to update. The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid name of a usage definition (for example, SiteSubscriptionConfig1); or an instance of a valid **SPUsageDefinition** object. You can use the PowerShell **Get-SPUsageDefinition** cmdlet to obtain this GUID. For more information, see [Get-SPUsageDefinition](http://technet.microsoft.com/library/674e89f1-309b-4901-80db-6be02618e79f.aspx).</span></span>

<span data-ttu-id="5d3c4-p113">使用 **Enable** 參數可以啟用此使用狀況定義的使用狀況記錄。使用 **DaysRetained** 參數可以指定刪除使用狀況資料之前,在記錄中保留的時間。範圍介於 0 到 31 天之間。若要檢視命令的進度,請使用 **Verbose** 參數。</span><span class="sxs-lookup"><span data-stu-id="5d3c4-p113">Use the **Enable** parameter to enable usage logging for this usage definition. Use the **DaysRetained** parameter to specify how long the usage data is retained in the log before it is deleted. The range is 0 to 31 days. To view the progress of the command, use the **Verbose** parameter.</span></span> 

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

使用 Windows PowerShell 記錄其他記錄資料庫中的使用狀況資料Log usage data in a different logging database by using Windows PowerShell

您可以使用 PowerShell 變更此設定。You can use PowerShell to change this setting.

使用 Windows PowerShell 記錄其他記錄資料庫中的使用狀況資料:To log usage data in a different logging database by using Windows 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 2013 產品 Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint 2013 Products 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.

  1. 在 [開始]**** 功能表上,按一下 [所有程式]****。On the Start menu, click All Programs.

  2. 按一下 [SharePoint 2016]****。Click SharePoint 2016.

  3. 按一下 [SharePoint 2016 管理命令介面]****。Click SharePoint 2016 Management Shell.

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

Set-SPUsageApplication -DatabaseServer <DatabaseServerName> -DatabaseName <DatabaseName> [-DatabaseUserName <UserName>] [-DatabasePassword <Password>] [-Verbose]
<span data-ttu-id="5d3c4-201">其中:</span><span class="sxs-lookup"><span data-stu-id="5d3c4-201">Where:</span></span>
  • <DatabaseServerName> 是記錄資料庫的主機伺服器名稱。您必須為 DatabaseServer 參數指定值,即使新資料庫與舊資料庫位於同一資料庫伺服器上亦然。<DatabaseServerName> is the name of host server for the logging database. You must specify a value for the DatabaseServer parameter, even if the new database is located on the same database server as the old one.

  • <DatabaseName> 是記錄資料庫的名稱。<DatabaseName> is the name of the logging database.

  • <UserName> 是用於連線至記錄資料庫的使用者名稱。唯有在使用 SQL Server 驗證存取記錄資料庫時,才使用此參數。<UserName> is the user name to use for connecting to the logging database. Use this parameter only if SQL Server Authentication is used to access the logging database.

  • <Password> 是在 DatabaseUserName 中指定的使用者密碼。如果資料庫擁有人的使用者帳戶與您登入時所使用的使用者帳戶不同,則必須同時指定 <UserName><Password><Password> is the password for the user specified in DatabaseUserName. You must specify both <UserName> and <Password> if the database owner is a different user account than the one with which you logged on.

<span data-ttu-id="5d3c4-209">若要檢視命令的進度,請使用 **Verbose** 參數。</span><span class="sxs-lookup"><span data-stu-id="5d3c4-209">To view the progress of the command, use the **Verbose** parameter.</span></span> 

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

另請參閱See also

概念Concepts

SharePoint Server 2016 監視概觀Overview of monitoring in SharePoint Server