sql-server-on-linux-how-i-think-they-did-it : Anthony Nocentino's Blog
http://www.sqlservercentral.com/blogs/anthony-nocentinos-blog/2016/11/21/sql-server-on-linux-how-i-think-they-did-it/
SQL Server on Linux – How I think they did it!
OK, so everyone wants to know how Microsoft did it…how they got SQL Server running on Linux. In this article, I’m going to try to figure out how.
Update: Since the publication of this post, Microsoft has published a blog post detailing the implementation here.
There’s a couple of approaches they could take…a direct port or some abstraction layer…A direct port would have been hard, basically any OS interaction would have had to been looked at and that would have been time consuming and risk prone. Who comes along to save the day? Abstraction. The word you hear about a million times when you take Operating Systems classes in undergrad and grad computer science courses. :)
Well things are finally starting to come to light on how it was done. I had a Twitter conversation this weekend with Slava Oks, who is a leader on the project team and several other very active people in the SQL Community Klaus Aschenbrenner, Ewald Cress, and Lonny Niederstadt. This got my gears turning…to find out…how they did it!
What do we know so far?
So here’s what we know, there’s some level of abstraction going on using a layer called SQL Platform Abstraction Layer (SQLPAL) and also some directly ported code via SQLOSv2. From a design standpoint this it a pretty good compromise. Check out Figure 1, here you can see SQLPAL sits between the Database Engine and the underlying operating system. Whichever one it may be, Windows, Linux and oh yeah “other OS in Future” :)
Figure 1 – SQL Server on Linux – source @SQLRockstar
Background information
So to understand how we got here, it’s worth looking at the Drawbridge project from Microsoft Research. Drawbridge is basically application, or more specifically, process virtualization with a contained OS inside that process space. This is called a picoprocess. Since the process is abstracted away from the underlying operating system, the process will need some part of an OS inside its address space. This is called the Library OS. With that abstracted away…each process has a consistent view of it’s own operating environment. In figure 2, you can see the Library OS and it’s roots into ntoskrnl.dll, which is an NT user-mode kernel. This provides a consistent OS interface for the application. Essentially program code doesn’t need to change.
Now it’s up to the picoprocess as a whole to provide some abstraction back to the actual operating system and that’s where the Platform Abstraction Layer (PAL) comes in. All that’s left is to provide an application binary interface for the picoprocess and you have a completely self-contained process without the need to interact directly the host operating system. This is amazing stuff!
Figure 2 – Drawbridge Architecture – Source MS Research
SQLPAL – SQL Server Platform Abstraction Layer
So, I wanted to see this in action. In the Windows world, hard core SQL people are familiar with attaching a debugger to a SQL process and loading debug symbols to get a view into what’s going on inside of SQL Server. Well in Linux, we can do the same, and it’s a LOT easier. On Linux, there’s a tool called strace, which will give you a view into your programs execution and any interactions it has with the OS. So I launched SQL Server and strace and here’s what I found.
So to launch strace and SQL Server, we add the SQL Server binary as a parameter to strace. Caution, do not do this as root as it may cause a permission issue with log files generated by the sqlservr process. Use sudo to change to the msssql user.
[mssql@rhel1 ~]$ strace /opt/mssql/bin/sqlservr
execve(“/opt/mssql/bin/sqlservr”, [“/opt/mssql/bin/sqlservr”], [/* 24 vars */]) = 0
open(“/lib64/libstdc++.so.6”, O_RDONLY|O_CLOEXEC) = 3
open(“/opt/mssql/bin/../lib/libc++abi.so.1”, O_RDONLY|O_CLOEXEC) = 3
open(“/opt/mssql/lib/system.sfp”, O_RDONLY) = 3
pread(3, “Win8.dbmanifest\0”, 16, 4704) = 16
pread(3, “windows.hiv\0”, 12, 4753) = 12
pread(3, “NtOsKrnl.dll\0”, 13, 5123) = 13
open(“/opt/mssql/lib/system.common.sfp”, O_RDONLY) = 4
pread(4, “kerberos.dll\0”, 13, 15055) = 13
open(“/opt/mssql/lib/sqlservr.sfp”, O_RDONLY) = 7
…omitted
pread(7, “sqlservr.exe\0”, 13, 13398) = 13
…omitted
pread(7, “SqlDK.dll\0”, 10, 14079) = 10
…omitted
pread(7, “sqllang.dll\0″, 12, 14382) = 12
…omitted
pread(7, “SQLOS.dll\0”, 10, 14418) = 10
…omitted
pread(7, “sqlmin.dll\0”, 11, 14511) = 11
nanosleep({999999999, 0}, 2016-11-17 14:11:37.53 Server Microsoft SQL Server vNext (CTP1) – 14.0.1.246 (X64)
Nov 1 2016 23:24:39
Copyright (c) Microsoft Corporation
on Linux (Red Hat Enterprise Linux)
2016-11-17 14:11:37.53 Server Logging SQL Server messages in file ‘C:\var\opt\mssql\log\errorlog’.
SQLOSv2
So in that Twitter conversation I had with Slava and others, we learned it’s not straight PAL, but a SQL Server specific PAL. This allows the product team to provide another path to the underlying OS for performance sensitive code. Look back at figure 1, you’ll see two paths from SQL Sever into SQLPAL. One uses the Win32 APIs, likely provided by Drawbridge (or some variant), and the other is perhaps natively compiled code…really that’s just a guess on my part.
Final thoughts
All, this is a pretty awesome time we’re getting into…Microsoft embracing Linux, SQL on Linux, PowerShell on Linux. I’ve said this many times…Windows, Linux…it’s just an OS. I would like to thank Slava for his insight and also the product team for a fantastic preview release. It’s amazing how seamless this really is.
In a sidebar conversation with Ewald, he made the point that as SQL Server professionals that our investment in the understanding of SQL Server’s internals will persist with this implementation. Which I think is a huge relief for those that have invested years into understanding it’s internals!
Please leave some comments on what your thoughts are on how this works. If you want to contact me directly, you can reach me at aen@centinosystems.com or @nocentino
Disclaimer
Well, if you made it this far…awesome! I want you to know, I don’t have any inside knowledge of how this was developed. I basically sat down and traced the code with the techniques I showed here.
References
https://www.microsoft.com/en-us/research/project/drawbridge/
https://blogs.msdn.microsoft.com/wsl/2016/05/23/pico-process-overview/
The post SQL Server on Linux – How I think they did it! appeared first on Centino Systems Blog.
Comments
Leave a comment on the original post [www.centinosystems.com, opens in a new window]
Posted by David Turner on 1 December 2016
Who cares ? Why bother with SQL server on Linux when you have MySQL/postgres/mongodb. Well long list of far better open source DBs.
SQL server costs a fortune. Powershell crashes, as does Windoze. Indisputable.
Oracle costs 47, 500 a core, SQL server is in the same ball prak. Unreal costs.
Now, the interesting part will be has MS managed to make Linux crash, bet they have. Time will tell.
Ha ha. 21st century, leaving overpriced commercial software behind, about time.
Posted by Lonny Niederstadt on 2 December 2016
Hello David Turner!
I’m not a succinct person, so I’ll summarize:
Who cares?
•Lots of folks for lots of reasons.
•Even if you aren’t one of them.
•But if neither you nor I cared a whit about SQL Server on Linux, I imagine there’d be two fewer blog posts here.
***
1. Who cares?
•Licensing costs are not the only driving factor in database platform selection. Thankfully neither are the opinions or thoughtful arguments that you or I make in blog posts or associated comments :-)
•The determination of “better” or “best” database platform should take into account many factors. Often functional and operational requirements will be included in the decision.
•Many established IT shops using commercial, off the shelf (COTS) software have done so with SQL Server in the stack. Some by choice, some because there software vendor supports SQL Server but not other database platform. In these organizations, there is a heap of interest in Linux bubbling up to software vendors. The main driver seems to be platform consolidation.
•As mentioned, interest in SQL Server on Linux is bubbling up to software vendors. Some software vendors will also be able to benefit from platform consolidation.
•Folks pursuing/retaining a job at organizations using Linux or SQL Server heavily will have an interest in SQL Server on Linux in order to diversify their talents. Future-proofing resume strength or job security is a good strategy. This applies to jobs at software vendors as well as jobs at software consumers.
2. Perhaps your comment would have been better prefaced with “I don’t care.” That would have been a good introduction to why you believe SQL Server on Linux is not worth your attention. My lengthy response, which you may not appreciate or even enjoy, was invited by a question implying no-one as an answer: Who cares?
3. And yet, even “I don’t care” seems a bit odd. How did you end up at this blog post if you don’t care? Why leave a comment if you don’t care? As always, you are free to make your own database platform and skill set decisions, for reasons of license costs, license model, source code availability, or any others. Many others will likely make similar decisions. But there will be a multitude of professionals and organizations that take a different path. That shouldn’t take you by surprise.
Regards,
sql-server-on-linux-how-i-think-they-did-it : Anthony Nocentino's Blog的更多相关文章
- SQL Server on Linux 理由浅析
SQL Server on Linux 理由浅析 今天的爆炸性新闻<SQL Server on Linux>基本上在各大科技媒体上刷屏了 大家看到这个新闻都觉得非常震精,而美股,今天微软开 ...
- 从Windows迁移SQL Server到Linux
前一篇博客关于SQL Server on Linux的安装,地址:http://www.cnblogs.com/fishparadise/p/8057650.html,现在测试把Windows平台下的 ...
- 配置SQL Server on Linux(2)
1. 前言 前一篇配置SQL Server on Linux(1),地址:http://www.cnblogs.com/fishparadise/p/8125203.html ,是关于更改数据库排序规 ...
- 关于解决Mac使用docker安装SQL server for Linux 中文乱码问题
本人是Mac的追随者,无奈本学期数据库课要求使用Microsoft的SQL server.但是Microsoft并没有发布SQL server for Mac ,笔者使用Google搜索后, 发现可以 ...
- Microsoft SQL Server on Linux 踩坑指南
微软用 SQL Server 在 2016 年的时候搞了一个大新闻,宣传 Microsoft ❤️ Linux 打得一众软粉措手不及.但是这还是好事情,Linux 上也有好用的 SQL Server ...
- 在linux上安装 sql server for linux
在linux上安装 sql server for linux Install SQL Server on Red Hat Enterprise Linux Install SQL Server To ...
- 微软发布SQL Server on Linux
本文参考并翻译自:微软云计算与企业执行副总裁Scott Guthrie的博客. 过去的一年,不管是对于微软的数据业务,还是整个行业,都是令人惊喜的一年.在周四刚于纽约举行的Data Driven活动中 ...
- SQL Server on Linux: How? Introduction: SQL Server Blog
SQL Server Blog Official News from Microsoft’s Information Platform https://blogs.technet.microsoft. ...
- SQL Server On Linux:基于实际项目案例,总结功能支持情况及相关问题解决方案,讲如何快速完成迁移
上个月,有个朋友问我说Sql Sever向Mysql迁移有什么好的经验分享,他们公司客户明确提出不再提供Windows服务器,现在计划Mysql迁移.我说Mysql迁移成本太高了,不妨可以了解一下SQ ...
- 配置SQL Server on Linux(1)
1. 背景 SQL Server一般是在安装过程中进行相关的配置,安装完成之后,再去修改有一些配置就比较麻烦,比如更改SQL Server实例级别的排序规则.但在Linux下,安装过程并没有很多可以配 ...
随机推荐
- netty学习指南
这段时间领导让我熟悉Socket开发,我花了三周时间左右去学习相关的知识,包括Java socket开发,重点学习了netty这个异步非阻塞通信框架. 在这里把我学习过程中遇到的有用资料整理了,供大家 ...
- python—用for循环、while循环和一句话打印九九乘法表
用for循环打印九九乘法表: for i in range (1,10): for j in range(1,10): print(j,"x",i,"=",i* ...
- objc_msgSend arm64 崩溃问题
http://blog.csdn.net/chenyong05314/article/details/42121001 2014-12-24 10:49 878人阅读 评论(0) 收藏 举报 转载自: ...
- ubuntu下wireshark+scapy+tcpreply
安装wireshark命令: sudo apt-get install wireshark 运行打开wireshark命令: sudo wireshark(一定要以超级权限打开) 正确打开的窗口应该默 ...
- iOS设计模式 —— KV0
刨根问底KVO KVO 全称 Key-Value Observing.中文叫键值观察.KVO其实是一种观察者模式,观察者在键值改变时会得到通知,利用它可以很容易实现视图组件和数据模型的分离,当数据模型 ...
- Hibernate 和 Mybatis的区别
第一方面:开发速度的对比 就开发速度而言,Hibernate的真正掌握要比Mybatis来得难些.Mybatis框架相对简单很容易上手,但也相对简陋些.个人觉得要用好Mybatis还是首先要先理解好H ...
- tushare 安装
1.pip install lxml 2.pip install pandas 3.pip install requests 4.pip install lxml 5.pip install tush ...
- 通过文件配置:firewalld.service(5)
firewalld.service Name firewalld.service — firewalld service configuration files Synopsis /etc/firew ...
- python如何通过pymongo连接到mongodb?
python版本2.7,mongodb2.6.9,pymongo 首先在mongodb中创建一个数据库users,然后连接到users from pymongo import MongoClientm ...
- AC日记——[Ahoi2013]作业 bzoj 3236
3236 思路: 莫队+树状数组维护: 代码: #include <cmath> #include <cstdio> #include <cstring> #inc ...