SQL Server误设置max server memory的处理方法
作者:潇湘隐者 发布时间:2024-01-21 14:01:22
昨天网上一网友说,由于他同事误将“max server memory”设置为10M后,SQL Server数据库登录不了,当时我简单测试了一下,今天有空就顺手将整个过程整理一下,记录在此。
在SSMS的UI界面设置“max server memory”,即使你设置为10M大小,但是它会“悄悄”默认修改为128M,你用Profile跟踪或者设置后会发现,它偷偷“修改”了你的设置值(改为了128M),
EXEC sys.sp_configure N'max server memory (MB)', N'128'
GO
RECONFIGURE WITH OVERRIDE
GO
Configuration option 'max server memory (MB)' changed from 4096 to 128. Run the RECONFIGURE statement to install.
如果你没有注意这些细节,或者不信这个事情,那么也可以用脚本测试一下,如下所示,它提示你这个值(10M)不是一个有效值。
当你对“max server memory”做了错误设置后,那么基本上,任何查询或连接都会出现类似下面这样的错误:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
There is insufficient system memory in resource pool 'internal' to run this query. (Microsoft SQL Server, Error: 701)
------------------------------
ADDITIONAL INFORMATION:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - 远程主机强迫关闭了一个现有的连接。) (Microsoft SQL Server, Error: 10054)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=10054&LinkId=20476
------------------------------
远程主机强迫关闭了一个现有的连接。
你检查数据库的错误日志,就会发现有很多额外信息,摘抄部分如下:
.........................................................
.........................................................
2019-12-24 10:15:32.84 spid53 There is insufficient system memory in resource pool 'internal' to run this query.
2019-12-24 10:15:52.88 spid53 Error: 18056, Severity: 20, State: 29. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2019-12-24 10:15:55.89 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2019-12-24 10:16:12.70 Server Failed allocate pages: FAIL_PAGE_ALLOCATION 1
2019-12-24 10:16:12.70 Server
Process/System Counts Value
---------------------------------------- ----------
Available Physical Memory 6614454272
Available Virtual Memory 140726213148672
Available Paging File 7776440320
Working Set 95432704
Percent of Committed Memory in WS 100
Page Faults 57030
System physical memory high 1
System physical memory low 0
Process physical memory low 1
Process virtual memory low 0
2019-12-24 10:16:12.70 Server
Memory Manager KB
---------------------------------------- ----------
VM Reserved 10652776
VM Committed 57972
Locked Pages Allocated 86472
Large Pages Allocated 0
Emergency Memory 1024
Emergency Memory In Use 16
Target Committed 131072
Current Committed 144448
Pages Allocated 84176
Pages Reserved 0
Pages Free 0
Pages In Use 144432
Page Alloc Potential -19912
NUMA Growth Phase 2
Last OOM Factor 1
Last OS Error 0
2019-12-24 10:16:12.70 Server
Memory node Id = 0 KB
---------------------------------------- ----------
VM Reserved 10652712
VM Committed 57952
Locked Pages Allocated 86472
Pages Allocated 84176
Pages Free 0
Target Committed 131048
Current Committed 144424
Foreign Committed 0
Away Committed 0
Taken Away Committed 0
2019-12-24 10:16:12.70 Server
Memory node Id = 64 KB
---------------------------------------- ----------
VM Reserved 0
VM Committed 20
Locked Pages Allocated 0
2019-12-24 10:16:12.70 Server
MEMORYCLERK_SQLGENERAL (node 0) KB
---------------------------------------- ----------
.........................................................
.........................................................
要解决这个问题,你需要关闭数据库服务, 然后以单用户模式+最小配置启动数据库实例,然后去修改max server memory参数。 关闭数据库过程中如果遇到一些问题,可以通过重启服务器解决问题(这个要根据具体实际情况决定,有时候不会遇到问题,有时候会遇到一些问题,例如net stop mssqlserver命令卡住,出现service_state[MSSQLSERVER]): Stop pending)
注意:如果以单用户模式启动,然后以sqlcmd去连接数据库,就会出现下面错误,所以必须以单用户模式+最小配置启动数据库实例
EXEC sys.sp_configure 'max server memory (MB)',4096; #根据实际情况设置内存大小。
RECONFIGURE
GO
然后重启SQL Server实例,问题就解决了。 当然你也可以还原master库的备份到其它测试数据库,然后用还原后master数据库的相关文件替换当前数据库master的相关文件来解决问题。但是那样会相对麻烦,没有这种方法简便、有效!
C:\Windows\system32>net stop mssqlserver
The SQL Server (MSSQLSERVER) service is stopping.
The SQL Server (MSSQLSERVER) service was stopped successfully.
C:\Windows\system32>net start mssqlserver
The SQL Server (MSSQLSERVER) service is starting.
The SQL Server (MSSQLSERVER) service was started successfully.
来源:https://www.cnblogs.com/kerrycode/p/12090494.html


