Performance Monitor1:開始性能監控

Performance Monitor是Windows內置的一個可視化監控工具,可以在OS級別上實時記錄系統資源的使用狀況,經過收集和存儲日誌數據,在SQL Server發生異常時,可以還原系統當時的資源的使用狀況,是對SQL Server進行Troubleshooting的首選工具。Performance Monitor使用Performance Counter來追蹤系統的活動狀態的測量值,取樣間隔默認是15s,即,Performance Monitor每隔15s,記錄Performance Counter的當前值。html

Performance Monitor主要有兩個組件:Viewer和Data Collector,分別用於查看和記錄Performance Counter的測量值,開啓Performance Monitor對Server的影響很微小,建議開啓,多收集一些性能數據。安全

一,查看Vieweride

1,打開 Performance Monitor工具

點擊Windows+R,在Run中輸入perfmon,打開Performance Monitor,主要分爲三個目錄:Monitoring Tools,Data Collector Sets 和 Reports。post

2,查看Performance Monitor性能

Performance Monitor是Viewer,有兩種查看模式:View Current Activity 和 View Log Data,前者用於實時監控當前數據,後者用於查看歷史數據。ui

3,圖表(Graph),顯示計數器的測量值url

可以選擇時間區間(zoom to),可以選擇顯示和隱藏指定的Counter,可以縮放(Scale)Counter的值spa

4,Sample Interval,實時監控能夠設置取樣間隔和顯示的數據長度rest

Performance Monitor的取樣時間間隔由屬性 Sample Interval 肯定,經過Performance Monitor Properties -> General tab查看取樣間隔設置

  • 勾選Sample automatically:自動取樣
  • Sample Every  X  seconds:採樣的時間間隔
  • Duration X seconds:Viewer顯示的時間長度,這是 Real-Time 監控模式下保持數據的最長時間

二,建立Data Collector

Data Collector用於記錄Performance Counter的數值,默認存儲在C:\PerfLogs 目錄下,多個Data Collector的集合就是一個Data Collector Set。

1,建立自定義的Data Collector Set

展開Data Collector Sets,點擊User Defined->New->Data Collector Set,輸入Name,選擇 Create Manually(Advanced),不使用模板,自定義建立。

2,建立數據日誌

選擇Create Data Logs,並勾選Performance Counter,經過Add按鈕添加Performance Counter,默認的Sample Interval是15s。

3,添加Performance Counter

根據監控目的,選擇合適的Counter,樓主建立的Data Collector用於監控Disk活動,主要選擇如下7個計數器,經過Add按鈕添加到右側面板中。

4,設置Data Collector Set的Stop Condition,使數據文件Size不會超過限制

Windows使用Set來同一管理Data Collector,每一個Data Collector的數據單獨存儲在文件中,若是數據文件過大,在查看時,Viewer加載過程緩慢,建議將Data Collector的數據文件控制在300MB之內。打開指定Data Collector Set的屬性,切換到Stop Condition Tab,指定中止收集數據的條件。

Overall duration指定:在必定的時間以後,中止收集數據(stop collecting data after a period of time)

Limits指定:當數據收集知足Duration和Maximum Size條件時,將數據文件分離單獨的數據文件。

  • Use limits to segment data collection into separate logs by selecting  When a limit is reached, restart the data collector set.
  • If both limit types are selected, data collection will stop or restart when the first limit is reached.
  • Duration:configure a time period for data collection to write to a single log file.
  • Maximum Size:restart the Data Collector Set or to stop collecting data when the log file reaches the limit.

 

5,Data Manager,刪除舊的無用數據

在Data Collector運行了很長世間以後,Data Collector建立的數據文件可能很大,必須及時將無用的數據清理掉,Data Manger負責清理數據文件。

選中指定的Data Collector Set,右擊彈出快捷菜單,打開Data Manager。在Data Manager Tab中設置Maximum root path size=10GB,並勾選Enable Data Manager複選框;在Actions Tab中,增長一個Action,Age:30Days,勾選Delete Data Files,表示將超過30天的數據文件刪除。

三,查看Reports,還原計數器在某個歷史時間點的測量值

若是設置了Data Collector的Limits屬性,將數據文件分段,那麼在Disk Activity目錄下,能看到多個文件,每一個文件的大小不會超過Stop Condtition Tab的限制,樓主的文件大小不超過300MB,每一個文件記錄數據的時間不會大於6hours。

點擊數據文件,Viewer就能自動加載數據,此時,Viewer處於View Log Data模式。

  • 從圖表面板,可以查看各個Counter,在特定時間點的測量值;
  • 從時間軸,選中時間區間,右擊選中Zoom To,可以縮放圖表面板;
  • 從Counter面板,可以顯示或隱藏計數器,能對單個計數值按比例縮放(Scale);

四,開啓Performance Monitor對Server性能影響很微小

在一個Production Server上,Performance Monitor運行很長一段時間以後,Task Management顯示消耗的CPU和內存資源數量很小,如圖:

引用《SQL Server 2012 實施與管理實戰指南》:

默認的Performance Monitor 是用來Real-Time 檢測系統的,在現實的問題分析中,更多的是須要在問題發生以前,開啓Performance Counter來收集數據,一段時間以後,或者問題重現以後,經過收集的數據,離線分析問題的現象和緣由。

有些DBA會擔憂,抓這麼多Performance Counter會不會影響Server的性能,根據經驗,Performance Monitor對系統總體性能的影響幾乎感受不到,因此,能夠放心大膽地多收集一些Counter,時間間隔設置默認值 15s 是比較安全的。

若是性能日誌文件超過1GB,在View Report時,加載log file會很慢,通常將日誌文件的Size的最大值設置爲300MB。這能夠經過選擇「Stop Condition」 Tab,勾選 Maximum Size 設置日誌文件的最大值爲300MB來實現。

 

Performance Counter是性能監控的測量值,直接關係到監控的數據是否完善和合理,請繼續閱讀《Performance Monitor2:Peformance Counter》瞭解經常使用的計數器。

 

參考文檔:

Windows Performance Monitor

Performance Monitoring Getting Started Guide

相關文章
相關標籤/搜索