配置存储库以便安装和升级 Linux 上的 SQL ServerConfigure repositories for installing and upgrading SQL Server on Linux

适用对象:是SQL Server(仅限 Linux)否Azure SQL 数据库 否Azure SQL 数据仓库 否并行数据仓库 APPLIES TO: yesSQL Server (Linux only) noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

本文介绍如何为 Linux 上的 SQL Server 2017 和 SQL Server 2019 的安装和升级配置正确的存储库。This article describes how to configure the correct repository for SQL Server 2017 and SQL Server 2019 installations and upgrades on Linux. 在顶部,当前所选内容为“Red Hat (RHEL)” 。At the top, your current selection is Red Hat (RHEL).

本文介绍如何为 Linux 上的 SQL Server 2017 和 SQL Server 2019 的安装和升级配置正确的存储库。This article describes how to configure the correct repository for SQL Server 2017 and SQL Server 2019 installations and upgrades on Linux. 在顶部,当前所选内容为“SUSE (SLES)” 。At the top, your current selection is SUSE (SLES).

本文介绍如何为 Linux 上的 SQL Server 2017 和 SQL Server 2019 的安装和升级配置正确的存储库。This article describes how to configure the correct repository for SQL Server 2017 and SQL Server 2019 installations and upgrades on Linux. 在顶部,当前所选内容为“Ubuntu” 。At the top, your current selection is Ubuntu.

提示

SQL Server 2019 预览版现已推出!SQL Server 2019 preview is now available! 若要试用该预览版,请按照本文说明配置新的 mssql-server-preview 存储库 。To try it, use this article to configure the new mssql-server-preview repository. 然后按照安装指南中的说明进行安装。Then install using the instructions in the installation guide.

存储库Repositories

在 Linux 上安装 SQL Server 时,须配置 Microsoft 存储库。When you install SQL Server on Linux, you must configure a Microsoft repository. 此存储库用于获取数据库引擎包、mssql-server 以及相关 SQL Server 包 。This repository is used to acquire the database engine package, mssql-server, and related SQL Server packages. 现有三个主要存储库:There are currently three main repositories:

存储库Repository “属性”Name 描述Description
预览版 (2017)Preview (2017) mssql-servermssql-server SQL Server 2017 CTP 和 RC 存储库(已停用)。SQL Server 2017 CTP and RC repository (discontinued).
预览版 (2019)Preview (2019) mssql-server-previewmssql-server-preview SQL Server 2019 预览版和 RC 存储库。SQL Server 2019 preview and RC repository.
CUCU mssql-server-2017mssql-server-2017 SQL Server 2017 累积更新 (CU) 存储库。SQL Server 2017 Cumulative Update (CU) repository.
GDRGDR mssql-server-2017-gdrmssql-server-2017-gdr SQL Server 2017 GDR 存储库仅用于关键更新。SQL Server 2017 GDR repository for critical updates only.

累积更新与 GDRCumulative Update versus GDR

务必注意,每个分发都有两种主要的存储库类型:It is important to note that there are two main types of repositories for each distribution:

  • 累积更新 (CU) :累积更新 (CU) 存储库包含基础 SQL Server 版本包,以及自该版本以来的所有 bug 修复程序或改进。Cumulative Updates (CU): The Cumulative Update (CU) repository contains packages for the base SQL Server release and any bug fixes or improvements since that release. 累积更新特定于发布的版本,例如 SQL Server 2017。Cumulative updates are specific to a release version, such as SQL Server 2017. 它们会定期发布。They are released on a regular cadence.

  • GDR:GDR 存储库包含基础 SQL Server 版本包,并且仅包含自该版本以来的关键修复程序和安全更新。GDR: The GDR repository contains packages for the base SQL Server release and only critical fixes and security updates since that release. 这些更新也会添加到下一个 CU 版本中。These updates are also added to the next CU release.

每个 CU 和 GDR 版本都包含完整的 SQL Server 包以及该存储库此前的所有更新。Each CU and GDR release contains the full SQL Server package and all previous updates for that repository. 通过更改为 SQL Server 配置的存储库,可支持从 GDR 版本更新到 CU 版本。Updating from a GDR release to a CU release is supported by changing your configured repository for SQL Server. 也可以降级到主要版本中的任何版本(例如:2017)。You can also downgrade to any release within your major version (ex: 2017).

备注

可以随时通过更改存储库从 GDR 版本更新到 CU 版本。You can update from a GDR release to CU release at any time by changing repositories. 不支持从 CU 版本更新到 GDR 版本。Updating from a CU release to a GDR release is not supported.

配置存储库Configure repositories

使用以下部分中的步骤来配置 Red Hat Enterprise Server (RHEL) 上的存储库。Use the steps in the following sections to configure repositories on Red Hat Enterprise Server (RHEL).

使用以下部分中的步骤来配置 SUSE Linux Enterprise Server (SLES) 上的存储库。Use the steps in the following sections to configure repositories on SUSE Linux Enterprise Server (SLES).

使用以下部分中的步骤来配置 Ubuntu 上的存储库。Use the steps in the following sections to configure repositories on Ubuntu.

检查先前配置的存储库Check for previously configured repositories

首先,请验证是否已注册了 SQL Server 存储库。First verify whether you have already registered a SQL Server repository.

  1. 通过以下命令查看“/etc/yum.repos.d”目录中的文件 :View the files in the /etc/yum.repos.d directory with the following command:

    sudo ls /etc/yum.repos.d
    
  2. 查找配置 SQL Server 目录的文件,例如“mssql-server.repo” 。Look for a file that configures the SQL Server directory, such as mssql-server.repo.

  3. 打印文件内容。Print out the contents of the file.

    sudo cat /etc/yum.repos.d/mssql-server.repo
    
  4. “name”属性为配置的存储库 。The name property is the configured repository. 可以使用本文存储库部分中的表确认该存储库。You can identify it with the table in the Repositories section of this article.

