linux系统sql server,Linux 上的 SQL Server 的安装指南

Linux 上的 SQL Server 的安装指南Installation guidance for SQL Server on Linux

06/22/2020

本文内容

适用于:Applies to: 719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server(所有支持的版本)719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server (all supported versions) - Linux适用于:Applies to: 719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server(所有支持的版本)719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server (all supported versions) - Linux

本文提供有关在 Linux 上安装、更新和卸载 SQL Server 2017 和 SQL Server 2019 的指导。This article provides guidance for installing, updating, and uninstalling SQL Server 2017 and SQL Server 2019 on Linux.

有关其他部署方案,请参阅:For other deployment scenarios, see:

提示

本指南涵盖了多种部署方案。This guide covers several deployment scenarios. 如果只是寻找逐步安装说明,请跳转到其中一个快速入门:If you are only looking for step-by-step installation instructions, jump to one of the quickstarts:

For answers to frequently asked questions, see the SQL Server on Linux FAQ.

支持的平台Supported platforms

SQL Server 在 Red Hat Enterprise Linux (RHEL)、SUSE Linux Enterprise Server (SLES) 和 Ubuntu 上受支持。SQL Server is supported on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu. 此外,它也可作为 Docker 映像提供,可在 Linux 上的 Docker 引擎或用于 Windows/Mac 的 Docker 上运行。It is also supported as a Docker image, which can run on Docker Engine on Linux or Docker for Windows/Mac.

平台Platform

支持的版本Supported version(s)

获取Get

Red Hat Enterprise LinuxRed Hat Enterprise Linux

7.3、7.4、7.5、7.6、87.3, 7.4, 7.5, 7.6, 8

SUSE Linux Enterprise ServerSUSE Linux Enterprise Server

v12 SP2v12 SP2

Docker 引擎Docker Engine

1.8+1.8+

支持的平台Supported platforms

平台Platform

文件系统File System

安装指南Installation Guide

获取Get

Red Hat Enterprise Linux 7.3-7.8 或 8.0-8.3 服务器Red Hat Enterprise Linux 7.3 - 7.8, or 8.0 - 8.3 Server

XFS 或 EXT4XFS or EXT4

SUSE Enterprise Linux Server v12 SP2 - SP5SUSE Enterprise Linux Server v12 SP2 - SP5

XFS 或 EXT4XFS or EXT4

Ubuntu 16.04 LTS、18.04 LTS、20.04 LTSUbuntu 16.04 LTS, 18.04 LTS, 20.04 LTS

XFS 或 EXT4XFS or EXT4

适用于 Windows、Mac 或 Linux 的 Docker 引擎 1.8 及更高版本Docker Engine 1.8+ on Windows, Mac, or Linux

空值N/A

提示

有关详细信息,请查看 Linux 上 SQL Server 的系统要求。For more information, review the system requirements for SQL Server on Linux. 有关 SQL Server 2017 的最新支持策略,请参阅 Microsoft SQL Server 的技术支持策略。For the latest support policy for SQL Server 2017, see the Technical support policy for Microsoft SQL Server.

Microsoft 还支持使用 OpenShift 和 Kubernetes 部署和管理 SQL Server 容器。Microsoft also supports deploying and managing SQL Server containers by using OpenShift and Kubernetes.

备注

SQL Server 在 Linux 上针对之前列出的发行版进行了测试且受支持。SQL Server is tested and supported on Linux for the previously listed distributions. 如果选择在不受支持的操作系统上安装 SQL Server,请查看 Microsoft SQL Server 的技术支持策略的“支持策略”部分,以了解支持含义。If you choose to install SQL Server on an unsupported operating system, please review the Support policy section of the Technical support policy for Microsoft SQL Server to understand the support implications.

系统要求System requirements

SQL Server 对 Linux 具有以下系统要求:SQL Server has the following system requirements for Linux:

要求Requirement

内存Memory

2 GB2 GB

文件系统File System

XFS 或 EXT4(其他文件系统均不受支持,如 BTRFS) 。XFS or EXT4 (other file systems, such as BTRFS, are unsupported)

磁盘空间Disk space

6 GB6 GB

处理器速度Processor speed

2 GHz2 GHz

处理器核心数Processor cores

2 个核心2 cores

处理器类型Processor type

仅兼容 x64x64-compatible only

如果在生产中使用网络文件系统 (NFS) 远程共享,请注意以下支持要求:If you use Network File System (NFS) remote shares in production, note the following support requirements:

使用 NFS 版本 4.2 或更高版本。Use NFS version 4.2 or higher. 较早版本的 NFS 不支持现代文件系统常用的必需功能,例如 fallocate 和稀疏文件创建。Older versions of NFS do not support required features, such as fallocate and sparse file creation, common to modern file systems.

仅在 NFS 装载上查找 /var/opt/mssql 目录。Locate only the /var/opt/mssql directories on the NFS mount. 不支持其他文件,例如 SQL Server 系统二进制文件。Other files, such as the SQL Server system binaries, are not supported.

