搜尋本站文章

顯示具有 SQL Server 相關工具 標籤的文章。 顯示所有文章
顯示具有 SQL Server 相關工具 標籤的文章。 顯示所有文章

2017-09-29

Install Telnet Client: 安裝 Telnet用戶端程式


預設是沒有安裝 Telnet 用戶端程式,可以使用以下方式來安裝:


  • 「伺服器管理員」: 「Telnet 用戶端」
    • 「Server Manager」: 「Telnet Client 」
  • 「封裝管理員」 :  
    • 「Package Manager」:  pkgmgr /iu:"TelnetClient"





(1)「封裝管理員」 :  pkgmgr /iu:"TelnetClient"

100_開啟命令列視窗_尚未安裝



輸入執行以下命令來安裝 Telnet Client

pkgmgr /iu:"TelnetClient"


101_pkgmgr 安裝 Telnet Client



102_使用 telnet



103_使用 telnet



104_離開 Telnet: 使用 quit





(2) 「伺服器管理員」: 「Telnet 用戶端」

105_「伺服器管理員」_「Telnet 用戶端」





參考資料

安裝 telnet 用戶端,以Windows Server 2012 R2為例
http://sharedderrick.blogspot.tw/2015/04/telnet-windows-server-2012-r2.html

安裝 telnet 用戶端,使用「封裝管理員(Pkgmgr.exe)」
http://sharedderrick.blogspot.tw/2015/04/telnet-pkgmgrexe.html

使用 telnet 測試 Web Server,以 IIS漏洞-漏洞編號CVE-2015-1635 為例
http://sharedderrick.blogspot.tw/2015/04/telnet-web-server-iis-cve-2015-1635.html

2017-07-26

[SQL Server] Performance Dashboard Reports - CPU bottlenecks, IO bottlenecks, missing Index ,Blocking, Latch

SQL Server 2012 Performance Dashboard Reports 可用於協助 DBA 快速識別出目前系統的效能瓶頸。

Performance Dashboard Reports 是 Microsoft 所提供,採用 SQL Server Management Studio(SSMS) 的自訂報表(Custom Reports)方式來呈現。

可用於解決以下性能上的問題:
  1. CPU  瓶頸(bottlenecks )
  2. DISK IO  瓶頸
  3. 遺漏索引(missing index)
  4. Blocking(封鎖)
  5. Latch contention(閂鎖爭用)
Performance Dashboard Reports 使用 DMV(dynamic management views) 方式來取得系統相關資訊,以自訂報表(*.rdl)方式來呈現,無須安裝 Reporting Services。

適用環境:

  • SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 2014
  • 經過測試,SQL Server 2014、SQL Server 2016 可以使用。




下載與安裝 Performance Dashboard Reports 

示範版本
SQL Server 2016 + SSMS 17.1

工作:
00. 安裝 Performance Dashboard Reports
01. 執行 setup.sql
02. 使用 SSMS  開啟 performance_dashboard_main.rdl

預設路徑

  • "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Performance Dashboard\setup.sql"
  • "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Performance Dashboard\performance_dashboard_main.rdl"


工作00: 安裝 Performance Dashboard Reports

-- 011_安裝 Performance Dashboard Reports


預設安裝路徑:
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Performance Dashboard

-- 012_點選_I_Accept

 

-- 013_Registration_Information



-- 014_Feature_Selection



-- 015_Change_Current_Destination_Folder



-- 016_Ready_to_Install



-- 017_Complete



-- 018_Performance Dashboard_安裝路徑與檔案



-- 019_CHM說明_Performance Dashboard




工作01: 執行 setup.sql

01. 使用 SSMS,執行 setup.sql。
setup.sql 預設是位於:
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Performance Dashboard\setup.sql"

02. setup.sql 將在 msdb 系統資料庫,建立新的結構描述、資料表、預存程序等資料庫物件。
例如:
MS_PerfDashboard、MS_PerfDashboard.tblConfigValues、MS_PerfDashboard.usp_CheckDependencies等

預存程序,約有 37 支。

-- 020_在msdb建立新的物件


-- 021_完成建置



-- 022_檢視產生的預存程序



-- 023_檢視產生的物件




工作02: 使用 SSMS  開啟 performance_dashboard_main.rdl

