SharePoint Server 中的已編寫監視設定指令碼概觀Overview of scripted monitoring configuration in SharePoint Server

摘要:了解如何使用 Microsoft PowerShell 和 XML 以自動設定 SharePoint Server 2016 和 SharePoint 2013 的監視設定。Summary: Learn how to use Microsoft PowerShell and XML to automate the configuration of monitoring settings for SharePoint Server 2016 and SharePoint 2013.

您可以使用幾種方式變更 SharePoint Server 環境的監視設定。其中一個方式是使用 SharePoint 管理中心網站。您可以使用此方式對本機伺服器陣列進行小型、單一的變更。另一個方式是直接使用 PowerShell cmdlets。您可以使用此方式對本機或遠端的伺服器陣列進行單一變更。還有另一個方式是建立您自有的 PowerShell 指令碼。您可以使用這些指令碼,對本機或遠端伺服器陣列重複進行多個複雜的變更。You can change the monitoring settings for SharePoint Server environments several ways. One way is to use the SharePoint Central Administration website. You might use this to make a single change to a small, local farm. Another way is to use PowerShell cmdlets directly. You might use this to make a single change to a local or remote farm. Still another way is to create your own PowerShell scripts. You might use these scripts to make multiple complex changes to local or remote farms that might be done repeatedly.

已編寫監視設定指令碼包含一組 PowerShell 指令碼檔案和 XML 資料檔案,稱作設定檔,使系統管理員能夠自動設定 SharePoint Server 環境中的監視設定,包括備份及還原這些設定。系統管理員可以在對伺服器陣列變更之前、變更期間和變更之後執行指令碼。變更可能包含伺服器陣列拓撲更新、主要安全性變更、軟體更新或效能測試更新。指令碼會變更監視設定,使所有必要的監視資料在事件期間收集,而不會在正常操作期間濫記於記錄資料庫。Scripted monitoring configuration involves a set of PowerShell script files and XML data files, called Profiles, to enable administrators to automate configuration of the monitoring settings in SharePoint Server environments, including back up and restore of these settings. Administrators can run the scripts before, during, and after changes to the farm. Changes might include updates of the farm topology, major security changes, software updates, or performance tests. The scripts change the monitoring settings so that all of the necessary monitoring data are collected during the event without flooding the Logging database during normal operation.

  • 診斷設定Diagnostic Settings

  • 使用服務設定Usage Service settings

  • 使用定義Usage definitions

  • 記錄層級設定Log level settings

  • 計時器工作設定Timer job settings

  • SharePoint Health Analyzer 規則設定SharePoint Health Analyzer rule settings

您可以執行已編寫監視設定指令碼以備份與還原伺服器陣列監視設定,而不需執行備份及還原。您可以使用它變更監視設定,使所有必要的監視資料在事件期間收集,而不會在正常操作期間濫記於記錄資料庫。您也可以執行該指令碼,以調整在 SharePoint 生命週期不同階段的監視層級。如需詳細資訊,請參閱 在 SharePoint Server 執行已編寫監視設定指令碼You can run scripted monitoring configuration to backup and restore monitoring settings for the farm without having to run backup and restore. You can use it to change the monitoring settings so that all of the necessary monitoring data is collected during the event without flooding the Logging database during normal operation. You can also run the scripts to tune the level of monitoring during different phases of the SharePoint lifecycle. For more information, see Run scripted monitoring configuration in SharePoint Server.

您也可以複製並修改備份設定檔,以建立針對特定用途的設定檔。如需詳細資訊,請參閱 SharePoint Server 中的設定檔結構描述參照You can also copy and modify the backup Profile to create Profiles for specific purposes. For more information, see Profile schema reference in SharePoint Server.

已編寫監視設定指令碼的元件The components of scripted monitoring configuration

