阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS7.4脱机安装SQL Server 2017

432次阅读
没有评论

共计 10083 个字符,预计需要花费 26 分钟才能阅读完成。

SQL Server on Linux 也发布一段时间了,官方上支持 Red Hat, SUSE, Ubuntu。手上没有以上 Linux 版本,选用了与 Red Hat 最接近的 CentOS7.4 来进行安装和测试。

1. 环境

Linux: CentOS Linux release 7.4.1708 (Core)
Memory: 4 GB
SQL Server: SQL Server 2017 (RC2) – 14.0.900.75 (X64)

2. 安装 mssql-server

2.1 下载 rpm 包

[root@linuxidc /opt]# mkdir -p /opt/sqlserver2017
[root@linuxidc /opt]# cd /opt/sqlserver2017/
[root@linuxidc /opt]# wget https://packages.microsoft.com/rhel/7/mssql-server/mssql-server-14.0.900.75-1.x86_64.rpm

2.2 yum 安装

[root@linuxidc /opt/sqlserver2017]# yum localinstall mssql-server-14.0.900.75-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining mssql-server-14.0.900.75-1.x86_64.rpm: mssql-server-14.0.900.75-1.x86_64
Marking mssql-server-14.0.900.75-1.x86_64.rpm to be installed
Resolving Dependencies
–> Running transaction check
—> Package mssql-server.x86_64 0:14.0.900.75-1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                            Arch                          Version                                Repository                                                Size
===========================================================================================================================================================================
Installing:
 mssql-server                        x86_64                        14.0.900.75-1                          /mssql-server-14.0.900.75-1.x86_64                        870 M

Transaction Summary
===========================================================================================================================================================================
Install  1 Package

Total size: 870 M
Installed size: 870 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-14.0.900.75-1.x86_64                                                                                                                      1/1

+————————————————————–+
Please run ‘sudo /opt/mssql/bin/mssql-conf setup’
to complete the setup of Microsoft SQL Server
+————————————————————–+

  Verifying  : mssql-server-14.0.900.75-1.x86_64                                                                                                                      1/1

Installed:
  mssql-server.x86_64 0:14.0.900.75-1                                                                                                                                     

Complete!

2.3 配置

[root@linuxidc /opt/mssql/bin]# /opt/mssql/bin/mssql-conf setup
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=852741&clcid=0x409

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409

Do you accept the license terms? [Yes/No]:YES

Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID)
  7) I bought a license through a retail sales channel and have a product key to enter.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409

Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.

Enter your edition(1-7): 2
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server…

This is an evaluation version.  There are [40] days left in the evaluation period.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.

 
注意评估版本有使用期限。
 

2.4 验证服务

[root@linuxidc /opt/mssql/bin]# systemctl status mssql-server
● mssql-server.service – Microsoft SQL Server Database Engine
  Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
  Active: active (running) since Thu 2017-12-14 18:25:03 CST; 1min 23s ago
    Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 56504 (sqlservr)
  CGroup: /system.slice/mssql-server.service
          ├─56504 /opt/mssql/bin/sqlservr
          └─56525 /opt/mssql/bin/sqlservr

Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.36 Server      Server is listening on [::1 <ipv6> 1434].
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.37 Server      Server is listening on [127.0.0.1 <ipv4> 1434].
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.37 Server      Dedicated admin connection support was established for listening locally on port 1434.
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.38 spid19s    SQL Server is now ready for client connections. This is an informational message; … required.
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.42 spid9s      Starting up database ‘tempdb’.
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.61 spid9s      The tempdb database has 1 data file(s).
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.61 spid20s    The Service Broker endpoint is in disabled or stopped state.
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s    The Database Mirroring endpoint is in disabled or stopped state.
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s    Service Broker manager has started.
Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.63 spid6s      Recovery is complete. This is an informational message only. No user action is required.
Hint: Some lines were ellipsized, use -l to show in full.

2.5 停止、启动或重启 SQL Server 服务
systemctl stop mssql-server
systemctl start mssql-server
systemctl restart mssql-server

2.6 日志文件
/var/opt/mssql/log/errorlog

3. 安装 sqlcmd 和 bcp SQL Server 命令行工具

3.1 下载

wget https://packages.microsoft.com/rhel/7.3/prod/msodbcsql-13.1.6.0-1.x86_64.rpm
wget https://packages.microsoft.com/rhel/7.3/prod/mssql-tools-14.0.5.0-1.x86_64.rpm

3.2 安装

yum localinstall msodbcsql-13.1.6.0-1.x86_64.rpm
yum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm

3.3 添加到环境变量

[root@linuxidc /opt]# echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile
[root@linuxidc /opt]# source ~/.bash_profile
[root@linuxidc /opt]# echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
[root@linuxidc /opt]# source ~/.bashrc

3.4 本地连接

[root@linuxidc /opt/mssql/bin]# sqlcmd -S localhost -U sa
Password:
1> select name from sys.databases;
2> go
name                                                                                                                           
——————————————————————————————————————————–
master                                                                                                                         
tempdb                                                                                                                         
model                                                                                                                           
msdb                                                                                                                                                                                                                                           