01. 使用 SSMS,在 物件總管,在執行個體節點上,滑鼠右鍵,選擇 自訂報表。

-- 031_SSMS_執行個體_自訂報表


02. 開啟 performance_dashboard_main.rdl
performance_dashboard_main.rdl 預設路徑:
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Performance Dashboard\performance_dashboard_main.rdl"

-- 032_performance_dashboard_main_路徑


03. 在 執行自訂報表,勾選 請不要再顯示這個警告

-- 033_執行自訂報表


完成安裝。

之後要使用 Performance Dashboard Reports,可直接開啟 SSMS ,就可以看到 Performance Dashboard Reports。

-- 034_完成安裝



-- 035_檢視可用報表類型


-- 36_SSMS_點選已存在的報表_performance_dashboard_main




下載 SQL Server 2012 Performance Dashboard Reports

Microsoft® SQL Server® 2012 Performance Dashboard Reports

-- 101_下載_Performance_Dashboard_Reports


-- 102_功能說明


-- 103_下載的檔案_SQLServer2012_PerformanceDashboard



-- 104_檔案_詳細資訊




參考資料

SQL Server® 2012 Performance Dashboard Reports

SQL Server Performance Dashboard Reports unleashed for Enterprise Monitoring !!!

2017-07-09

[SQL Server] sp_whoisactive: find out long running queries (找出費時、耗資源的查詢)


使用 sp_whoisactive,快速找出費時、耗資源的查詢。

作者: Adam Machanic - Microsoft MVP
http://sqlblog.com/blogs/adam_machanic/default.aspx

示範版本:
sp_whoisactive  Version 11.17 - October 18, 2016 (Box versions 2005-2016 only. NOT for Azure.)

適用環境:
SQL Server 2005 ~ 2016,不適用於 Azure。

若是 Azure SQL Database,請改用此版本:
sp_whoisactive for Azure SQL Database

個人常用的範例

-- EX01_sp_WhoIsActive:增加顯示 執行計畫、交易資訊、封鎖資訊等
USE master
GO
EXEC sp_WhoIsActive @get_plans=1, @get_transaction_info=1, @find_block_leaders=1
GO

-- EX02_sp_WhoIsActive:增加顯示 執行計畫、交易資訊、封鎖資訊、系統資訊等
USE master
GO
EXEC sp_WhoIsActive @get_plans=1, @get_transaction_info=1, @find_block_leaders=1, @get_task_info=2
GO

補充包:
[SQL Server] sp_whoisactive: find out long running queries (找出費時、耗資源的查詢) (2)
http://sharedderrick.blogspot.tw/2017/08/sql-server-spwhoisactive-find-out-long.html



sp_whoisactive 參數說明


參數 說明
@get_plans = 1
增加顯示:執行計畫
If @get_plans = 1, gets the plan based on the request's statement offset
If @get_plans = 2, gets the entire plan based on the request's plan_handle
@get_locks = 1 
增加顯示:XML 格式的執行計畫
Gets associated locks for each request, aggregated in an XML format
@get_transaction_info=1
增加顯示:交易紀錄檔寫入資訊 與 交易持續時間
Enables pulling transaction log write info and transaction duration
@find_block_leaders = 1
增加顯示:封鎖鏈結、封鎖計數
Walk the blocking chain and count the number of total SPIDs blocked all the way down by a given session
Also enables task_info Level 1, if @get_task_info is set to 0
@get_task_info = 2
增加顯示:active tasks, current wait stats, physical I/O, context switches, blocker, 檢視 CXPACKET wait 等
Get information on active tasks, based on three interest levels
Level 0 does not pull any task-related information
Level 1 is a lightweight mode that pulls the top non-CXPACKET wait, giving preference to blockers
Level 2 pulls all available task-based metrics, including: number of active tasks, current wait stats, physical I/O, context switches, and blocker information




sp_whoisactive 使用範例

範例 1:sp_WhoIsActive


-- 01_sp_WhoIsActive without any parameters
USE master
GO
EXEC sp_WhoIsActive
GO

-- 02_sp_WhoIsActive SPID
EXEC sp_WhoIsActive 64
GO

-- 03_sp_WhoIsActive SPID
EXEC sp_WhoIsActive 66
GO


