如何破解mssql for linux 3.5G内存的限制
在上有篇博客中主要介绍了如何在CentOS 中安装和配置mssql ,在安装过程中遇到3.5G内存的限制,下面介绍如何去破解,
微软发布了SQLServer for Linux,但是安装竟然需要3.5GB内存,这让大部分云主机用户都没办法尝试这个新东西 这篇我将讲解如何破解这个内存限制 要看关键的可以直接跳到第6步,只需要替换4个字节就可以破解这个限制
首先按照微软的给出的步骤安装和配置 https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-red-hat
到执行/opt/mssql/bin/sqlservr-setup时可以看到这个错误
sqlservr: This program requires a machine with at least 3250 megabytes of memory.
按错误文本查找消息在哪个文件里面
[root@localhost ~]# cd /opt/mssql/bin/
[root@localhost bin]# grep -irn "3250"
[root@localhost bin]# grep -irn "megabytes of memory"
Binary file sqlpackage matches
Binary file sqlpackage matches
Binary file sqlservr matches
[root@localhost bin]# strings sqlservr | grep "megabytes of memory"
%s: This program requires a machine with at least %zu megabytes of memory.
[root@localhost bin]# strings sqlpackage | grep "megabytes of memory"
%s: This program requires a machine with at least %zu megabytes of memory.
看来sqlservr和sqlpackage会检测这个限制,并且这个限制是一个常量
查找错误消息的位置
[root@localhost bin]# hexdump -C sqlservr | less
找到这里
0006baf0 72 69 6e 67 29 00 25 73 3a 20 54 68 69 73 20 70 |ring).%s: This p|
0006bb00 72 6f 67 72 61 6d 20 72 65 71 75 69 72 65 73 20 |rogram requires |
可以看到消息在0006baf6的位置
查找调用错误消息的位置
[root@localhost bin]# objdump -C -S sqlservr | less
找到这里
23940: 48 8d 35 af 81 04 00 lea 0x481af(%rip),%rsi # 6baf6
23947: 31 c0 xor %eax,%eax
23949: 48 89 ca mov %rcx,%rdx
2394c: 48 89 d9 mov %rbx,%rcx
2394f: e8 6c e4 fe ff callq 11dc0 <fprintf@plt>
23954: bf 01 00 00 00 mov $0x1,%edi
23959: e8 e2 e1 fe ff callq 11b40 <exit@plt>
判断的函数在这里
238e0: 55 push %rbp
238e1: 48 89 e5 mov %rsp,%rbp
238e4: 53 push %rbx
238e5: 48 83 ec 78 sub $0x78,%rsp
// 把这个函数接收的第二个参数放到rbx
// 参考 https://en.wikipedia.org/wiki/X86_calling_conventions (System V AMD64 ABI)
238e9: 48 89 f3 mov %rsi,%rbx
// 调用sysinfo获取内存大小
// rdi是第一个参数,是一个在堆栈中的struct sysinfo
// 参考 https://linux.die.net/man/2/sysinfo
238ec: 48 8d 7d 88 lea -0x78(%rbp),%rdi
238f0: e8 3b e3 fe ff callq 11c30 <sysinfo@plt>
// 偏移量的计算如下
// -0x78: uptime (struct sysinfo的开头地址)
// -0x70: loads[3]
// -0x58: totalram
// -0x50: freeram
// -0x48: sharedram
// -0x40: bufferram
// -0x38: totalswap
// -0x30: freeswap
// -0x28: procs (short为什么占8个字节?看https://en.wikipedia.org/wiki/Data_structure_alignment)
// -0x20: totalhigh
// -0x18: freehigh
// -0x10: mem_unit (同样,int 4个字节 align 4个字节)
// 计算出rax = totalram * mem_unit
238f5: 8b 45 f0 mov -0x10(%rbp),%eax
238f8: 48 0f af 45 a8 imul -0x58(%rbp),%rax
// 如果rax小于rbx则跳到23909,即显示内存不足并退出
238fd: 48 39 d8 cmp %rbx,%rax
23900: 72 07 jb 23909
23902: 48 83 c4 78 add $0x78,%rsp
23906: 5b pop %rbx
23907: 5d pop %rbp
23908: c3 retq
调用判断的函数的代码在这里
// 这里的第二个参数是3250000000,可以看到内存的限制值是一个常量
// 0xc1b71080 = 3250000000
1486a: be 80 10 b7 c1 mov $0xc1b71080,%esi
1486f: 4c 89 e7 mov %r12,%rdi
14872: e8 69 f0 00 00 callq 238e0
顺道再用hexdump查找一下有多少处地方用了80 10 b7 c1,结果是只有一处
00014860 00 00 48 89 df e8 66 15 00 00 be 80 10 b7 c1 4c |..H...f........L|
00014870 89 e7 e8 69 f0 00 00 0f 57 c0 0f 29 85 70 ff ff |...i....W..).p..|
使用python修改代码 改条件判断的jb或者改8010b7c1都可以,我这里把8010b7c1改成更小的值0080841e(512M)
其实以上内容我是看不懂的,惭愧,直接复制粘贴过来,大体意思应该是找出哪里对内存进行了限制,下面的内容是主要的,所以我们如果看不懂的博友们可以直接使用下面的步骤进行破解,注意切换自己的mssql的bin目录下 使用下面的命令:
[root@localhost bin]# mv sqlservr sqlservr.old
[root@localhost bin]# python
>>> a = open("sqlservr.old", "rb").read()
>>> b = a.replace("\x80\x10\xb7\xc1", "\x00\x80\x84\x1e")
>>> open("sqlservr", "wb").write(b)
[root@localhost bin]# chmod +x sqlservr
如果怕自己打字出错,请直接复制粘贴,然后再重新来过我们的安装步骤 ./mssql -conf setup 就可以安装成功了。
可以继续替换掉sqlpackage中的限制值,但是不替换也可以使用
继续配置sqlserver
[root@localhost bin]# /opt/mssql/bin/sqlservr-setup
[root@localhost bin]# systemctl status mssql-server
如果你执行完命令后没有看到服务正常启动,可能是之前的配置没有成功导致的 删除mssql的数据文件夹并重试即可
[root@localhost bin]# rm -rf /var/opt/mssql
[root@localhost bin]# /opt/mssql/bin/sqlservr-setup
正常启动后可以看到
● mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-12-05 22:50:06 EST; 20s ago
Main PID: 2625 (sqlservr)
CGroup: /system.slice/mssql-server.service
├─2625 /opt/mssql/bin/sqlservr
└─2638 /opt/mssql/bin/sqlservr Dec 05 22:50:10 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:10.85 spid17s Server is listening on [ 0.0.0.0 ...433].
Dec 05 22:50:10 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:10.87 Server Server is listening on [ 127.0.0....434].
Dec 05 22:50:10 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:10.89 Server Dedicated admin connection suppor...1434.
Dec 05 22:50:10 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:10.89 spid17s SQL Server is now ready for clien...ired.
Dec 05 22:50:11 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:11.77 spid6s Starting up database 'tempdb'.
Dec 05 22:50:12 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:12.02 spid6s The tempdb database has 1 data file(s).
Dec 05 22:50:12 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:12.02 spid20s The Service Broker endpoint is in...tate.
Dec 05 22:50:12 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:12.03 spid20s The Database Mirroring endpoint i...tate.
Dec 05 22:50:12 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:12.09 spid20s Service Broker manager has started.
Dec 05 22:50:12 localhost.localdomain sqlservr[2625]: 2016-12-06 03:50:12.14 spid5s Recovery is complete. This is an ...ired.
Hint: Some lines were ellipsized, use -l to show in full.
启动成功后使用微软提供的命令行工具连接也可以,使用windows上的客户端连接也可以 https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-tools 下图是2G内存上运行的mssql
本文转自 破解SQLServer for Linux预览版的3.5GB内存限制 (RHEL篇)
如何破解mssql for linux 3.5G内存的限制的更多相关文章
- 破解SQLServer for Linux预览版的3.5GB内存限制 (UBUNTU篇)
在上一篇中我提到了如何破解RHEL上SQLServer的内存大小限制,但是Ubuntu上还有一道检查 这篇我将会讲解如何在3.5GB以下内存的Ubuntu中安装和运行SQLServer for Lin ...
- 破解SQLServer for Linux预览版的3.5GB内存限制 (RHEL篇)
微软发布了SQLServer for Linux,但是安装竟然需要3.5GB内存,这让大部分云主机用户都没办法尝试这个新东西 这篇我将讲解如何破解这个内存限制 要看关键的可以直接跳到第6步,只需要替换 ...
- 破解SQLServer for Linux预览版的3.5GB内存限制 (RHEL篇) 转
https://www.ancii.com/database/30842.html 微软发布了SQLServer for Linux,但是安装竟然需要3.5GB内存,这让大部分云主机用户都没办法尝试这 ...
- Linux就这个范儿 第15章 七种武器 linux 同步IO: sync、fsync与fdatasync Linux中的内存大页面huge page/large page David Cutler Linux读写内存数据的三种方式
Linux就这个范儿 第15章 七种武器 linux 同步IO: sync.fsync与fdatasync Linux中的内存大页面huge page/large page David Cut ...
- 老司机带你开飞机 一: mssql on linux 安装指导
通常在本机开发环境中需要搭建所有的服务,还要修改本地的hosts,实在是不胜其烦.如今有了docker,完全不用污染本地环境,且看老司机带你搭建一个asp.net core的开发环境集群.愿你走出虚拟 ...
- linux中tomcat内存溢出解决办法
用命令 tail -f /root/apache-tomcat-6.0.20/logs/catalina.out(需要找到tomcat路径) 查看日志,查看是否有错误 linux中tomcat内存溢出 ...
- linux中tomcat内存溢出
刚开始测试服务器与线上后台都不能上传10分钟以上的视频,后来只要是视频就不能上传,进入服务器查日志得到如下错误: Caused by: java.lang.OutOfMemoryError: Java ...
- Linux内核笔记--内存管理之用户态进程内存分配
内核版本:linux-2.6.11 Linux在加载一个可执行程序的时候做了种种复杂的工作,内存分配是其中非常重要的一环,作为一个linux程序员必然会想要知道这个过程到底是怎么样的,内核源码会告诉你 ...
- Linux内核笔记——内存管理之slab分配器
内核版本:linux-2.6.11 内存区和内存对象 伙伴系统是linux用于满足对不同大小块内存分配和释放请求的解决方案,它为slab分配器提供页框分配请求的实现. 如果我们需要请求具有连续物理地址 ...
随机推荐
- <2013 08 17> BucketList of girlfriend
BucketList of girlfriend 1.出国旅游 2.跟相爱的人结婚,生个健康可爱的孩子 3.说一口流利的英语 4.学素描和水彩 5.买个雅马哈钢琴,偶尔学着弹一首曲子 6.把泪腺堵住 ...
- Vue.js中css的作用域
Vue.js中的css的作用域问题: 如果在vue组件下的style中定义样式,效果会作用于整个html页面,如果只想本组件的css样式只作用于本组件的话,在<style>标签里添加sco ...
- 如何在有input() 语句下断点调试(内附高清无码福利)
困扰了半天,一直没找到如何在含有输入语句的情况下用pycharm进行断点调试(调试的同时进行输入交互), But 经过尝试,还是找到了~~~ 通过debug可以快速的找到报错信息,以及观察程序每步的运 ...
- 流畅的python python 序列
内置序列 容器类型 list .tuple和collections.deque这些序列能放入不同的类型的数据 扁平序列 str.byets.bytearray.memoryview(内存视图)和arr ...
- iOS Application Project与OS X Application Project对于plist使用的区别
前几天因为在开源中国看到一个求源代码的问题: 模拟一个动物园系统MyZoo 1.动物园里面有三种动物:Panda,Elephant,Kangaroo 2.三种动物都有一定的数量(不止一只) 3.动物有 ...
- PAT 天梯赛 L1-031. 到底是不是太胖了 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-031 AC代码 #include <iostream> #include <cstdio&g ...
- LeetCode 14. Longest Common Prefix字典树 trie树 学习之 公共前缀字符串
所有字符串的公共前缀最长字符串 特点:(1)公共所有字符串前缀 (好像跟没说一样...) (2)在字典树中特点:任意从根节点触发遇见第一个分支为止的字符集合即为目标串 参考问题:https://lee ...
- 每天一个Linux命令(47)route命令
Linux系统的route命令用于显示和操作内核IP路由表(show / manipulate the IP routing table). (1)用法: 用法: route ...
- INSPIRED启示录 读书笔记 - 第8章 巴顿将军的忠告
目标管理 永远不要告诉别人怎么做.告诉他们做什么,他们自然会发挥天赋,给你惊喜. ——乔治·史密斯·巴顿 首先,产品经理收集需求时,常听到客户建议“如何做”产品,而不是产品应该“做什么”.如果产 ...
- NorFlash、NandFlash、eMMC比较区别【转】
本文转载自:http://www.veryarm.com/1200.html 快闪存储器(英语:Flash Memory),是一种电子式可清除程序化只读存储器的形式,允许在操作中被多次擦或写的存储器. ...