最近兩周,DB 伺服器記憶體一直佔用不上,給了32G,結果用的記憶體量一直在4G左右,真的很讓人糾結,正常情況下,應該用到17G左右。結果排查了半天,原來是 AWE 開啟後沒有重啟服務,真的是太難了,太糾結了,讓我找了半天。重啟服務後,記憶體佔用慢慢上來了,到了正常水平。
雖然沒什麼技術含量,但是尋找的過程還是蠻有意思的,尋找的方法也是能舉一反三的,所以記錄一下。
首先檢查的是伺服器的版本,發現是 Windows 2003 X64,結果令人詫異的是裝了 Sql Server 2008 X86,太讓人糾結了,要是裝 Sql Server 2008 X64 不上更好嗎?在 64位 系統上,32位 的 Sql Server 是最多隻能佔用4G 的,所以,也就把 排查 AWE 是否配置作為了主要入手點。
直接運行 "sp_configure 'awe enabled'" ,卻報出了 "The configuration option 'awe enabled' does not exist, or it may be an advanced option." 的錯誤,原來需要這樣:
exec sp_configure 'show advanced options', 1
RECONFIGURE
GO
exec sp_configure
之後發現 config_value 為 1 ,而 run_value 為 0,真的是很鬱悶,明顯的配置成功了,卻沒有運行成功,肯定是配置後沒有重啟 Sql Server 服務。
exec sp_configure 是比較好用的,能檢查一些配置項是否生效,主要通過對比 config_value 、run_value 和 預設值。
下表列出了所有可用的配置選項、可能的設定範圍及其預設值。配置選項按以下字母代碼標記:
- A = 進階選項,僅允許有經驗的資料庫管理員或認證的 SQL Server 技術人員變更,並且需要將 show advanced
options 設為 1。
- RR = 需要重新啟動資料庫引擎的選項。
- SC = 自配置選項。
| 配置選項 |
最小值 |
最大值 |
預設值 |
|
Ad Hoc Distributed
Queries (A) |
0 |
1 |
0 |
|
affinity I/O
mask(A,RR) |
-2147483648 |
2147483647 |
0 |
|
affinity64 I/O
mask(A,僅適用於 64 位元版本的 SQL Server) |
-2147483648 |
2147483647 |
0 |
|
affinity mask
(A) |
-2147483648 |
2147483647 |
0 |
|
affinity64
mask(A,僅適用於 64 位元版本的 SQL Server) |
-2147483648 |
2147483647 |
0 |
|
Agent XPs
(A) |
0 |
1 |
0
(當 SQL Server Agent啟動時,改為 1。如果 SQL Server Agent設定為在安裝過程中自動啟動,則為 1。) |
|
allow
updates(已淘汰。請勿使用。將在重新設定期間導致錯誤。) |
0 |
1 |
0 |
|
awe
enabled(A,RR) |
0 |
1 |
0 |
|
blocked process
threshold (A) |
0 |
86400 |
0 |
|
c2 audit
mode(A,RR) |
0 |
1 |
0 |
|
clr enabled |
0 |
1 |
0 |
|
common criteria compliance
enabled (A,RR) |
0 |
1 |
0 |
|
cost threshold for
parallelism (A) |
0 |
32767 |
5 |
|
cross db ownership
chaining |
0 |
1 |
0 |
|
cursor threshold
(A) |
-1 |
2147483647 |
-1 |
|
Database Mail XPs
(A) |
0 |
1 |
0 |
|
default full-text
language (A) |
0 |
2147483647 |
1033 |
|
default language |
0 |
9999 |
0 |
|
default trace
enabled (A) |
0 |
1 |
1 |
|
disallow results from
triggers (A) |
0 |
1 |
0 |
|
fill
factor(A,RR) |
0 |
100 |
0 |
|
ft crawl bandwidth (max),請參閱 ft crawl bandwidth
(A) |
0 |
32767 |
100 |
|
ft crawl bandwidth (min),請參閱 ft crawl bandwidth
(A) |
0 |
32767 |
0 |
|
ft notify bandwidth (max),請參閱 ft notify
bandwidth (A) |
0 |
32767 |
100 |
|
ft notify bandwidth (min),請參閱 ft notify
bandwidth (A) |
0 |
32767 |
0 |
|
index create
memory(A,SC) |
704 |
2147483647 |
0 |
|
in-doubt xact
resolution (A) |
0 |
2 |
0 |
|
lightweight
pooling(A,RR) |
0 |
1 |
0 |
|
locks(A,RR,SC) |
5000 |
2147483647 |
0 |
|
max degree of
parallelism (A) |
0 |
64 |
0 |
|
max full-text crawl
range (A) |
0 |
256 |
4 |
|
max server
memory(A,SC) |
16 |
2147483647 |
2147483647 |
|
max text repl size |
0 |
2147483647 |
65536 |
|
max worker
threads(A,RR) |
128 |
32767
(對於 32 位 SQL Server,建議最大為 1024;對於 64 位元 SQL Server,建議最大為 2048。) |
0
歸零操作將根據處理器的數量自動設定最大背景工作執行緒數,可以使用公式 (256+(<處理器數> -4)* 8) 來計算 32 位
SQL Server 的線程數,64 位元 SQL Server 的線程數為 32 位的 2 倍。 |
|
media
retention(A,RR) |
0 |
365 |
0 |
|
min memory per
query (A) |
512 |
2147483647 |
1024 |
|
min server
memory(A,SC) |
0 |
2147483647 |
8 |
|
nested triggers |
0 |
1 |
1 |
|
network packet
size (A) |
512 |
32767 |
4096 |
|
Ole Automation
Procedures (A) |
0 |
1 |
0 |
|
open
objects(A,RR,已淘汰) |
0 |
2147483647 |
0 |
|
PH_timeout
(A) |
1 |
3600 |
60 |
|
precompute rank
(A) |
0 |
1 |
0 |
|
priority
boost(A,RR) |
0 |
1 |
0 |
|
query governor cost
limit (A) |
0 |
2147483647 |
0 |
|
query wait
(A) |
-1 |
2147483647 |
-1 |
|
recovery
interval(A,SC) |
0 |
32767 |
0 |
|
remote access
(RR) |
0 |
1 |
1 |
|
remote admin
connections |
0 |
1 |
0 |
|
remote login
timeout |
0 |
2147483647 |
20 |
|
remote proc trans |
0 |
1 |
0 |
|
remote query
timeout |
0 |
2147483647 |
600 |
|
Replication XPs 選項
(A) |
0 |
1 |
0 |
|
scan for startup
procs(A,RR) |
0 |
1 |
0 |
|
server trigger
recursion |
0 |
1 |
1 |
|
set working set
size(A,RR,已淘汰) |
0 |
1 |
0 |
|
show advanced
options |
0 |
1 |
0 |
|
SMO and DMO XPs
(A) |
0 |
1 |
1 |
|
SQL Mail XPs
(A) |
0 |
1 |
0 |
|
transform noise
words (A) |
0 |
1 |
0 |
|
two digit year
cutoff (A) |
1753 |
9999 |
2049 |
|
user
connections(A,RR,SC) |
0 |
32767 |
0 |
|
User Instance
Timeout(A,僅出現在 SQL Server 2005 Express Edition 中) |
5 |
65535 |
60 |
|
user instances
enabled(A,僅 SQL Server 2005 Express Edition 中提供) |
0 |
1 |
0 |
|
user options |
0 |
32767 |
0 |
|
Web Assistant
Procedures (A) |
0 |
1 |
0 |
|
xp_cmdshell
(A) |
0 |
1 |
0 |