2018年4月24日 星期二

SQL Server Reporting Services failed to start (Reporting Services啟動失敗)

SQL Server Reporting Services failed to start
(Reporting Services啟動失敗)


Problem 問題:
The SQL Server Reporting Services (MSSQLSERVER) service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.

Resolution 解決方法:
有三種解決方法,以下是我常用的一種
To increase the default service time-out, follow these steps:
    1. Click Start, click Run, type regedit in the Open box, and then click OK.
    2. Locate and then select the following registry subkey:  
    3. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
    4. Right-click Control, point to New, and then click DWORD.
    5. In the New Value box, type ServicesPipeTimeout, and then press Enter.
    6. Right-click ServicesPipeTimeout, and then click Modify.
    7. Click Decimal, type the number of milliseconds that you want to wait until the service times out, and then click OK.
    8. For example, to wait 60 seconds before the service times out, type 60000.
    9. On the File menu, click Exit, and then restart the computer.

其他解決方法請參考以下連結文件
You cannot start SQL Server Reporting Services after you apply the update that is discussed in KB 2677070
Reporting Services service doesn’t start after the installation of MS12-070 security patch


2018年4月20日 星期五

Cluster service verification failed 叢集服務驗證失敗

Cluster service verification failed
叢集服務驗證失敗

Cause:
如果在Windows 2012 R2 failover cluster上安裝SQL Server 2008 R2 cluster將會遇到此錯誤
Rule "Cluster service verification" failed.

Resolution: 解決方法
事先啟用 Failover Cluster Automation Server功能
Using SQL Server in Windows 8 and later versions of Windows operating system

To resolve this issue, do one of the following:
  • Enable the Failover Cluster Automation Server feature on each node by using Server Manager. In Server Manager, expand Remote Server Administration Tools, expand Feature Administration Tools, expand Failover Clustering Tools, and then click to select Failover Cluster Automation Server. (The screen shot for this step follows.)


2018年3月13日 星期二

Install SQL 2017 CU4 non-English locale without internet access (離線安裝SQL 2017 CU4)

Install SQL 2017 CU4 non-English locale without internet access
(離線安裝SQL 2017 CU4)


週日接到微軟一位Machine Learning專家James Chang訊息,詢問如何離線安裝SQL 2017 CU4
了解狀況後,原來是SQL 2017 CU4在安裝過程中,需要下載Machine Learning(R Server and Python Server)相關cab檔,因為沒有網際網路,所以一直無法成功。
Error log出現要下載下列幾個檔案:
SRO_3.3.3.300_1028.cab
SRS_9.2.0.400_1028.cab
SPS_9.2.0.400_1028.cab
SPO_9.2.0.24_1028.cab
經過來回確認與research,最後的解決方法是
1.download Cab file
透過這篇官方文件,下載需要的cab檔
2.rename cab file
由於這些cab檔案名稱是1033(English語言環境),如果SQL Server是繁體中文版,在CU4的安裝過程中指定這些cab檔案的所在目錄會無法辨識,需手動將cab檔案名稱更名,將1033改為1028
3.provide the location of the correct version of the CAB files
然後在CU4的安裝過程中指定這些cab檔案的所在目錄,這樣才能順利安裝成功。

Reference:

2018年1月17日 星期三

Replication Troubleshooting 複寫疑難排解

Replication Troubleshooting
複寫疑難排解

從TLog讀取
sp_replcounters (Transact-SQL)
Returns replication statistics about latency, throughput, and transaction count for each published database. This stored procedure is executed at the Publisher on any database.
sp_replcounters

Returns a result set of all the transactions in the publication database transaction log that are marked for replication but have not been marked as distributed. This stored procedure is executed at the Publisher on a publication database.
只回傳交易序號
sp_replcmds (Transact-SQL)
Returns the commands for transactions marked for replication. This stored procedure is executed at the Publisher on the publication database.
sp_replcmds is used by the log reader process in transactional replication.
將交易轉成SQL命令回傳

sp_replcmds @maxtrans = 500
GO
sp_replflush
GO
sp_replshowcmds (Transact-SQL)
Returns the commands for transactions marked for replication in readable format. sp_replshowcmds can be run only when client connections (including the current connection) are not reading replicated transactions from the log. This stored procedure is executed at the Publisher on the publication database.
將交易轉成易讀的SQL命令回傳
sp_replshowcmds @maxtrans = 500
GO
sp_replflush
GO

sp_replcmds @maxtrans = 500 -- retrieve 500 pending transactions
GO
SELECT dbid, begin_lsn, commit_lsn, rows, cmds_in_tran
FROM sys.dm_repl_traninfo
GO

SELECT count(*) FROM ::fn_dblog(NULL, NULL)
GO
-- Records marked for REPLICATION
SELECT count(*) FROM ::fn_dblog(NULL, NULL) WHERE Description='REPLICATE'
GO

從散發資料庫讀取
[Distributor]
sp_browsereplcmds (Transact-SQL)
Returns a result set in a readable version of the replicated commands stored in the distribution database, and is used as a diagnostic tool. This stored procedure is executed at the Distributor on the distribution database.
從散發資料庫讀取暫存的交易SQL命令
[Reference]
Transactional Replication Conversations

