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年8月21日 星期三
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
今天在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
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
2019年3月20日 星期三
SQL Server RML Utilities pressure testing tool
env: Windows Server 2016
RML Utilities是一個好用的簡易壓測工具,這個工具已經有點歷史,這次在新環境安狀測試看看。
1.這次使用的版本是CU4
RML Utilities for SQL Server (x64) CU4
下載連結:
https://www.microsoft.com/en-us/download/details.aspx?id=4511
Supported Operating System
Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2
可以順利在Windows Server 2016安裝
3.檢查安裝程式,並開始使用RML
安裝程式清單
點選"RML Cmd Prompt"
在"RML Cmd "輸入"ostress /?",顯示相關指令參數
4.使用"RML Utilities"進行壓力測試
在RML指令視窗輸入以下指令:做查詢Server Name的測試
command:
ostress.exe -Q"Select @@VERSION"
這裡有一點要留意,在RML產生2個檔案,一個是LOG檔,一個是OUT檔。
LOG檔記錄執行結果。OUT檔紀錄SCRIPT結果。以我們這個測試案例,就是SELECT @@VERSION的產出結果。
檔案儲存目錄:
C:\Users\Administrator\AppData\Local\Temp\output\
5.測試範例二
command:
ostress.exe -Q"SELECT @@VERSION" -r10
-r 10 代表執行10次
6.測試範例三
command:
ostress.exe -Q"SELECT @@VERSION" -r10 -q
-q : 不會輸出查詢結果到dos 與檔案
7.測試範例四
command:
ostress.exe -dTBTEST03 -Q"SELECT * FROM dbo.test01" -r20 -n40
ostress.exe -SWIN-LON676ITMD5 -Usa -Ppa$$w0rd -dTBTEST03 -Q"EXECUTE dbo.TESTQUERY" -r20 -n40
RML跟sqlcmd很接近,也可以使用遠端連線進行壓測,留意指令格式即可。
-n 代表使用多Thread進行
以下是執行command後,查詢連線數
其中有一連線是查詢連線,所以有41個
這次測試安裝驗證到此一個段落!!!
SQL Server 2016 SP2
RML Utilities是一個好用的簡易壓測工具,這個工具已經有點歷史,這次在新環境安狀測試看看。
1.這次使用的版本是CU4
RML Utilities for SQL Server (x64) CU4
下載連結:
https://www.microsoft.com/en-us/download/details.aspx?id=4511
Supported Operating System
Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2
2.安裝RML Utilities for SQL Server (x64) CU4
這次省略說明。附上安裝步驟畫面
可以順利在Windows Server 2016安裝
3.檢查安裝程式,並開始使用RML
安裝程式清單
點選"RML Cmd Prompt"
在"RML Cmd "輸入"ostress /?",顯示相關指令參數
4.使用"RML Utilities"進行壓力測試
在RML指令視窗輸入以下指令:做查詢Server Name的測試
command:
ostress.exe -Q"Select @@VERSION"
這裡有一點要留意,在RML產生2個檔案,一個是LOG檔,一個是OUT檔。
LOG檔記錄執行結果。OUT檔紀錄SCRIPT結果。以我們這個測試案例,就是SELECT @@VERSION的產出結果。
檔案儲存目錄:
C:\Users\Administrator\AppData\Local\Temp\output\
5.測試範例二
command:
ostress.exe -Q"SELECT @@VERSION" -r10
-r 10 代表執行10次
6.測試範例三
command:
ostress.exe -Q"SELECT @@VERSION" -r10 -q
-q : 不會輸出查詢結果到dos 與檔案
7.測試範例四
command:
ostress.exe -dTBTEST03 -Q"SELECT * FROM dbo.test01" -r20 -n40
ostress.exe -SWIN-LON676ITMD5 -Usa -Ppa$$w0rd -dTBTEST03 -Q"EXECUTE dbo.TESTQUERY" -r20 -n40
RML跟sqlcmd很接近,也可以使用遠端連線進行壓測,留意指令格式即可。
-n 代表使用多Thread進行
以下是執行command後,查詢連線數
其中有一連線是查詢連線,所以有41個
這次測試安裝驗證到此一個段落!!!
2019年3月14日 星期四
SQL Server 2016 database mail queue inactive by bug
env:
Windows Server 2016
SQL Server 2016 SP2
這幾天發現某幾台的SQL Server怎麼都沒有發送一些警示的mail,是管理的太好嗎?感覺不太可能,因為機器的資源很少,難免會出現一些壓力測試的警訊。
所以開始一步一步檢查SQL Server database mail
1.檢查database mail queue與status
command:
EXEC msdb.dbo.sysmail_help_queue_sp
database mail queue竟然有383,很多mail沒有發送出來
2.檢查database mail是否啟動
command:
EXEC msdb.dbo.sysmail_help_status_sp
database mail確定有啟動
3.再次使用查詢指令確認是否有mail尚未發送,與哪些mail已送出
database mail queue竟然有383,很多mail沒有發送出來
2.檢查database mail是否啟動
command:
EXEC msdb.dbo.sysmail_help_status_sp
database mail確定有啟動
3.再次使用查詢指令確認是否有mail尚未發送,與哪些mail已送出
command:
SELECT * FROM msdb.dbo.sysmail_sentitems;
SELECT * FROM msdb.dbo.sysmail_unsentitems;
SELECT * FROM msdb.dbo.sysmail_unsentitems;
已sent的mail是0,但是有很多unsent的mail紀錄
4.確認msdb的service broker是否啟用
command:
SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb';
msdb的service broker已經啟用
5.因為一直找不到哪裡錯誤,所以往微軟官方找文件看看
結果找到以下訊息
SQL Server 2016 SP2 CU4
https://support.microsoft.com/en-gb/help/4464106/cumulative-update-4-for-sql-server-2016-sp2
When you install Cumulative Update 1(CU1), CU2 or CU3 for Microsoft SQL Server 2016 Service Pack 2, you will notice that the config file DatabaseMail.exe.config may be removed. Additionally, the Database Mail feature may not work correctly and cannot send email messages.
裡面提到DatabaseMail.exe.config這個檔案可能被移除。
在檢查後,可以確認是一定會被移除。
SQL Server 2016 SP2 CU5
這裡也有修復database mail的錯誤
另外一篇
SQL Server 2016 SP1 CU1
SQL Server 2016 SP1 CU2
https://support.microsoft.com/en-au/help/4013106/cumulative-update-2-for-sql-server-2016-sp1
6.確認修復方式與範圍
Database mail bug損害的版本範圍:
SQL Server 2016 SP1 CU1
SQL Server 2016 SP2 CU1, CU2, CU3
現行版本SQL Server 2016 SP2 CU1,可以利用service pack修復,但是要重開機。
7.找尋可以修復卻不用重開機的方式
用service pack的方式行不通
所找這篇來看看
SQL Server 2016 SP1 CU1
裡面有提到做法:
To work around this issue, you can implement any one of the following:
1. Create the DatabaseMail.exe.config and drop it next to the DatabaseMail.exe under the Binn folder. You can use notepad.exe or any other editor to edit it. Just make sure you save it by using UTF-8 encoding (in notepad.exe, select Save As... and in the Encoding combo box, select UTF-8):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
2. Run a repair setup action of SQL Server 2016.
3. Manually install .Net Framework 3.5 on the machine.
但是我想不透為何與.Net Framework 3.5有關???
8.開始進行修復,確認DatabaseMail.exe.config是否存在
檔案目錄:
” C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn”
結果找到以下訊息
SQL Server 2016 SP2 CU4
https://support.microsoft.com/en-gb/help/4464106/cumulative-update-4-for-sql-server-2016-sp2
When you install Cumulative Update 1(CU1), CU2 or CU3 for Microsoft SQL Server 2016 Service Pack 2, you will notice that the config file DatabaseMail.exe.config may be removed. Additionally, the Database Mail feature may not work correctly and cannot send email messages.
裡面提到DatabaseMail.exe.config這個檔案可能被移除。
在檢查後,可以確認是一定會被移除。
SQL Server 2016 SP2 CU5
這裡也有修復database mail的錯誤
另外一篇
SQL Server 2016 SP1 CU1
FIX: SQL Server 2016 Database Mail does not
work on a computer that does not have the .NET Framework 3.5 installed or stops
working after applying SQL Server update
SQL Server 2016 SP1 CU2
https://support.microsoft.com/en-au/help/4013106/cumulative-update-2-for-sql-server-2016-sp1
6.確認修復方式與範圍
Database mail bug損害的版本範圍:
SQL Server 2016 SP1 CU1
SQL Server 2016 SP2 CU1, CU2, CU3
現行版本SQL Server 2016 SP2 CU1,可以利用service pack修復,但是要重開機。
7.找尋可以修復卻不用重開機的方式
用service pack的方式行不通
所找這篇來看看
SQL Server 2016 SP1 CU1
FIX: SQL Server 2016 Database Mail does not work on a computer that does not have the .NET Framework 3.5 installed or stops working after applying SQL Server update
裡面有提到做法:
To work around this issue, you can implement any one of the following:
1. Create the DatabaseMail.exe.config and drop it next to the DatabaseMail.exe under the Binn folder. You can use notepad.exe or any other editor to edit it. Just make sure you save it by using UTF-8 encoding (in notepad.exe, select Save As... and in the Encoding combo box, select UTF-8):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
2. Run a repair setup action of SQL Server 2016.
3. Manually install .Net Framework 3.5 on the machine.
但是我想不透為何與.Net Framework 3.5有關???
8.開始進行修復,確認DatabaseMail.exe.config是否存在
檔案目錄:
” C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn”
9.修復database mail
因為我覺得這篇文件寫得有點誇張
https://support.microsoft.com/en-au/help/3186435/sql-server-2016-database-mail-doesn-t-work-when-net-framework-3-5
除了建立DatabaseMail.exe.config外
還要執行下面步驟
Run a repair setup action of SQL Server 2016.
Manually install .Net Framework 3.5 on the machine.
所以我決定忽略後面兩個步驟。
建立DatabaseMail.exe.config的動作,我也找一台SQL Sserver 2016把檔案複製過來
接著執行下面指令:
USE msdb;
EXEC sysmail_stop_sp;
EXEC sysmail_start_sp;
沒錯,重啟database mail
10.確認重啟database mail後的狀態
一旦重啟後,database mail就會開始發送mail。
所以在重起錢可以考慮是否要把unsent mail刪除
刪除unsent mail指令:
EXECUTE msdb.dbo.sysmail_delete_mailitems_sp
@sent_status = 'unsent' ;
GO
11.利用指令確認mail是否還卡在queue中
command:
SELECT * FROM msdb.dbo.sysmail_sentitems;
SELECT * FROM msdb.dbo.sysmail_unsentitems;
確認沒有unsent mail
https://support.microsoft.com/en-au/help/3186435/sql-server-2016-database-mail-doesn-t-work-when-net-framework-3-5
除了建立DatabaseMail.exe.config外
還要執行下面步驟
Run a repair setup action of SQL Server 2016.
Manually install .Net Framework 3.5 on the machine.
所以我決定忽略後面兩個步驟。
建立DatabaseMail.exe.config的動作,我也找一台SQL Sserver 2016把檔案複製過來
接著執行下面指令:
USE msdb;
EXEC sysmail_stop_sp;
EXEC sysmail_start_sp;
沒錯,重啟database mail
10.確認重啟database mail後的狀態
一旦重啟後,database mail就會開始發送mail。
所以在重起錢可以考慮是否要把unsent mail刪除
刪除unsent mail指令:
EXECUTE msdb.dbo.sysmail_delete_mailitems_sp
@sent_status = 'unsent' ;
GO
command:
SELECT * FROM msdb.dbo.sysmail_sentitems;
SELECT * FROM msdb.dbo.sysmail_unsentitems;
確認沒有unsent mail
手動發送測試mail也有收到。
SQL Server database mail修復大功告成。
2019年3月9日 星期六
SQL Server data collection with error code -1071636372 and -1073450952
env: Windows Server 2016
SQL Server 2016 SP2
很不幸Data Collection出現錯誤,這次錯誤訊息如下:
這個錯誤看來已經有一段時間,導致儲存cache有1GB的檔案。
開始修復這個錯誤。
1.嘗試重新啟動這支job
結果還是一樣的錯誤
2.停用Data Collection
3.重新設定cache folder,設定到新的位置
4.設定完後,可以把舊的cache folder裡面的資料刪除
5.重新啟動Data Collection排程
結果成功
SQL Server 2016 SP2
很不幸Data Collection出現錯誤,這次錯誤訊息如下:
Executed
as user: XXXX\XXXX. SSIS error. Component name: DFT - Upload collection
snapshot, Code: -1071636372, Subcomponent: RFS - Read Current Upload Data
[138], Description: String too long. The adapter read a string that was 256
bytes long, and expected a string no longer than 129 bytes, at offset 100587.
This could indicate a damaged input file. The file shows a string length that
is too large for the buffer column.
. SSIS error. Component name: DFT
- Upload collection snapshot, Code: -1073450952, Subcomponent: SSIS.Pipeline,
Description: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on RFS - Read Current
Upload Data returned error code 0x80004005.
The component returned a failure code when the pipeline engine called
PrimeOutput(). The meaning of the failure code is defined by the component, but
the error is fatal and the pipeline stopped executing. There may be error messages posted before
this with more information about the failure.
.The master package exited with error, previous error messages should
explain the cause. Process Exit Code
5. The step failed.
這個錯誤看來已經有一段時間,導致儲存cache有1GB的檔案。
開始修復這個錯誤。
1.嘗試重新啟動這支job
結果還是一樣的錯誤
2.停用Data Collection
3.重新設定cache folder,設定到新的位置
4.設定完後,可以把舊的cache folder裡面的資料刪除
5.重新啟動Data Collection排程
結果成功
訂閱:
文章 (Atom)