2021年2月11日 星期四

Install SQL Server With Service Pack and CU

 env: Windows Server 2016 

         SQL Server 2016

SQL Server 2016自從上市到現在已經到Service Pack 2 與CU15,在安裝新主機時相一次全部完成,可以透過指令方式一次完成所有的Patch,這次提供簡易的指令加上UI設定來完成SQL Server安裝。

我們先準備一台已經安裝Windows Server 2016的環境

還有準備SQL Server 2016與Service Pack 2

1.在Windows Server掛載SQL Server 2016,如下圖:

若沒有IOS也可以把安裝檔複製到特定目錄,例如: C:\SQLServer2016SP2

2.嘗試複製安裝檔案到目錄: C:\SQLServer2016SP2

3.在目錄: C:\SQLServer2016SP2透過以下指令創建目錄: C:\SQLServer2016SP2\updates,用來存放Service Pack2(也可以把CU放在一起)

powershell指令: mkdir C:\SQLServer2016SP2\updates /MIR


4.在目錄: C:\SQLServer2016SP2\ 執行以下指令,在出現安裝UI介面後,可以看到下圖出現升級資訊。接著在UI一步一步設定即可完成。

powershell指令: setup.exe /Action =Install /UpdateEnabled=True /UpdateSource=".\Updates"



若使用ISO掛載安裝,只需要把Service Pack (也可以把CU放在一起),透過以下指令完成。

例如: 把Service Pack 與CU放在目錄: C:\sp_cu

SQL Server 2016掛載後目錄在F:\

powershell指令:

1. cd F:\

2. ./setup.exe /Action=Install /UpdateEnabled=True /UpdateSource="C:\sp_cu"


2021年2月7日 星期日

TLS 1.2 for SQL Server

env: Windows Server 2012R2

        SQL Server 2012

這一陣子許多系統逐步移除TLS1.0, 1.1設定,改用TLS1.2。
過程中產生程式連線出現SSL無法連線的訊息,資料庫這裡也不意外的產生許多連線問題。

這次紀錄的是Windwos Server 2012R2, SQL Server2012的問題,相信對於SQL Server 2014啟用TLS1.2也會有幫助。

在官方文件kb3135244提到SQL Server支援TLS1.2需要做以下更新(不列出SQL Server 2008):
1.SQL Server 2012 SP2 CU10
2.SQL Server 2012 SP2 GDR
3.SQL Server 2012 SP1 CU3
4.SQL Server 2012 SP3 GDR
5.SQL Server 2014 RTM GDR
6.SQL Server 2014 RTM CU12
7,SQL Server 2014 SP1 GDR
8.SQL Server 2014 SP1 CU5

總結版本需要更新如下:
1.SQL Server 2012 SP4 或 + 最新CU(KB4583465)
2.SQL Server 2014 SP3 或 + 最新CU(KB4583462)

確保SQL Server可以支援TLS1.2,SQL Server 2016一開始就支援TLS1.2,因此沒有需要更新的問題。

資料庫主機要實現啟用TLS1.2並關閉TLS1.0, 1.1,執行步驟如下:
1.安裝SQL Server Service Pack
2.重啟資料庫主機確認服務與連線
3.資料庫主機啟用TLS1.2
4.重啟資料庫主機確認服務與連線
5.資料庫主機啟用TLS1.0, 1.1
6.重啟資料庫主機確認服務與連線

若在資料庫主機或是其他主機程式連線有出現SSL的連線錯誤,但是其他主機可以使用SSMS(version 17以上)可以連線到SQL Server 2012資料庫,問題可能是出現在.NET Framwork版本老舊的問題,這裡建議更新到.NET Framwork 4.6以上的版本。若手上沒有.NET Framwork 4.6則可以用SSMS(version 17以上)的版本暫時替代,因為安裝過程中會安裝NET Framwork 4.7.2。


2019年8月21日 星期三

SQL Server 2016 execution plan without parallelism

env: Windows Server 2016
        SQL Server 2016 SP2

資料庫升級進行出現script緩慢的狀況,環境是SQL Server 2008R2 升級到SQL Server 2016,原本以為是統計資訊或是索引造成,但是在比對執行計畫後,發現怎麼都沒有行處理。