安装远程共享时,请确保 NFS 客户端使用“nolock”选项。Ensure that NFS clients use the 'nolock' option when mounting the remote share.

配置源存储库Configure source repositories

安装或升级 SQL Server 时,从配置的 Microsoft 存储库中获取最新版本的 SQL Server。When you install or upgrade SQL Server, you get the latest version of SQL Server from your configured Microsoft repository. 快速入门使用 SQL Server 的累积更新 (CU) 存储库。The quickstarts use the Cumulative Update CU repository for SQL Server. 但是可以改为配置 GDR 存储库。But you can instead configure a GDR repository. For more information on repositories and how to configure them, see Configure repositories for SQL Server on Linux.

安装 SQL ServerInstall SQL Server

可以从命令行在 Linux 上安装 SQL Server 2017 或 SQL Server 2019。You can install SQL Server 2017 or SQL Server 2019 on Linux from the command line. 有关分步说明,请参阅以下快速入门之一:For step-by-step instructions, see one of the following quickstarts:

平台Platform

安装快速入门Installation quickstarts

Red Hat Enterprise Linux (RHEL)Red Hat Enterprise Linux (RHEL)

SUSE Linux Enterprise Server (SLES)SUSE Linux Enterprise Server (SLES)

还可以在 Azure 虚拟机中运行 Linux 上的 SQL Server。You can also run SQL Server on Linux in an Azure virtual machine.

安装后,请考虑进行其他配置更改以实现最佳性能。After installing, consider making additional configuration changes for optimal performance.

更新或升级 SQL ServerUpdate or Upgrade SQL Server

若要将“mssql-server”包更新到最新版本,请根据你的平台使用以下命令之一:To update the mssql-server package to the latest release, use one of the following commands based on your platform:

平台Platform

包更新命令Package update command(s)

RHELRHEL

sudo yum update mssql-server

SLESSLES

sudo zypper update mssql-server

UbuntuUbuntu

sudo apt-get update

sudo apt-get install mssql-server

这些命令将下载最新包,并替换 /opt/mssql/ 下的二进制文件。These commands download the newest package and replace the binaries located under /opt/mssql/. 此操作不会影响到用户生成的数据库和系统数据库。The user generated databases and system databases are not affected by this operation.

若要升级 SQL Server,请首先将配置的存储库更改为所需的 SQL Server 版本。To upgrade SQL Server, first change your configured repository to the desired version of SQL Server. 然后使用同一个 update 命令升级 SQL Server 版本。Then use the same update command to upgrade your version of SQL Server. 这仅当两个存储库之间支持升级路径时才可行。This is only possible if the upgrade path is supported between the two repositories.

回滚 SQL ServerRollback SQL Server

若要将 SQL Server 回滚或降级到以前的版本,请使用以下步骤:To rollback or downgrade SQL Server to a previous release, use the following steps:

标识要降级到的 SQL Server 包的版本号。Identify the version number for the SQL Server package you want to downgrade to. 有关包版本号的列表,请参阅发行说明。For a list of package numbers, see the Release notes.

降级到 SQL Server 的早期版本。Downgrade to a previous version of SQL Server. 在以下命令中,将 替换为步骤 1 中标识的 SQL Server 版本号。In the following commands, replace with the SQL Server version number you identified in step one.

平台Platform

包更新命令Package update command(s)

RHELRHEL

sudo yum downgrade mssql-server-.x86_64

SLESSLES

sudo zypper install --oldpackage mssql-server=

UbuntuUbuntu

sudo apt-get install mssql-server=

sudo systemctl start mssql-server

备注

只支持降级到相同主版本(如 SQL Server 2019)内的版本。It is only supported to downgrade to a release within the same major version, such as SQL Server 2019.

检查已安装的 SQL Server 版本Check installed SQL Server version

若要验证 Linux 上的 SQL Server 的当前版本和版本,请使用以下过程:To verify your current version and edition of SQL Server on Linux, use the following procedure:

If not already installed, install the SQL Server command-line tools.

使用“sqlcmd”运行显示 SQL Server 版本的 Transact-SQL 命令。Use sqlcmd to run a Transact-SQL command that displays your SQL Server version and edition.

sqlcmd -S localhost -U SA -Q 'select @@VERSION'

卸载 SQL ServerUninstall SQL Server

若要删除 Linux 上的“mssql-server”包,请根据你的平台使用以下命令之一:To remove the mssql-server package on Linux, use one of the following commands based on your platform:

平台Platform

包删除命令Package removal command(s)

RHELRHEL

sudo yum remove mssql-server

SLESSLES

sudo zypper remove mssql-server

UbuntuUbuntu

sudo apt-get remove mssql-server

删除包不会删除生成的数据库文件。Removing the package does not delete the generated database files. 如果希望删除数据库文件,请使用以下命令:If you want to delete the database files, use the following command:

sudo rm -rf /var/opt/mssql/

无人参与安装Unattended install

可以通过以下方式执行无人参与安装:You can perform an unattended installation in the following way:

按照快速入门中的初始步骤注册存储库并安装 SQL Server。Follow the initial steps in the quickstarts to register the repositories and install SQL Server.