(5 rows affected)
1>
1>create database TestDB;
2>go
1>

1> use TestDB;
2> go
Changed database context to ‘TestDB’.
1> create table t1 (id int, cname nvarchar(50))
2> go
1>
1> insert into t1 (id, cname) values (1,’abc’);
2> go

(1 rows affected)
1> select * from t1;
2> go
id          cname                                             
———– ————————————————–
          1 abc                                               

(1 rows affected)
1>

3.5 退出

1> quit

4. 安装 SQL Server Agent

4.1 下载

wget https://packages.microsoft.com/rhel/7/mssql-server/mssql-server-agent-14.0.900.75-1.x86_64.rpm

4.2 安装

[root@linuxidc /opt/sqlserver2017]# yum localinstall mssql-server-agent-14.0.900.75-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining mssql-server-agent-14.0.900.75-1.x86_64.rpm: mssql-server-agent-14.0.900.75-1.x86_64
Marking mssql-server-agent-14.0.900.75-1.x86_64.rpm to be installed
Resolving Dependencies
–> Running transaction check
—> Package mssql-server-agent.x86_64 0:14.0.900.75-1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                                Arch                      Version                              Repository                                                    Size
===========================================================================================================================================================================
Installing:
 mssql-server-agent                    x86_64                    14.0.900.75-1                        /mssql-server-agent-14.0.900.75-1.x86_64                    8.9 M

Transaction Summary
===========================================================================================================================================================================
Install  1 Package

Total size: 8.9 M
Installed size: 8.9 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-agent-14.0.900.75-1.x86_64                                                                                                                1/1

+——————————————————————————–+
Please restart mssql-server to enable Microsoft SQL Server Agent.
+——————————————————————————–+

  Verifying  : mssql-server-agent-14.0.900.75-1.x86_64                                                                                                                1/1

Installed:
  mssql-server-agent.x86_64 0:14.0.900.75-1                                                                                                                               

Complete!

5. 在 Windows 上使用 SSMS 连接数据库

CentOS7.4 脱机安装 SQL Server 2017

Figure-1:SSMS 连接 Linux 下的数据库

CentOS7.4 脱机安装 SQL Server 2017

Figure-2:查询版本信息

SELECT @@VERSION;
GO
Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64)
    Jul 27 2017 08:53:49
    Copyright (C) 2017 Microsoft Corporation
    Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))
 

CentOS7.4 脱机安装 SQL Server 2017
Figure-3:查询数据

发现 Red Gate 部分功能不能使用。rpm 包安装无法指定安装目录。

6. 参考

https://www.microsoft.com/en-us/sql-server/sql-server-2017
https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-red-hat
https://packages.microsoft.com/rhel/7/mssql-server/
https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-troubleshooting-guide

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-12/149607.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计10083字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19348
评论数
4
阅读量
7799350
文章搜索
热门文章
开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南

开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南

开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南 大家好,我是星哥。之前介绍了腾讯云的 Code...
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
云服务器部署服务器面板1Panel:小白轻松构建Web服务与面板加固指南

云服务器部署服务器面板1Panel:小白轻松构建Web服务与面板加固指南

云服务器部署服务器面板 1Panel:小白轻松构建 Web 服务与面板加固指南 哈喽,我是星哥,经常有人问我不...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛 NAS 硬件 03:五盘位 +N5105+ 双网口的成品 NAS 值得入手吗 前言 大家好,我...
星哥带你玩飞牛NAS-1:安装飞牛NAS

星哥带你玩飞牛NAS-1:安装飞牛NAS

星哥带你玩飞牛 NAS-1:安装飞牛 NAS 前言 在家庭和小型工作室场景中,NAS(Network Atta...
星哥带你玩飞牛NAS-7:手把手教你免费内网穿透-Cloudflare tunnel

星哥带你玩飞牛NAS-7:手把手教你免费内网穿透-Cloudflare tunnel

星哥带你玩飞牛 NAS-7:手把手教你免费内网穿透 -Cloudflare tunnel 前言 大家好,我是星...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
星哥带你玩飞牛NAS-13:自动追番、订阅下载 + 刮削,动漫党彻底解放双手!

星哥带你玩飞牛NAS-13:自动追番、订阅下载 + 刮削,动漫党彻底解放双手!

星哥带你玩飞牛 NAS-13:自动追番、订阅下载 + 刮削,动漫党彻底解放双手! 作为动漫爱好者,你是否还在为...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手! 前言 对于个人开发者、建站新手或是想搭建测试站点的从业者...
4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

  4 盘位、4K 输出、J3455、遥控,NAS 硬件入门性价比之王 开篇 在 NAS 市场中,威...
支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare 也瘫了连监控都挂,根因藏在哪? 最近两天的互联网堪称“故障...
告别Notion焦虑!这款全平台开源加密笔记神器,让你的隐私真正“上锁”

告别Notion焦虑!这款全平台开源加密笔记神器,让你的隐私真正“上锁”

  告别 Notion 焦虑!这款全平台开源加密笔记神器,让你的隐私真正“上锁” 引言 在数字笔记工...
把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地 大家好,我是星哥,今天教大家在飞牛 NA...