這裡題有三個解法:
1.啟用Trace flag:8649
2.在script啟用Trace flag: 8649
3.在SQL Server 2016 SP1 CU3版本,在script啟用HINT
option(use hint('enable_parallel_plan_preference')

但是在透過"1"的方法處理後,速度有加快但是與舊環境比對還是有差異。所以看看環境有沒有可以改善的地方。
找到一個關於NUMA設定值

Hyper-V





















VMware





















NUMA在針對測試環境等CPU配置少的狀況下有幫助,但是以這次遇到的狀況,還是要關閉避免影響效能。








2019年6月23日 星期日

SQL Server 2016 change drive letter step by step after installing

env: Windows Server 2016
         SQL Server 2016

這幾天出現一件震驚的事,系統人員在沒有告知DBA把磁碟標編擅自做更改,把E disk換為F disk。這個變更不僅讓資料庫無法運作。也造成SQL Server無法開啟。
啟動SQL Server錯誤訊息:












我們這次模擬已經安裝完畢後的SQL Server,並且變更磁碟造成路徑問題,嘗試修復此問題。

1.我們安裝的SQL Server路徑內容。
模擬的環境一樣是把SQL Server目錄設定在E disk。









































2.開始在測試環境模擬變更SQL Server路徑。
Turn off SQL Server 2016 service









3.Change drive letter from e disk to f disk








4.Update the file directory from E to F of SQL Server in configuration manager
變更SQL Server Configuration Manager裡面設定的啟始參數路徑


























5.Turn on SQL Server 2016 service
啟動SQL Server











6.SQL Server startup log

2019-06-23 13:21:11.56 spid5s      Starting up database 'msdb'.
2019-06-23 13:21:11.56 spid5s      Error: 17204, Severity: 16, State: 1.
2019-06-23 13:21:11.56 spid5s      FCB::Open failed: Could not open file E:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\MSDBData.mdf for file number 1.  OS error: 3(The system cannot find the path specified.).
2019-06-23 13:21:11.56 spid5s      Error: 5120, Severity: 16, State: 101.
2019-06-23 13:21:11.56 spid5s      Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\MSDBData.mdf". Operating system error 3: "3(The system cannot find the path specified.)".
2019-06-23 13:21:11.56 spid5s      Error: 17207, Severity: 16, State: 1.
2019-06-23 13:21:11.56 spid5s      FileMgr::StartLogFiles: Operating system error 2(The system cannot find the file specified.) occurred while creating or opening file 'E:\Program Files\Microsoft S

2019-06-23 13:21:12.72 spid6s      Starting up database 'model'.
2019-06-23 13:21:12.72 spid6s      Error: 17204, Severity: 16, State: 1.
2019-06-23 13:21:12.72 spid6s      FCB::Open failed: Could not open file E:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\model.mdf for file number 1.  OS error: 3(The system cannot find the path specified.).
2019-06-23 13:21:12.72 spid6s      Error: 5120, Severity: 16, State: 101.
2019-06-23 13:21:12.72 spid6s      Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\model.mdf". Operating system error 3: "3(The system cannot find the path specified.)".
2019-06-23 13:21:12.72 spid6s      Error: 17207, Severity: 16, State: 1.


7.過程中我們嘗試修改registry。但是無法完成,MSDB還是有檔案路徑不正確的狀況。
因此必須還原之前的做法。

8.找出系統資料庫檔案路徑。
語法:
SELECT name, physical_name AS CurrentLocation 
FROM sys.master_files 
WHERE database_id IN(DB_ID(N'master'),DB_ID(N'model'),DB_ID(N'msdb'),DB_ID(N'tempdb')); 

GO  




















9.變更資料庫路徑。
語法:
USE master; 
GO 
ALTER DATABASE [master]  
MODIFY FILE (NAME = master, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\master.mdf'); 
GO 
ALTER DATABASE [master]  
MODIFY FILE (NAME = mastlog, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\mastlog.ldf'); 

GO  

錯誤訊息:
Msg 5121, Level 16, State 1, Line 3
The path specified by "F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\master.mdf" is not in a valid directory.
Msg 5121, Level 16, State 1, Line 6

The path specified by "F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\mastlog.ldf" is not in a valid directory.

10.增加磁碟F disk,並增加對應的路徑'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\'
語法:
New-Item -ItemType directory -Path 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\'

11.再次變更系統資料庫檔案路徑。
語法:
USE master; 
GO 
ALTER DATABASE [master]  
MODIFY FILE (NAME = master, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\master.mdf'); 
GO 
ALTER DATABASE [master]  
MODIFY FILE (NAME = mastlog, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\mastlog.ldf'); 
GO 

ALTER DATABASE [tempdb]  
MODIFY FILE (NAME = tempdev, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\tempdb.mdf'); 
GO 
ALTER DATABASE [tempdb]  
MODIFY FILE (NAME = templog, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\templog.ldf'); 
GO 

ALTER DATABASE [model]  
MODIFY FILE (NAME = modeldev, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\model.mdf'); 
GO 
ALTER DATABASE [model]  
MODIFY FILE (NAME = modellog, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\modellog.ldf'); 
GO  

ALTER DATABASE [msdb]  
MODIFY FILE (NAME = MSDBData, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\MSDBData.mdf'); 
GO 
ALTER DATABASE [msdb]  
MODIFY FILE (NAME = MSDBLog, FILENAME = 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\MSDBLog.ldf'); 

GO  

訊息:
The file "master" has been modified in the system catalog. The new path will be used the next time the database is started.
The file "mastlog" has been modified in the system catalog. The new path will be used the next time the database is started.
The file "tempdev" has been modified in the system catalog. The new path will be used the next time the database is started.
The file "templog" has been modified in the system catalog. The new path will be used the next time the database is started.
The file "modeldev" has been modified in the system catalog. The new path will be used the next time the database is started.
The file "modellog" has been modified in the system catalog. The new path will be used the next time the database is started.
The file "MSDBData" has been modified in the system catalog. The new path will be used the next time the database is started.

The file "MSDBLog" has been modified in the system catalog. The new path will be used the next time the database is started.


12.停用SQL Server service。

13.移除第10步驟增加的F disk。

14.再次修改SQL Server Configuration Manager啟動路徑參數










15.啟動SQL Server service。
若沒有錯誤就是修改成功。
我的啟動log如下。

2019-06-23 14:25:11.88 Server      Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64)
        Apr 29 2016 23:23:58
        Copyright (c) Microsoft Corporation
        Enterprise Evaluation Edition (64-bit) on Windows Server 2016 Standard Evaluation 6.3 <X64> (Build 14393: )

2019-06-23 14:25:11.88 Server      UTC adjustment: 8:00
2019-06-23 14:25:11.88 Server      (c) Microsoft Corporation.
2019-06-23 14:25:11.88 Server      All rights reserved.
2019-06-23 14:25:11.88 Server      Server process ID is 3908.
2019-06-23 14:25:11.88 Server      System Manufacturer: 'innotek GmbH', System Model: 'VirtualBox'.
2019-06-23 14:25:11.88 Server      Authentication mode is MIXED.
2019-06-23 14:25:11.88 Server      Logging SQL Server messages in file 'F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log\ERRORLO'.
2019-06-23 14:25:11.88 Server      The service account is 'NT Service\MSSQLSERVER'. This is an informational message; no user action is required.
2019-06-23 14:25:11.88 Server      Registry startup parameters:
         -d F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\master.mdf
         -e F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log\ERRORLO
         -l F:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
2019-06-23 14:25:11.88 Server      Command Line Startup Parameters:
         -s "MSSQLSERVER"
2019-06-23 14:25:11.88 Server      SQL Server detected 1 sockets with 1 cores per socket and 1 logical processors per socket, 1 total logical processors; using 1 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2019-06-23 14:25:11.88 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2019-06-23 14:25:11.88 Server      Detected 1023 MB of RAM. This is an informational message; no user action is required.
2019-06-23 14:25:11.88 Server      Using conventional memory in the memory manager.
2019-06-23 14:25:11.98 Server      Default collation: SQL_Latin1_General_CP1_CI_AS (us_english 1033)
2019-06-23 14:25:12.03 Server      Buffer pool extension is already disabled. No action is necessary.
2019-06-23 14:25:12.09 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2019-06-23 14:25:12.09 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
2019-06-23 14:25:12.12 Server      The maximum number of dedicated administrator connections for this instance is '1'
2019-06-23 14:25:12.12 Server      This instance of SQL Server last reported using a process ID of 1900 at 6/23/2019 2:22:33 PM (local) 6/23/2019 6:22:33 AM (UTC). This is an informational message only; no user action is required.
2019-06-23 14:25:12.13 Server      Node configuration: node 0: CPU mask: 0x0000000000000001:0 Active CPU mask: 0x0000000000000001:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2019-06-23 14:25:12.13 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2019-06-23 14:25:12.13 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
2019-06-23 14:25:12.16 Server      Query Store settings initialized with enabled = 1,
2019-06-23 14:25:12.17 spid5s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [1] 'master'. XTP Engine version is 0.0.
2019-06-23 14:25:12.17 spid5s      Starting up database 'master'.
2019-06-23 14:25:12.18 spid5s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [1] 'master'. XTP Engine version is 0.0.
2019-06-23 14:25:12.19 spid5s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [1] 'master'. XTP Engine version is 0.0.
2019-06-23 14:25:12.28 Server      CLR version v4.0.30319 loaded.
2019-06-23 14:25:12.31 spid5s      Resource governor reconfiguration succeeded.
2019-06-23 14:25:12.31 spid5s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2019-06-23 14:25:12.32 spid5s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2019-06-23 14:25:12.36 spid5s      SQL Trace ID 1 was started by login "sa".
2019-06-23 14:25:12.36 spid5s      Server name is 'WIN2K16SQL2K163'. This is an informational message only. No user action is required.
2019-06-23 14:25:12.53 spid11s     A self-generated certificate was successfully loaded for encryption.
2019-06-23 14:25:12.54 spid11s     Server is listening on [ 'any' <ipv6> 1433].
2019-06-23 14:25:12.54 spid11s     Server is listening on [ 'any' <ipv4> 1433].
2019-06-23 14:25:12.55 spid11s     Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\MSSQLSERVER ].
2019-06-23 14:25:12.55 spid5s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [4] 'msdb'. XTP Engine version is 0.0.
2019-06-23 14:25:12.55 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [32767] 'mssqlsystemresource'. XTP Engine version is 0.0.
2019-06-23 14:25:12.55 spid11s     Server local connection provider is ready to accept connection on [ \\.\pipe\sql\query ].
2019-06-23 14:25:12.55 spid5s      Starting up database 'msdb'.
2019-06-23 14:25:12.55 spid6s      Starting up database 'mssqlsystemresource'.
2019-06-23 14:25:12.58 Server      Server is listening on [ ::1 <ipv6> 1434].
2019-06-23 14:25:12.59 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
2019-06-23 14:25:12.59 Server      Dedicated admin connection support was established for listening locally on port 1434.
2019-06-23 14:25:12.63 spid11s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2019-06-23 14:25:12.63 Server      SQL Server is attempting to register a Service Principal Name (SPN) for the SQL Server service. Kerberos authentication will not be possible until a SPN is registered for the SQL Server service. This is an informational message. No user action is required.
2019-06-23 14:25:12.70 spid6s      The resource database build version is 13.00.1601. This is an informational message only. No user action is required.
2019-06-23 14:25:12.70 spid5s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [4] 'msdb'. XTP Engine version is 0.0.
2019-06-23 14:25:12.70 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [32767] 'mssqlsystemresource'. XTP Engine version is 0.0.
2019-06-23 14:25:12.79 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [32767] 'mssqlsystemresource'. XTP Engine version is 0.0.
2019-06-23 14:25:12.79 spid5s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [4] 'msdb'. XTP Engine version is 0.0.
2019-06-23 14:25:12.83 Server      The SQL Server Network Interface library successfully registered the Service Principal Name (SPN) [ MSSQLSvc/Win2k16SQL2k163.dba.com ] for the SQL Server service.
2019-06-23 14:25:12.83 Server      The SQL Server Network Interface library successfully registered the Service Principal Name (SPN) [ MSSQLSvc/Win2k16SQL2k163.dba.com:1433 ] for the SQL Server service.
2019-06-23 14:25:12.89 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [3] 'model'. XTP Engine version is 0.0.
2019-06-23 14:25:12.89 spid6s      Starting up database 'model'.
2019-06-23 14:25:12.93 Server      Common language runtime (CLR) functionality initialized using CLR version v4.0.30319 from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\.
2019-06-23 14:25:12.95 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [3] 'model'. XTP Engine version is 0.0.
2019-06-23 14:25:12.97 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [3] 'model'. XTP Engine version is 0.0.
2019-06-23 14:25:13.01 spid6s      Polybase feature disabled.
2019-06-23 14:25:13.01 spid6s      Clearing tempdb database.
2019-06-23 14:25:13.09 Server      Software Usage Metrics is disabled.
2019-06-23 14:25:13.42 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [2] 'tempdb'. XTP Engine version is 0.0.
2019-06-23 14:25:13.42 spid6s      Starting up database 'tempdb'.
2019-06-23 14:25:13.46 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [2] 'tempdb'. XTP Engine version is 0.0.
2019-06-23 14:25:13.52 spid6s      [INFO] HkHostDbCtxt::Initialize(): Database ID: [2] 'tempdb'. XTP Engine version is 0.0.
2019-06-23 14:25:13.64 spid6s      The tempdb database has 1 data file(s).
2019-06-23 14:25:13.65 spid19s     The Service Broker endpoint is in disabled or stopped state.
2019-06-23 14:25:13.65 spid19s     The Database Mirroring endpoint is in disabled or stopped state.
2019-06-23 14:25:13.69 spid19s     Service Broker manager has started.
2019-06-23 14:25:13.70 spid5s      Recovery is complete. This is an informational message only. No user action is required.
2019-06-23 14:25:48.54 spid53      Attempting to load library 'xpsqlbot.dll' into memory. This is an informational message only. No user action is required.
2019-06-23 14:25:48.55 spid53      Using 'xpsqlbot.dll' version '2015.130.1601' to execute extended stored procedure 'xp_qv'. This is an informational message only; no user action is required.
2019-06-23 14:25:49.02 spid55      Attempting to load library 'xpstar.dll' into memory. This is an informational message only. No user action is required.

2019-06-23 14:25:49.04 spid55      Using 'xpstar.dll' version '2015.130.1601' to execute extended stored procedure 'xp_instance_regread'. This is an informational message only; no user action is required.



2019年6月9日 星期日

Can not find m2 pcie ssd in Windows 7

env: Windows 7 SP1

今天在Windows 7添加一條m2 pcie ssd,結果出現pcie驅動安裝失敗。
發現Windows 7並不支援pcie。
最快的解法是安裝hotfix: KB2990941
下載路徑:
http://thehotfixshare.net/board/index.php?autocom=downloads&showfile=20015






2019年6月1日 星期六

SQL Server connection error with SSL security error

env: Windows Server 2016
        SQL Server 2016 SP2

新的資料庫主機安裝crystal report, vs2010, silverlight後,遠端使用資料庫帳號密碼連線SQL Server,出現以下訊息:
[DBNETLIB][ConnectionOpen (SECCreateCredentials()).]SSL Security error.
但是同網段的主機透過服務帳號可以連線














原因可能安裝成是在安裝後升級TLS1.0為TLS1.2並且將TLS1.0停用

解決方式:
在registry執行以下指令,增加TLS1.0 CLIENT設定
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

執行後可以順利連線。



2019年4月5日 星期五

SQL Server Stress pressure testing tool

env: Windows Server 2016
        SQL Server 2016 SP2

這次介紹的壓測軟體"Stress",是由sp_whoisactive 作者"Adam Machanic"所開發,而且已釋出到開源專案平臺 GitHub 上。

下載來源:
https://github.com/ErikEJ/SqlQueryStress

這次我們要測試的版本是0.9.7.61

Stress偏向測試script在多人同時使用時,script反應時間與使用狀況
與RML有點不一樣,可以看到多人同時執行的狀態,各自獨立session連到db,沒有connection pool概念。執行完session即結束。

1.開始安裝"Stress"

安裝步驟一


安裝步驟二
採用預設安裝




















點選"Next"進行安裝





















2.開啟"Stress"
說明:
1.Clean Buffers : DBCC DROPCLEANBUFFERS
2.Free Cache : DBCC FREEPROCCACHE
3.Connection Timeout : 目標伺服器的連線逾時,超過時將回報錯誤
4.Connection Pooling : 啟用或是停用 Connection Pooling,預設啟用
5.Command Timeout : 指令逾時,超過時將回報錯誤
6.Collect I/O Statistics 與 Collect Time Statistics : 是否要收集 I/O 與 Time 統計值
7.Force Client Retrieval of Data : 強迫查詢的資料必須使用 SQL Server 主機的網路資源傳回


























3.設定"Stress"連線
設定連線測試主機,並用SQL帳號認證
設定測試DB





















































4.輸入測試查詢指令
command:
SELECT * FROM dbo.test01
number of Iteration 設定 20
number of thread 設定 40


























5.輸入測試procedure
command:
EXECUTE dbo.TESTQUERY
number of Iteration 設定 300
number of thread 設定 40


























6.測試connection pool是否實現
command:
EXECUTE dbo.TESTQUERY
number of Iteration 設定 800
number of thread 設定 100


























查詢所有session數量
command:
SELECT * FROM SYS.dm_exec_sessions WHERE login_name='test'

session共有102,包含了查詢的session