首先,请验证是否已注册了 SQL Server 存储库。First verify whether you have already registered a SQL Server repository.

  1. 使用“zypper info”获取之前配置的任何存储库的相关信息 。Use zypper info to get information about any previously configured repository.

    sudo zypper info mssql-server
    
  2. “Repository”属性为配置的存储库 。The Repository property is the configured repository. 可以使用本文存储库部分中的表确认该存储库。You can identify it with the table in the Repositories section of this article.

首先,请验证是否已注册了 SQL Server 存储库。First verify whether you have already registered a SQL Server repository.

  1. 查看“/etc/apt/sources.list”文件的内容 。View the contents of the /etc/apt/sources.list file.

    sudo cat /etc/apt/sources.list
    
  2. 检查 mssql-server 的包 URL。Examine the package URL for mssql-server. 可以使用本文存储库部分中的表确认该存储库。You can identify it with the table in the Repositories section of this article.

删除旧存储库Remove old repository

如有必要,通过以下命令删除旧存储库。If necessary, remove the old repository with the following command.

sudo rm -rf /etc/yum.repos.d/mssql-server.repo

此命令假定上一部分中标识的文件名为“mssql-server” 。This command assumes that the file identified in the previous section was named mssql-server.repo.

如有必要,删除旧的存储库。If necessary, remove the old repository. 基于之前配置的存储库类型,使用以下命令之一。Use one of the following commands based on the type of previously configured repository.

存储库Repository 要删除的命令Command to remove
预览版 (2017)Preview (2017) sudo zypper removerepo 'packages-microsoft-com-mssql-server'
预览版 (2019)Preview (2019) sudo zypper removerepo 'packages-microsoft-com-mssql-server-preview'
CUCU sudo zypper removerepo 'packages-microsoft-com-mssql-server-2017'
GDRGDR sudo zypper removerepo 'packages-microsoft-com-mssql-server-2017-gdr'

如有必要,删除旧的存储库。If necessary, remove the old repository. 基于之前配置的存储库类型,使用以下命令之一。Use one of the following commands based on the type of previously configured repository.

存储库Repository 要删除的命令Command to remove
预览版 (2017)Preview (2017) sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server xenial main'
预览版 (2019)Preview (2019) sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-preview xenial main'
CUCU sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017 xenial main'
GDRGDR sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017-gdr xenial main'

配置新的存储库Configure new repository

配置要用于 SQL Server 安装和升级的新存储库。Configure the new repository to use for SQL Server installations and upgrades. 使用以下命令之一配置所选存储库。Use one of the following commands to configure the repository of your choice.

存储库Repository 版本Version CommandCommand
预览版 (2019)Preview (2019) 20192019 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-preview.repo
CUCU 20172017 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
GDRGDR 20172017 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017-gdr.repo

配置要用于 SQL Server 安装和升级的新存储库。Configure the new repository to use for SQL Server installations and upgrades. 使用以下命令之一配置所选存储库。Use one of the following commands to configure the repository of your choice.

存储库Repository 版本Version CommandCommand
预览版 (2019)Preview (2019) 20192019 sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-preview.repo
CUCU 20172017 sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2017.repo
GDRGDR 20172017 sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2017-gdr.repo

配置要用于 SQL Server 安装和升级的新存储库。Configure the new repository to use for SQL Server installations and upgrades.

  1. 导入公共存储库 GPG 密钥。Import the public repository GPG keys.

    sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
    
  2. 使用以下命令之一配置所选存储库。Use one of the following commands to configure the repository of your choice.

    存储库Repository 版本Version CommandCommand
    预览版 (2019)Preview (2019) 20192019 sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
    CUCU 20172017 sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
    GDRGDR 20172017 sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017-gdr.list)"
  3. 运行“apt-get 更新” 。Run apt-get update.

    sudo apt-get update
    

后续步骤Next steps

配置了正确的存储库后,可继续通过新存储库安装升级 SQL Server 以及任何相关包。After you have configured the correct repository, you can proceed to install or update SQL Server and any related packages from the new repository.

重要

此时,如果选择使用 RHEL 快速入门,回想一下,现已配置目标存储库。At this point, if you choose to use the RHEL quickstart, remember that you have already configured the target repository. 请勿在教程学习过程中重复该步骤。Do not repeat that step in the tutorials. 尤其是在配置 GDR 存储库的情况下,因为快速入门会使用 CU 存储库。This is especially true if you configure the GDR repository, because the quickstart uses the CU repository.

重要

此时,如果选择使用 SLES 快速入门,回想一下,现已配置目标存储库。At this point, if you choose to use the SLES quickstart, remember that you have already configured the target repository. 请勿在教程学习过程中重复该步骤。Do not repeat that step in the tutorials. 尤其是在配置 GDR 存储库的情况下,因为快速入门会使用 CU 存储库。This is especially true if you configure the GDR repository, because the quickstart uses the CU repository.

重要

此时,如果选择使用 Ubuntu 快速入门,回想一下,现已配置目标存储库。At this point, if you choose to use the Ubuntu quickstart, remember that you have already configured the target repository. 请勿在教程学习过程中重复该步骤。Do not repeat that step in the tutorials. 尤其是在配置 GDR 存储库的情况下,因为快速入门会使用 CU 存储库。This is especially true if you configure the GDR repository, because the quickstart uses the CU repository.

有关如何在 Linux 上安装 SQL Server 2017 的详细信息,请参阅 Linux 上的 SQL Server 安装指南For more information on how to install SQL Server 2017 on Linux, see Installation guidance for SQL Server on Linux.