-- 010_sp_WhoIsActive without any parameters



-- 011_sp_WhoIsActive without any parameters_2



-- 012_sp_WhoIsActive without any parameters_3



-- 013_sp_WhoIsActive without any parameters_4



-- 014_sp_WhoIsActive_SPID



-- 015_sp_WhoIsActive_SPID_2



-- 016_sp_WhoIsActive_SPID_3



-- 017_檢視_sql_text




範例 2:@get_plans:增加顯示 執行計畫


-- sp_WhoIsActive,@get_plans:增加顯示 執行計畫
USE master
GO
EXEC sp_WhoIsActive @get_plans = 1
GO


-- 018_增加顯示:執行計畫_get_plans



-- 019_增加顯示:執行計畫_get_plans_2




範例 3:@get_locks:增加顯示 XML 格式的執行計畫


-- sp_WhoIsActive,@get_locks:增加顯示 XML 格式的執行計畫
USE master
GO
EXEC sp_WhoIsActive @get_locks = 1 
GO

-- 020_增加顯示:執行計畫_get_locks




範例 4:@find_block_leaders:增加顯示 封鎖鏈結、封鎖計數


-- sp_WhoIsActive,@find_block_leaders:增加顯示 封鎖鏈結、封鎖計數
USE master
GO
EXEC sp_WhoIsActive @find_block_leaders = 1 
GO


-- 021_增加顯示封鎖鏈結_封鎖計數_find_block_leaders




範例 5:@get_task_info:增加顯示 active tasks, current wait stats, physical I/O, context switches, blocker, CXPACKET wait

-- sp_WhoIsActive,@get_task_info:增加顯示 active tasks, current wait stats, physical I/O, context switches, blocker, CXPACKET wait
USE master
GO
EXEC sp_WhoIsActive @get_task_info = 2
GO


-- 022_增加顯示active tasks_current wait stats_physical IO_get_task_info






下載與安裝 sp_whoisactive

-- 200_sp_whoisactive_official_website



-- 201_who_is_active_v11_17.zip



-- 202_who_is_active_v11_17.sql



-- 203_Create_sp_WhoIsActive



-- 204_Create_sp_WhoIsActive






參考資料

sp_whoisactive
http://whoisactive.com/

sp_whoisactive: The Big Fixes!
http://sqlblog.com/blogs/adam_machanic/archive/2016/10/18/sp-whoisactive-the-big-fixes.aspx

How to Use sp_WhoIsActive to Find Slow SQL Server Queries
https://www.brentozar.com/archive/2010/09/sql-server-dba-scripts-how-to-find-slow-sql-server-queries/

sp_WhoIsActive utility for SQL Server troubleshooting
http://www.sqlserver-dba.com/2015/09/sp_whoisactive-utility-for-sql-server-troubleshooting.html

How to monitor Blocked Processes with SQL Alert and email sp_whoisActive report
http://www.sqlserver-dba.com/2017/01/how-to-monitor-blocked-processes-with-sql-alert-and-email-sp_whoisactive-report.html

How to Log Activity Using sp_whoisactive in a Loop
https://www.brentozar.com/responder/log-sp_whoisactive-to-a-table/

INF: Understanding and resolving SQL Server blocking problems
https://support.microsoft.com/en-us/help/224453/inf-understanding-and-resolving-sql-server-blocking-problems

sp_whoisactive for Azure SQL Database
http://sqlblog.com/blogs/adam_machanic/archive/2016/04/14/sp-whoisactive-for-azure-sql-database-attempt-2.aspx

下載  20170709_sp_WhoIsActive
https://drive.google.com/drive/folders/0B9PQZW3M2F40RU43aFNZUWtJc0k?usp=sharing

2017-03-04

[SQL Server]:壓力測試工具 OSTRESS


OSTRESS:可以對 SQL Server 做壓力測試的工具,這是以 ODBC 為基礎的多重執行緒的查詢工具。


  • 可以設定平行執行給定 T-SQL 陳述式的執行緒數目,以及指定此執行緒上應該執行陳述式的次數。
  • OSTRESS 會加快執行緒的速度,並平行執行所有執行緒上的陳述式。
  • 所有執行緒完成執行之後,OSTRESS 會報告所有執行緒完成執行所花費的時間。


