微软在开源 .NET Framework 之后,相继推出了跨平台的编辑器 Visual Studio Code,跨平台的 SQL Server 数据库 SQL Server vNext,Visual Studio for Mac,微软在跨平台的路上越走越远了。
SQL Server vNext 发布后,我就想在 linux 环境下尝试一下,但是微软只发布了针对 Ubuntu 和 Red Hat 平台的。我平时习惯使用 Debian, Ubuntu 是基于 Debian 的,所以就按照在 Ubuntu 上安装的方法在 Debian 上安装,最终成功安装了。
安装需求
1、SQL Server 需要至少 3.5G 的内存。如果虚拟机的内存小的话,需要调整到大于 3.5G。
2、SQL Server 依赖于 OpenSSL 1.0.2 以上版本。Debian jessie 的 OpenSSL 是 1.0.1,需要先升级 OpenSSL。Debian 稳定版的软件包里的 OpenSSL 还是 1.0.1 ,所以需要安装不稳定版的软件包。安装方法参考:http://serverfault.com/questions/775298/debian-jessie-nginx-with-openssl-1-0-2-to-use-alpn-rather-than-npn
Add the Debian stretch repository to your apt sources. Don’t use /etc/apt/sources.list for this, but instead use a dedicated file inside /etc/apt/sources.list.d/ to keep it clean, personally I’m using stretch.list.
Put these lines inside there:
deb http://httpredir.debian.org/debian/ stretch main contrib non-free
deb-src http://httpredir.debian.org/debian/ stretch main contrib non-freedeb http://security.debian.org/ stretch/updates main contrib non-free
deb-src http://security.debian.org/ stretch/updates main contrib non-free# stretch-updates, previously known as ‘volatile’
deb http://httpredir.debian.org/debian/ stretch-updates main contrib non-free
deb-src http://httpredir.debian.org/debian/ stretch-updates main contrib non-free
Set up apt pinning to make sure you only pull in packages out of Debian stretch which you’re specifying. The file to use for this is /etc/apt/preferences, inside there, put:Package: *
Pin: release n=jessie
Pin-Priority: 900Package: *
Pin: release a=jessie-backports
Pin-Priority: 500Package: *
Pin: release n=stretch
Pin-Priority: 100
(You might have to alter the suites and priorities to fit your environment.)
Run apt-get update (via sudo / as root) to update the package cache.
升级完 OpenSSL 后就可以安装 SQL Server 了,安装方法参考在 Ubuntu 上的安装方法: https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-ubuntu
1、导入公共库密匙:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
2、注册 Microsoft SQL Server Ubuntu 软件库:
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
3、执行更新和安装命令:
sudo apt-get update
sudo apt-get install -y --allow-unauthenticated mssql-server
4、运行配置脚本:
sudo /opt/mssql/bin/sqlservr-setup
5、配置完成后,查看SQL Server 服务的运行状态:
systemctl status mssql-server
服务正在运行。
查看虚拟机的 IP,在 Win10 中连接安装的数据库:
连接成功!