Linux或Docker以及跨平台SQL Operations Studio中SQL Server

image

I recently met some folks that didn't know that SQL Server 2017 also runs on Linux but they really needed to know. They had a single Windows desktop and a single Windows Server that they were keeping around to run SQL Server. They had long-been a Linux shop and was now fully containerzed...except for this machine under Anna's desk. (I assume The Cloud is next...pro tip: Don't have important servers under your desk). You can even get a license first and decide on the platform later.

我最近遇到了一些不知道SQL Server 2017也可以在Linux上运行的人,但他们确实需要知道。 他们只有一个Windows桌面和一个Windows Server,它们一直在运行SQL Server。 他们本来是一家Linux商店,现在已经完全装箱了……除了Anna桌子下面的这台机器。 (我认为接下来是Cloud ...专业提示:您的办公桌下面没有重要的服务器)。 您甚至可以先获得许可证,然后再决定使用该平台

You can run SQL Server on a few Linux flavors...

您可以在几种Linux版本上运行SQL Server ...

or, even better, run it on Docker...

甚至更好的是在Docker上运行它...

Of course you'll want to do the appropriate volume mapping to keep your database on durable storage. I'm digging being able to spin up a full SQL Server inside a container on my Windows machine with no install.

当然,您将需要进行适当的卷映射以使数据库保持持久存储。 我正在挖掘能够无需安装而在Windows计算机上的容器内启动完整SQL Server。

I've got Docker for Windows on my laptop and I'm using Shayne Boyer's "Docker Why" repo to make the point. Look at his sample DockerCompose that includes both a web frontend and a backend using SQL Server on Linux.

我在笔记本电脑上安装了适用于Windows的Docker,并使用Shayne Boyer的“ Docker Why”存储库来说明这一点。 看一下他的示例DockerCompose ,其中包括在Linux上使用SQL Server的Web前端和后端。

version: '3.0'
services:

mssql:
image: microsoft/mssql-server-linux:latest
container_name: db
ports:
- 1433:1433
volumes:
- /var/opt/mssql
# we copy our scripts onto the container
- ./sql:/usr/src/app
# bash will be executed from that path, our scripts folder
working_dir: /usr/src/app
# run the entrypoint.sh that will import the data AND sqlserver
command: sh -c ' chmod +x ./start.sh; ./start.sh & /opt/mssql/bin/sqlservr;'
environment:
ACCEPT_EULA: 'Y'
SA_PASSWORD: P@$$w0rdP@$$w0rd

Note his starting command where he's doing an initial population of the database with sample data, then running sqlservr itself. The SQL Server on Linux Docker container includes the "sqlcmd" command line so you can set up the database, maintain it, etc with the same command line you've used on Windows. You can also configure SQL Server from Environment Variables so it makes it easy to use within Docker/Kubernetes. It'll take just a few minutes to get going.

请注意他的启动命令,其中他正在使用示例数据对数据库进行初始填充,然后运行sqlservr本身。 Linux Docker容器上SQL Server包含“ sqlcmd”命令行,因此您可以使用与Windows上相同的命令行来设置数据库,维护数据库等。 您还可以从环境变量配置SQL Server,以便在Docker / Kubernetes中轻松使用。 只需几分钟即可开始

Example:

例:

/opt/mssql-tools/bin/sqlcmd -S localhost -d Names -U SA -P $SA_PASSWORD -I -Q "ALTER TABLE Names ADD ID UniqueIdentifier DEFAULT newid() NOT NULL;"

I cloned his repo (and I have .NET Core 2.1) and did a "docker-compose up" and boom, running a front end under Alpine and backend with SQL Server on Linux.

我克隆了他的仓库(我有.NET Core 2.1),并做了“ docker-compose up”和繁荣,在Alpine下运行前端,在Linux上使用SQL Server后端。

101→ C:\Users\scott> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e5b4dae93f6d namesweb "dotnet namesweb.dll" 38 minutes ago Up 38 minutes 0.0.0.0:57270->80/tcp, 0.0.0.0:44348->443/tcp src_namesweb_1
5ddffb76f9f9 microsoft/mssql-server-linux:latest "sh -c ' chmod +x ./…" 41 minutes ago Up 39 minutes 0.0.0.0:1433->1433/tcp mssql

Command lines are nice, but SQL Server is known for SQL Server Management Studio, a nice GUI for Windows. Did they release SQL Server on Linux and then expect everyone use Windows to manage it? I say nay nay! Check out the cross-platform and open source SQL Operations Studio, "a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux." You can download SQL Operations Studio free here.

命令行很不错,但是SQL Server以SQL Server Management Studio (用于Windows的漂亮GUI)而闻名。 他们是否在Linux上发布了SQL Server,然后希望每个人都使用Windows来管理它? 我说不! 查看跨平台和开放源代码的SQL Operations Studio ,它是“一种数据管理工具,可从Windows,macOS和Linux使用SQL Server,Azure SQL DB和SQL DW。” 您可以在此处免费下载SQL Operations Studio

SQL Ops Studio is really impressive. Here I am querying SQL Server on Linux running within my Docker container on my Windows laptop.

SQL Ops Studio确实令人印象深刻。 在这里,我要查询Windows笔记本电脑上运行在Docker容器中Linux上SQL Server。

SQL Ops Studio - Cross platform SQL management

As I'm digging in and learning how far cross-platform SQL Server has come, I also checked out the mssql extension for Visual Studio Code that lets you develop and execute SQL against any SQL Server. The VS Code SQL Server Extension is also open source!

当我深入研究跨平台SQL Server时,我还检查了Visual Studio Code的mssql扩展,该扩展使您可以针对任何SQL Server开发和执行SQL。 VS Code SQL Server扩展也是开源的!

Go check it SQL Server in Docker at https://github.com/Microsoft/mssql-docker and try Shayne's sample at https://github.com/spboyer/docker-why

去检查它在码头工人SQL Server在https://github.com/Microsoft/mssql-docker并尝试谢恩的样品在https://github.com/spboyer/docker-why

Sponsor: Scale your Python for big data & big science with Intel® Distribution for Python. Near-native code speed. Use with NumPy, SciPy & scikit-learn. Get it Today!

赞助商:借助适用于Python的英特尔®发行版,将Python扩展到大数据和大科学领域。 接近本机的代码速度。 与NumPy,SciPy和scikit-learn一起使用。 立即获取

翻译自: https://www.hanselman.com/blog/sql-server-on-linux-or-in-docker-plus-crossplatform-sql-operations-studio

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值