运行 mssql-conf setup 时,设置环境变量并使用 -n(无提示)选项。When you run mssql-conf setup, set environment variables and use the -n (no prompt) option.

以下示例使用“MSSQL_PID”环境变量配置 SQL Server 的开发人员版本。The following example configures the Developer edition of SQL Server with the MSSQL_PID environment variable. 它还接受 EULA (ACCEPT_EULA) 并设置 SA 用户密码 (MSSQL_SA_PASSWORD) 。It also accepts the EULA (ACCEPT_EULA) and sets the SA user password (MSSQL_SA_PASSWORD). 该 -n 参数执行无提示安装,安装期间从环境变量中提取配置值。The -n parameter performs an unprompted installation where the configuration values are pulled from the environment variables.

sudo MSSQL_PID=Developer ACCEPT_EULA=Y MSSQL_SA_PASSWORD='' /opt/mssql/bin/mssql-conf -n setup

还可以创建执行其他操作的脚本。You can also create a script that performs other actions. 例如,可安装其他 SQL Server 包。For example, you could install other SQL Server packages.

有关更详细的示例脚本,请参阅以下示例:For a more detailed sample script, see the following examples:

脱机安装Offline install

如果 Linux 计算机无法访问快速入门中使用的联机存储库,则可以直接下载包文件。If your Linux machine does not have access to the online repositories used in the quick starts, you can download the package files directly. These packages are located in the Microsoft repository, https://packages.microsoft.com.

提示

如果通过快速入门中的步骤成功安装了包,则无需下载或者手动安装 SQL Server 包。If you successfully installed with the steps in the quick starts, you do not need to download or manually install the SQL Server package(s). 这部分仅适用于脱机情况。This section is only for the offline scenario.

下载适用于平台的数据库引擎包。Download the database engine package for your platform. 在发行说明的包详细信息部分找到包下载链接。Find package download links in the package details section of the Release Notes.

将下载的包移动到 Linux 计算机。Move the downloaded package to your Linux machine. 如果使用了不同的计算机下载包,则可以通过“scp”命令将包移至你的 Linux 计算机。If you used a different machine to download the packages, one way to move the packages to your Linux machine is with the scp command.

安装数据库引擎包。Install the database engine package. 根据你的平台使用以下命令之一。Use one of the following commands based on your platform. 将此示例中的包文件名替换为下载的确切名称。Replace the package file name in this example with the exact name you downloaded.

平台Platform

包安装命令Package install command

RHELRHEL

sudo yum localinstall mssql-server_versionnumber.x86_64.rpm

SLESSLES

sudo zypper install mssql-server_versionnumber.x86_64.rpm

UbuntuUbuntu

sudo dpkg -i mssql-server_versionnumber_amd64.deb

备注

还可使用 rpm -ivh 命令安装 RPM 包(RHEL 和 SLES),但如果可以从批准的存储库中获得,则上表中的命令会自动安装依赖项。You can also install the RPM packages (RHEL and SLES) with the rpm -ivh command, but the commands in the previous table automatically install dependencies if available from approved repositories.

解决缺少依赖项的问题:此时可能会出现缺少依赖项的情况。Resolve missing dependencies: You might have missing dependencies at this point. 如果没有,可以跳过此步骤。If not, you can skip this step. 在 Ubuntu 上,如果能够访问包含这些依赖项的已批准的存储库,最简单的解决办法是使用 apt-get -f install 命令。On Ubuntu, if you have access to approved repositories containing those dependencies, the easiest solution is to use the apt-get -f install command. 此命令还会完成 SQL Server 的安装。This command also completes the installation of SQL Server. 若要手动检查依赖项,请使用以下命令:To manually inspect dependencies, use the following commands:

平台Platform

列出依赖项命令List dependencies command

RHELRHEL

rpm -qpR mssql-server_versionnumber.x86_64.rpm

SLESSLES

rpm -qpR mssql-server_versionnumber.x86_64.rpm

UbuntuUbuntu

dpkg -I mssql-server_versionnumber_amd64.deb

解决缺少的依赖项后,尝试再次安装 mssql-server 包。After resolving the missing dependencies, attempt to install the mssql-server package again.

完成 SQL Server 安装。Complete the SQL Server setup. 使用“mssql-conf”完成 SQL Server 安装:Use mssql-conf to complete the SQL Server setup:

sudo /opt/mssql/bin/mssql-conf setup

许可和定价Licensing and pricing

对于 Linux 和 Windows,SQL Server 获得的许可都相同。SQL Server is licensed the same for Linux and Windows. 有关 SQL Server 许可和定价的详细信息,请参阅如何授予 SQL Server 许可。For more information about SQL Server licensing and pricing, see How to license SQL Server.

可选的 SQL Server 功能Optional SQL Server features

安装后,还可以安装或启用可选的 SQL Server 功能。After installation, you can also install or enable optional SQL Server features.

640f286424bd9b6eeed7899a637a9116.png

获取帮助

提示

For answers to frequently asked questions, see the SQL Server on Linux FAQ.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值