已編寫監視設定指令碼由 PowerShell 指令碼和設定檔所組成,其中包含要在伺服器陣列中變更的設定資料。您可以 TechNet Library 取得這些指令碼。以下是相關的指令碼和設定檔:Scripted monitoring configuration consists of both PowerShell scripts and Profiles that contain the settings data for changes in the farm. The scripts are available on the TechNet Library. Following are the scripts and Profiles that are involved:

  • BackupMonitoringSettings.ps1BackupMonitoringSettings.ps1

    在伺服器陣列上執行此 PowerShell 指令碼,以將各種記錄設定備份至 XML 檔案。Run this PowerShell script on a farm to back up various logging settings to an XML file.

    重要

    您可以在 TechNet Library 的已編寫監視設定指令碼 - BackupMonitoringSettings 中取得此指令碼。This script is available on the TechNet Gallery at Scripted Monitoring Configuration - BackupMonitoringSettings.

  • AlterMonitoringSettings.ps1AlterMonitoringSettings.ps1

    在伺服器上執行此 PowerShell 指令碼,以藉由使用 XML 設定檔做為資料來源,將各種記錄設定進行還原或變更。Run this PowerShell script on a server to restore or change various logging settings by using an XML Profile as a data source.

    重要

    您可以在 TechNet Library 的已編寫監視設定指令碼 - AlterMonitoringSettings 中取得此指令碼。This script is available on the TechNet Gallery at Scripted Monitoring Configuration - AlterMonitoringSettings.

  • 備份設定檔Backup Profile

    BackupMonitoringSettings.ps1 指令碼會建立此 XML 檔案,其中包含上述所有的監視設定。您可以使用 AlterMonitoringSettings.ps1 指令碼的備份檔案,將設定還原至伺服器陣列。您也可以使用此檔案為範本建立另一個設定檔,或對其他伺服器陣列進行變更。The BackupMonitoringSettings.ps1 script creates this XML file which contains all of the monitoring settings mentioned above. You can use the AlterMonitoringSettings.ps1 script backup file to restore the settings to the farm. You can also use this file as a template to create another Profile or to make changes to another farm.

  • 設定檔Profiles

    建立一或多個這些 XML 檔案,藉由使用 AlterMonitoringSettings.ps1 指令碼以修改設定至伺服器陣列。Create one or more of these XML files to modify the settings to the farm by using the AlterMonitoringSettings.ps1 script.

已編寫監視設定指令碼程序The scripted monitoring configuration process

  1. 執行 BackupMonitoringSettings.ps1 指令碼Run the BackupMonitoringSettings.ps1 script

    在伺服器陣列上執行此指令碼,以備份各種監視設定至該指令碼建立的 XML 設定檔。XML 檔案名稱是「BackupSetting_[日期] @ [時間].xml」形式。指令碼會在您每次執行時建立新的檔案。Run this script on a farm to back up various monitoring settings to an XML Profile that the script creates. The XML file name is in the form "BackupSetting_[DATE] @ [Time].xml". The script creates a new file every time you run it.

  2. 藉由複製和更換備份設定檔中的設定,建立設定檔Create a Profile by copying and altering settings in the backup Profile

    您可以複製一份 BackupSettings.xml 檔案,並變更其設定。然後,您可以使用更新的檔案作為要變更伺服器陣列的來源。You can make a copy of the BackupSettings.xml file and change the settings. You can then use the updated file as the source for changes to your farm.

    重要

    請永遠保存原始的 BackupSettings.xml 檔案,如此您可以使用它將您的伺服器陣列還原至原始設定。若要建立自訂的設定檔,請修改 BackupSettings.xml 檔案的複本。Always preserve the original BackupSettings.xml file so that you can use it to restore your farm to the original configuration. To create custom Profiles, modify a copy of the BackupSettings.xml file.

  3. 藉由執行 AlterMonitorngSettings.ps1 指令碼套用設定變更Applying settings changes by running the AlterMonitorngSettings.ps1 script

    建立您自己的設定檔後,您可以執行 AlterMonitoringSettings.ps1 指令碼,以將那些變更套用至伺服器陣列。After you create your own Profile, you can run the AlterMonitoringSettings.ps1 script to apply those changes to the farm.

  4. 還原設定Restore settings

    若要將設定還原至先前的狀態,請執行 AlterMonitoringSettings.ps1 指令碼,並提供 BackupSettings.xml 檔案的路徑。To restore the setting to a previous state, run the AlterMonitoringSettings.ps1 script and provide the path of a BackupSettings.xml file.

  5. 將設定檔套用至另一個伺服器陣列Apply a Profile to another farm

    您也可以使用設定檔,將設定從一個伺服器陣列套用至另一個伺服器陣列。或者,您可以使用更新的設定檔案,將設定套用至許多伺服器陣列。You can also use a Profile to apply the settings from one farm to another farm. Or you can use an updated settings file to apply settings to many farms.

另請參閱See also

概念Concepts

SharePoint Server 中的設定檔結構描述參照Profile schema reference in SharePoint Server

在 SharePoint Server 執行已編寫監視設定指令碼Run scripted monitoring configuration in SharePoint Server

其他資源Other Resources

App Management Service cmdlets in SharePoint ServerApp Management Service cmdlets in SharePoint Server