在數據庫和服務啟動過程中,經常會出現的問題:
1.SQL Server實例無法正常啟動
2.系統數據庫無法正常啟動
3.網絡配置失敗
4.用戶數據庫無法啟動
5.集群環境下SQL Server資源無法保持在線
目錄
5.啟動SQL Server服務和數據庫... 1
5.1 SQL Server服務啟動步驟... 1
5.1.1 從注冊表中讀取SQL Server啟動信息... 1
5.1.2 檢查硬件,配置內存和CPU.. 2
5.1.3 數據庫啟動... 3
5.1.4 準備網絡... 4
5.2 數據庫狀態切換... 5
5.2.1 Recovering. 5
5.2.2 Online. 6
5.2.3 RECOVERY PENDING.. 6
5.2.4 SUSPECT. 6
5.2.5 EMERGENCY. 6
5.2.6 RESTORING.. 6
5.2.7 Offline. 6
5.3 數據庫長時間處于RECOVERING狀態... 7
5.3.1 多線程并行處理重做和回滾... 7
5.3.2 延遲事務... 7
5.4 數據庫無法啟動的常見問題... 7
5.4.1 Master數據庫不能啟動... 7
5.4.2 資源數據庫... 7
5.4.3 model數據庫... 8
5.4.4 tempdb數據庫... 8
5.4.5 用戶數據庫... 8
5.5 集群環境下,數據庫資源不能ONLINE的常見問題... 10
5.1 SQL Server服務啟動步驟5.1.1 從注冊表中讀取SQL Server啟動信息Sqlservr.exe啟動會去注冊表中找自己所在實例的注冊表信息。這些配置信息存放在HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SQL Server/MSSQL11.X/MSSQLServer下。有幾個比較重要的信息:
1.HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SQL Server/MSSQL11.X/MSSQLServer下,LoginMode:表示是windows驗證還是混合驗證,Audit Level:設置是否記錄用戶登錄信息。
2.HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SQL Server/MSSQL11.X/MSSQLServer /Parameters下是實例的啟動參數
3.HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SQL Server/MSSQL11.X/MSSQLServer /SuperSocketNetLib下記錄了監聽的網絡和訪問方式的。
5.1.1.1 啟動賬號的權限由于要讀取注冊表信息和SQL Server的資源文件,需要啟動服務賬號有很足夠的權限。那么無法啟動實例,甚至連errorlog都無法啟動。
可以使用PRocess Monitor進行監控。如果發現有access DENIED那么說明有權限問題。
5.1.1.2 日志文件和文件夾訪問問題如果SQL Server要啟動,必須正確的創建出日志文件,如果注冊表內-e參數指定的不夠正確就會出現報錯,無法啟動。
5.1.2 檢查硬件,配置內存和CPU等創建出errorlog之后,所有的啟動過程就可以從errorlog中看出來了。
Errorlog先會打印出SQL Server版本號和Windows版本號,啟動參數和進程基本信息:
2014-05-04 14:42:07.05 Server Microsoft SQL Server 2014 - 12.0.2000.8 (X64)
Feb 20 2014 20:04:26
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
2014-05-04 14:42:07.08 Server UTC adjustment: 8:00
2014-05-04 14:42:07.08 Server (c) Microsoft Corporation.
2014-05-04 14:42:07.08 Server All rights reserved.
2014-05-04 14:42:07.08 Server Server process ID is 4252.
2014-05-04 14:42:07.08 Server System Manufacturer: 'System manufacturer', System Model: 'System Product Name'.
2014-05-04 14:42:07.09 Server Authentication mode is MIXED.
2014-05-04 14:42:07.10 Server Logging SQL Server messages in file 'C:/Program Files/Microsoft SQL Server/MSSQL12.MSSQLSERVER/MSSQL/Log/ERRORLOG'.
2014-05-04 14:42:07.10 Server The service account is 'FanrCo-PC/Administrator'. This is an informational message; no user action is required.
2014-05-04 14:42:07.10 Server Registry startup parameters:
-d C:/Program Files/Microsoft SQL Server/MSSQL12.MSSQLSERVER/MSSQL/DATA/master.mdf
-e C:/Program Files/Microsoft SQL Server/MSSQL12.MSSQLSERVER/MSSQL/Log/ERRORLOG
-l C:/Program Files/Microsoft SQL Server/MSSQL12.MSSQLSERVER/MSSQL/DATA/mastlog.ldf
2014-05-04 14:42:07.10 Server Command Line Startup Parameters:
-s "MSSQLSERVER"
之后或讀取出服務器的配置信息,包括處理器和內存,以及進程的優先級:
2014-05-04 14:42:08.73 Server SQL Server detected 1 sockets with 2 cores per socket and 2 logical processors per socket, 2 total logical processors; using 2 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2014-05-04 14:42:08.73 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2014-05-04 14:42:08.73 Server Detected 3838 MB of RAM. This is an informational message; no user action is required.
2014-05-04 14:42:08.76 Server Using conventional memory in the memory manager.
之后會顯示NUMA信息和lock的信息,或為每個節點分配2500個鎖塊,5000個鎖擁有者
注意,在32bit系統下,每個鎖塊需要64字節,鎖擁有者32字節,64bit下,鎖塊96字節,鎖擁有者56個字節:
2014-05-04 14:42:10.38 Server Node configuration: node 0: CPU mask: 0x0000000000000003:0 Active CPU mask: 0x0000000000000003:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2014-05-04 14:42:10.40 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.
顯示CLR版本信息和默認TRACE的開啟:
2014-05-04 14:42:11.33 Server CLR version v4.0.30319 loaded.
2014-05-04 14:42:12.44 spid8s Resource governor reconfiguration succeeded.
2014-05-04 14:42:12.49 spid8s SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2014-05-04 14:42:12.60 spid8s SQL Server Audit has started the audits. This is an informational message. No user action is required.
2014-05-04 14:42:13.93 spid8s SQL Trace ID 1 was started by login "sa".
2014-05-04 14:42:14.09 spid8s Server name is 'FANRCO-PC'. This is an informational message only. No user action is required.
5.1.3 數據庫啟動系統數據庫的啟動順序是master,msdb,mssqlsystemresource,model,tempdb,也可以在errorlog中找到相關信息:
2014-05-04 14:42:10.57 spid8s Starting up database 'master'.
2014-05-04 14:42:16.67 spid21s Starting up database 'msdb'.
2014-05-04 14:42:16.67 spid22s Starting up database 'AdventureWorks2012'.
2014-05-04 14:42:16.74 spid10s Starting up database 'mssqlsystemresource'.
2014-05-04 14:42:16.74 spid23s Starting up database 'tst'.
2014-05-04 14:42:16.75 spid24s Starting up database 'AdventureWorksDW2012'.
2014-05-04 14:42:18.27 spid10s Starting up database 'model'.
2014-05-04 14:42:19.42 spid10s Clearing tempdb database.
新聞熱點
疑難解答