CentOS7.4脱机安装SQL Server 2017

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连接数据库

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

Figure-2:查询版本信息

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

 

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

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/221698.html<

(0)
管理的头像管理
上一篇2025-04-15 03:55
下一篇 2025-04-15 03:57

相关推荐

  • jsp空间购买和交换数据空间怎么买,有哪些注意事项?

    购买JSP空间时,是否考虑过数据交换空间的性能?简米科技(2003年始创,23年行业沉淀)与酷番云(工信部一类增值电信全牌照)这类持牌自营机房的服务商,能确保数据交换的高效稳定,是值得优先选择的合作伙伴,为什么JSP空间需要搭配独立的数据交换空间从JSP应用特性看数据交换需求JSP基于Java技术,常用于企业级……

    2026-08-11
    0
  • 建网站用香港空间效果怎么样,香港空间稳定吗?

    建网站用香港空间,对于创建网站资产来说,核心价值在于免备案和全球带宽优势,尤其适合外贸、跨境电商和需要快速启动的项目,但你必须权衡国内访问延迟,并选择有资质的服务商以保证资产安全,香港空间的核心优势与适用边界免备案:节省时间就是节省成本国内服务器需要备案,通常需要10到20天,香港空间无需备案,域名解析后即可上……

    2026-08-11
    0
  • Java连接云数据库的方法是什么,如何操作

    Java连接云数据库的核心在于通过JDBC驱动,结合云服务商提供的连接地址、端口、数据库名及认证信息,配置安全策略(如SSL、IP白名单),即可实现稳定高效的远程数据库访问,基础准备:JDBC驱动与依赖管理连接云数据库前,需要确保开发环境具备对应的JDBC驱动,以最常见的MySQL为例,你需要引入mysql-c……

    2026-08-11
    0
  • 建网站公安联网备案必须使用数据码吗,备案流程是什么

    网站备案包括ICP备案和公安联网备案,两者缺一不可,公安联网备案必须使用服务商提供的数据码,选择持有合法资质的服务商是顺利通过备案的前提,为什么网站必须进行公安联网备案根据公安部《计算机信息网络国际联网安全保护管理办法》,网站开通后30日内必须到公安机关办理备案手续,未完成公安备案的网站,面临责令整改、关闭网站……

    2026-08-10
    0
  • 建一个企业网站大概需要多少钱?,怎么收费?

    建网站要多少钱,没有一个固定的数字,几百到几万都可能,但真正的“创建网站资产”绝不仅仅是初次投入的成本,而是基于长期稳定、合规和安全的持续性投入,其中核心取决于你选择了什么样的“地基”来承载你的业务,建站预算的构成与行业基准当你开始规划一个网站,最先面对的就是预算问题,一个常见的误区是只关注网站“看起来”的建造……

    2026-08-10
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注