Monitor Replication 複寫監控

Monitor Replication 複寫監控

使用Tracer Token監控複寫延遲
保留延遲紀錄作法請參考我這篇
USE [distribution]
GO
sp_replmonitorhelppublisher
GO
USE [distribution]
GO
sp_replmonitorhelppublication @publisher = N'SQLDEV1'
GO
USE [distribution]
GO
sp_replmonitorhelpsubscription @publisher = N'SQLDEV1', @publication_type = 0
GO
USE [distribution]
GO
sp_replmonitorsubscriptionpendingcmds
@publisher = N'SQLDEV1',
@publisher_db = 'AdventureWorks2008R2',
@publication = 'Orders',
@subscriber = 'SQLDEVSUB1',
@subscriber_db = 'AdventureWorks2008R2',
@subscription_type = 0
GO
Result Sets
Column name Data type Description
pendingcmdcount int The number of commands that are pending for the subscription.
estimatedprocesstime int Estimate of the number of seconds required to deliver all of the pending commands to the Subscriber.

Monitoring Replication with System Monitor (複寫相關效能計數器Performance Counter)
https://docs.microsoft.com/en-us/sql/relational-databases/replication/monitor/monitoring-replication-with-system-monitor
AgentPerformance objectCounterDescription
All agentsMicrosoft SQL Server: Replication AgentsRunningThe number of replication agents currently running.
Snapshot AgentSQL Server: Replication SnapshotSnapshot: Delivered Cmds/secThe number of commands per second delivered to the Distributor.
Snapshot AgentSQL Server: Replication SnapshotSnapshot: Delivered Trans/secThe number of transactions per second delivered to the Distributor.
Log Reader AgentSQL Server: Replication LogreaderLogreader: Delivered Cmds/secThe number of commands per second delivered to the Distributor.
Log Reader AgentSQL Server: Replication LogreaderLogreader: Delivered Trans/secThe number of transactions per second delivered to the Distributor.
Log Reader AgentSQL Server: Replication LogreaderLogreader: Delivery LatencyThe current amount of time, in milliseconds, elapsed from when transactions are applied at the Publisher to when they are delivered to the Distributor.
Distribution AgentSQL Server: Replication Dist.Dist: Delivered Cmds/secThe number of commands per second delivered to the Subscriber.
Distribution AgentSQL Server: Replication Dist.Dist: Delivered Trans/secThe number of transactions per second delivered to the Subscriber.
Distribution AgentSQL Server: Replication Dist.Dist: Delivery LatencyThe current amount of time, in milliseconds, elapsed from when transactions are delivered to the Distributor to when they are applied at the Subscriber.
Merge AgentSQL Server: Replication MergeConflicts/secThe number of conflicts per second occurring during the merge process.
Merge AgentSQL Server: Replication MergeDownloaded Changes/secThe number of rows per second replicated from the Publisher to the Subscriber.
Merge AgentSQL Server: Replication MergeUploaded Changes/secThe number of rows per second replicated from the Subscriber to the Publisher.

2018年1月16日 星期二

SQL Server 2008 R2 Management Studio – Darker Shades of Blue Theme 套用Visual Studio色彩佈景主題環境設定檔

SQL Server 2008 R2 Management Studio – Darker Shades of Blue Theme
SSMS 2008 R2 套用Visual Studio色彩佈景主題環境設定檔

SQL 2012 SSMS以上才支援匯出與匯入環境設定檔
SQL 2008 R2 SSMS需自行調整字型與色彩,以下方法可以直接套用已經設定好的色彩佈景主題
SQL Server 2008 R2 Management Studio – Darker Shades of Blue Theme 套用Visual Studio色彩佈景主題環境設定檔

2017年11月9日 星期四

Filter content in ERRORLOG log file過濾log檔案的內容

Filter content in ERRORLOG log file
過濾log檔案的內容

當你在Troubleshooting調查一個錯誤與問題時,如果ERRORLOG有大量不需要的紀錄,你可以使用以下方法來過濾。PS.當然如果你使用SSMS UI介面也是可以過濾,但用Command速度比較快一點。

1.Create a exclude text file(E:\Temp\Log\exclude.txt) with the contain below.
建立一個文字檔,填入要過濾的關鍵字,例如以下文字(每一行為一組關鍵字)
Error: 18456
Login failed for user
2.Start a Command Prompt as an Administrator and run the command below.
執行以下命令產生過濾後的ERRORLOG檔

output exclude.txt以外的資料
type E:\Temp\Log\ERRORLOG | findstr /i /v /g:E:\Temp\Log\exclude.txt > E:\Temp\Log\ERRORLOG_Filtered.log

若只想output找到的那一行
type E:\Temp\Log\ERRORLOG | findstr /i /g:E:\Temp\Log\exclude.txt > E:\Temp\Log\ERRORLOG_Filtered.log

/i   : Specifies that the search is not to be case-sensitive.

/v   : Prints only lines that do not contain a match.

/g: file   : Gets search strings from the specified file.


Reference:
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490907(v=technet.10)?redirectedfrom=MSDN

資料治理實施

資料治理實施