CentOS7脱机安装SQL Server 2017

原文:CentOS7脱机安装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包

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

2.2 yum安装

[[email protected] /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 配置

[[email protected] /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[email protected] /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 134test sqlservr[56504]: 2017-12-14 18:25:10.36 Server      Server is listening on [ ::1 <ipv6> 1434].
Dec 14 18:25:10 134test 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 134test 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 134test 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 134test sqlservr[56504]: 2017-12-14 18:25:10.42 spid9s      Starting up database ‘tempdb‘.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.61 spid9s      The tempdb database has 1 data file(s).
Dec 14 18:25:10 134test 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 134test 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 134test sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s     Service Broker manager has started.
Dec 14 18:25:10 134test 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 添加到环境变量

[[email protected] /opt]# echo ‘export PATH="$PATH:/opt/mssql-tools/bin"‘ >> ~/.bash_profile
[[email protected] /opt]# source ~/.bash_profile
[[email protected] /opt]# echo ‘export PATH="$PATH:/opt/mssql-tools/bin"‘ >> ~/.bashrc
[[email protected] /opt]# source ~/.bashrc

3.4 本地连接

[[email protected] /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 安装

[[email protected] /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 27 2017 08: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

时间: 2024-10-07 01:39:54

CentOS7脱机安装SQL Server 2017的相关文章

CentOS7.5脱机安装SQL Server 2017(NEW)

发现搜到的都是在线下载安装的,都是只安装了mssql-server服务,没有mssql-server-agent服务.还以为linux下mssql没有agent服务呢.一番测试发现可以脱机安装,但是能找到的文章对于的rpm包在微软官网的位置改变了,所以最好每次都去上级目录看看. 1. 环境 Linux: CentOS Linux release 7.5 Memory: 4 GB SQL Server: SQL Server 2017 (RC2) - 14.0.900.75 (X64) 2. 安装

CentOS7.6安装SQL SERVER 2017

1.下载sql server 镜像配置文件到指定位置 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo 2.运行以下命令,安装 SQL Server sudo yum install -y mssql-server 3.配置SQL Server数据库 sudo /opt/mssql/bin/mssql-conf se

安装SQL Server 2017

微软的SQL Server版本除了很多也很快,从最早的版本到现在的SQL Server 2017,每一次的版本迭代都更新了很多功能以及增强稳定性,安全性等等,但从SQL Server 2016开始,只有64位版本了,并且开始支持R语言,到了SQL Server 2017,不仅支持R语言还支持Python,当然还有现在热门的机械学习等.今天我讲给大家介绍SQL Server 2017的安装. 在这里,我准备了一台Windows Server 2012 R2的系统,首先需要安装SQL 2017所需的

在Red Hat Enterprise Linux 7.3上安装SQL Server 2017

必要条件: 1.在此快速安装过程中,您需要安装SQL Server 2017或SQL Server 2019上Red Hat Enterprise Linux (RHEL) 7.3 +.然后使用sqlcmd创建第一个数据库连接以及运行查询. 2.必须使用RHEL 7.3或7.4且必须拥有至少2GB的内存.如果以前已安装CTP或SQL Server 2017的RC版本,必须在执行以下步骤之前删除旧存储库.   在Red Hat Enterprise Linux 7.3上安装SQL Server 2

CentOS中使用URLOS安装SQL Server 2017

CentOS怎么安装SQL Server 2017?在网上你能找到大量的安装教程,也许经过一些折腾,你也能成功在CentOS中安装sqlserver,但是其中可能会踩到很多莫名其妙的坑,白白浪费你的宝贵时间. 今天我们介绍一种更快速的安装方法,那就是通过URLOS一键安装SqlServer.urlos是什么? URLOS是一个云主机管理软件,基于Docker容器技术打包和运行应用,包含负载均衡和故障转移等高级功能,可自动识别机器和云应用的故障并将云应用转移至可用的机器上,单机故障并不影响业务开展

在Oracle Linux 7上通过官方Repo在线安装SQL Server 2017

挂载数据盘 #vgdispaly的Total PE 安装SQL Server服务端 1.下载SQL Server Red Hat Repository配置文件: curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo 2.安装SQL Server实例 yum install -y mssql-server 3.运行mssql-con

Linux安装SQL Server 2017

被逼无奈...我需要在Linux下安装SQL Server...学校要学SQL Server...千万不要在自己的Windows上安装这个毒瘤,即使卸载掉也会污染注册表...此时万能的VMware Workstations Pro登场了!!! (一)安装服务端 # 安装工具 yum install net-tools yum install yum-utils # 添加在线源 yum-config-manager --add https://packages.microsoft.com/rhel

Sql Server 2017 安装问题记录

记录了我在虚拟机中安装Sql server 2017遇到的一些问题. 安装环境: Sql server 2017 + Windows Server 2012 R2 提供两个网上的下载链接: https://www.microsoft.com/zh-CN/sql-server/sql-server-downloads Sql server 2017 链接: https://pan.baidu.com/s/1E_ZdvQJla5X86jLoh8d1bQ 密码: 2r4d https://blog.c

在Linux上使用mssql-conf工具配置SQL Server 2017

mssql-conf是在Linux上安装SQL Server 2017后的一个配置脚本.你可以使用这个实用工具设置以下参数: Agent 启用SQL Server代理 Collation 设置一个新的排序规则 Customer feedback 选择是否发送反馈给微软 Database Mail Profile 设置默认数据库邮件配置 Default data directory 修改新的数据文件的默认路径 Default log directory 修改新的日志文件的默认路径 Default