微软已经发布了SQL Server on Linux,目前支持RedHat和Ubuntu两种发行版。
Ubuntu 16.04下安装SQL Server for Linux
下面我们来安装体验一下。
1. 获得YUM源:
YUM的repo文件地址:
https://packages.microsoft.com/config/rhel/7/mssql-server.repo
下载到本地:
wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo
--2016-11-17 18:35:37-- https://packages.microsoft.com/config/rhel/7/mssql-server.repo
Resolving packages.microsoft.com (packages.microsoft.com)... 13.75.127.55
Connecting to packages.microsoft.com (packages.microsoft.com)|13.75.127.55|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 220 [application/octet-stream]
Saving to: 'mssql-server.repo'
100%[=================================================================================================================================>] 220 --.-K/s in 0s
2016-11-17 18:35:37 (47.7 MB/s) - 'mssql-server.repo' saved [220/220]
把此文件复制到/etc/yum.repos.d目录:
cp mssql-server.repo /etc/yum.repos.d/
更新yum信息:
[root@linuxidc~]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
openlogic | 1.3 kB 00:00:00
packages-microsoft-com-mssql-server | 2.9 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/13): extras/7/x86_64/prestodelta | 78 kB 00:00:00
(2/13): openlogic/7/x86_64/filelists | 6.7 kB 00:00:00
(3/13): openlogic/7/x86_64/other | 3.7 kB 00:00:00
(4/13): extras/7/x86_64/filelists_db | 468 kB 00:00:01
(5/13): extras/7/x86_64/other_db | 706 kB 00:00:00
(6/13): packages-microsoft-com-mssql-server/filelists_db | 1.4 kB 00:00:00
(7/13): packages-microsoft-com-mssql-server/other_db | 728 B 00:00:00
(8/13): base/7/x86_64/other_db | 2.3 MB 00:00:01
(9/13): updates/7/x86_64/prestodelta | 786 kB 00:00:00
(10/13): updates/7/x86_64/filelists_db | 5.3 MB 00:00:01
(11/13): base/7/x86_64/filelists_db | 6.2 MB 00:00:03
(12/13): updates/7/x86_64/other_db | 79 MB 00:00:04
(13/13): packages-microsoft-com-mssql-server/primary_db | 2.4 kB 00:00:06
Loading mirror speeds from cached hostfile
openlogic 54/54
openlogic 54/54
Metadata Cache Created
2. 通过yum安装sql server:
Yum查找mssql的相关信息:
[root@linuxidc~]# yum search mssql
Loaded plugins: fastestmirror, langpacks
Repository packages-microsoft-com-mssql-server is listed more than once in the configuration
Loading mirror speeds from cached hostfile
=========================================================================== N/S matched: mssql ============================================================================
mssql-server.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
mssql-server-ha.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
Name and summary matches only, use "search all" for everything.
可以看到有两个版本,ha版本应该是做高可用性的版本。安装mssql-server:
[root@linuxidc~]# yum search mssql
Loaded plugins: fastestmirror, langpacks
Repository packages-microsoft-com-mssql-server is listed more than once in the configuration
Loading mirror speeds from cached hostfile
=========================================================================== N/S matched: mssql ============================================================================
mssql-server.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
mssql-server-ha.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
Name and summary matches only, use "search all" for everything.
[root@linuxidc~]# yum install mssql-server -y
Loaded plugins: fastestmirror, langpacks
Repository packages-microsoft-com-mssql-server is listed more than once in the configuration
packages-microsoft-com-mssql-server | 2.9 kB 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 0:14.0.1.246-6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
mssql-server x86_64 14.0.1.246-6 packages-microsoft-com-mssql-server 138 M
Transaction Summary
===========================================================================================================================================================================
Install 1 Package
Total download size: 138 M
Installed size: 138 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/packages-microsoft-com-mssql-server/packages/mssql-server-14.0.1.246-6.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-server-14.0.1.246-6.x86_64.rpm is not installed
mssql-server-14.0.1.246-6.x86_64.rpm | 138 MB 00:00:05
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
Userid : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
From : https://packages.microsoft.com/keys/microsoft.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mssql-server-14.0.1.246-6.x86_64 1/1
+-------------------------------------------------------------------+
| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
| Microsoft(R) SQL Server(R). |
+-------------------------------------------------------------------+
Verifying : mssql-server-14.0.1.246-6.x86_64 1/1
Installed:
mssql-server.x86_64 0:14.0.1.246-6
Complete!
这样就安装好了。
3. 配置sql server