這是 Microsoft SQL Server support team 內部所使用的公用程式。

請謹慎使用。





使用 OSTRESS

點選「RML Cmd Prompt」命令提示字元視窗。



範例:

(1) 直接執行指定的 T-SQL 陳述式。

使用參數 Q



ostress.exe -Q"Select @@VERSION"


若未指定結果的輸出目錄,將會放置到該使用者帳戶的預設TEMP資料夾內,例如:C:\Users\Administrator\AppData\Local\Temp\output。


(2) 重複執行指定的 T-SQL 陳述式 100 次。

使用參數:r

ostress.exe –Q"SELECT @@VERSION" -r100


(3) 開啟 50 條並行連接,也就是 50 條執行緒(threads),並且重複執行 100 次。

使用參數:n 、 r。執行完成後,會關閉連線。

ostress.exe –Q"SELECT @@VERSION" -n50 –r100


(4) 開啟 50 條並行連接,也就是 50 條執行緒(threads),重複執行 20 次,並且採取安靜模式,抑制所有查詢輸出。

使用參數:q 、 n 、 r。執行完成後,會關閉連線。

ostress.exe –Q"SELECT @@VERSION" -n50 –r20 -q


(5) 直接執行指定的 T-SQL 陳述式,將結果輸出到c:\temp。

使用參數:o。測試後,使用者權限足夠,系統會自動建立資料夾。

ostress.exe -Q"SELECT @@VERSION" –oc:\temp





OSTRESS 參數說明

提醒事項,有區分大小寫。

-S:要連接之 MicrosoftSQL Server 執行個體的名稱
-E:使用 Windows 驗證進行連接 (預設值),如果使用 SQL Server 驗證,請分別使用 -U 和 -P 選項來指定使用者名稱和密碼

-d:資料庫的名稱
-Q:要執行的 T-SQL 陳述式

-n:處理每個輸入檔案/查詢的連接數目
-r:每個連接執行每個輸入檔案/查詢的反覆運算次數

-q:安靜模式;抑制所有查詢輸出


-- OSTRESS 可用參數






請參考以下的安裝抓圖

示範環境:
作業系統:SQL Server 2016。

抓圖歷程:下載與安裝 RML(Replay Markup Language) 公用程式
https://goo.gl/photos/gpq8ENxACvMY1nQk7



OSTRESS 是由 Microsoft CSS SQL Server 支援小組所開發的命令列工具。
此工具可用來平行執行查詢或執行預存程序。

您可以設定平行執行給定 T-SQL 陳述式的執行緒數目,以及指定此執行緒上應該執行陳述式的次數,ostress 會加快執行緒的速度,並平行執行所有執行緒上的陳述式。
所有執行緒完成執行之後,ostress 會報告所有執行緒完成執行所花費的時間。

安裝 OSTRESS
OSTRESS 會當做 RML 公用程式的一部分來安裝,您無法獨立安裝 OSTRESS。

[SQL Server]:下載與安裝 RML(Replay Markup Language) 公用程式
http://sharedderrick.blogspot.tw/2017/03/sql-server-rmlreplay-markup-language.html



參考資料

記憶體內部 OLTP 的範例資料庫
https://msdn.microsoft.com/zh-tw/library/mt465764.aspx

Cumulative Update 2 to the RML Utilities for Microsoft SQL Server Released
https://blogs.msdn.microsoft.com/psssql/2013/10/29/cumulative-update-2-to-the-rml-utilities-for-microsoft-sql-server-released/

安裝 RML 公用程式和 ostress
https://github.com/Azure/azure-content-zhtw/blob/master/articles/sql-database/sql-database-in-memory.md

Description of the Replay Markup Language (RML) Utilities for SQL Server
https://support.microsoft.com/zh-tw/help/944837/description-of-the-replay-markup-language-rml-utilities-for-sql-server

Download RML Utilities for SQL Server (x64) CU4
https://www.microsoft.com/en-us/download/details.aspx?id=4511

SQL Server Stress Testing
http://www.sqlconsulting.com/news1103.htm

[SQL Server]:下載與安裝 RML(Replay Markup Language) 公用程式
http://sharedderrick.blogspot.tw/2017/03/sql-server-rmlreplay-markup-language.html