猜你喜欢
- 本文实例为大家分享了Bootstrap组合上下拉框的具体代码,供大家参考,具体内容如下<html><head><
- 本文实例讲述了python判断windows系统是32位还是64位的方法。分享给大家供大家参考。具体分析如下:通常64的windows系统p
- 刚刚解决了这个问题,现在记录下来问题描述当使用lambda层加入自定义的函数后,训练没有bug,载入保存模型则显示Nonetype has
- 业务场景:关联不同数据库中的表的查询比如说,要关联的表是:机器A上的数据库A中的表A && 机器B上的数据库B中的表B。这种
- 本文实例讲述了Python实现基于TCP UDP协议的IPv4 IPv6模式客户端和服务端功能。分享给大家供大家参考,具体如下:由于目前工作
- 最近在为公司做一个门户网站,项目并不咋D,可规划却不小.在做的过程中就发现修改占了很大的工作量.于是就开始想了想如何使前端修改轻松一些.这个
- 需要先装pywin32,windows下调用winapi的接口## _*_ coding:UTF-8 _*___author__ =
- 以下的文章主要是介绍MySQL5创建存储过程的实例演示,MySQL5创建存储在实际操作中应用的频率还是很高的,以下就是MySQL5创建存储过
- 主页上的鼠标是不是就只有箭头和小手两种模样呢?如果鼠标移到“帮助”等字样上时,形状就变成求助的问号;鼠标移到可能需要较长时间等待的超链接时,
- 使用astype实现dataframe字段类型转换# -*- coding: UTF-8 -*-import pandas as pddf
- 1.绘制发散型柱状图python绘制发散型柱状图,展示单个指标的变化的顺序和数量,在柱子上添加了数值文本。实现代码:import numpy
- 本文实例讲述了js判断手机和pc端选择不同执行事件的方法。分享给大家供大家参考。具体如下:判断是否为手机:function isMobile
- 我们需要评估模型预测值来评估训练的好坏。 模型评估是非常重要的,随后的每个模型都有模型评估方式。使用TensorFlow时,需要把模型评估加
- 本文实例讲述了JS实现点击li标签弹出对应的索引功能。分享给大家供大家参考,具体如下:需求:点击li标签,弹出对应的索引先看效果:html结
- 原理之前也做过浏览器web端的SDK数据埋点上报,其实原理大同小异:通过劫持原始方法,获取需要上报的数据,最后再执行原始方法,这样就能实现无
- 学过 Python 的朋友应该都知道 f-strings 是用来非常方便的格式化输出的,觉得它的使用方法无外乎就是 print(f'
- 如何制作一个防止多次刷新计数的图片计数器?请问如何做一个专业的图片计数器? <%countlong
- ------谁正在访问数据库?Select c.sid, c.serial#,c.username,a.object_id,b.
- 我们先来看一个例子:#encoding=utf-8 # #by panda #桥接模式 def printInfo(info): &nbs
- 如何在线创建新表?下面我们以建立一个数码相机库用表为例,看看在ASP程序代码中使用 [CREATE TABLE 相机 (品牌 TEXT(10