介绍 (Introduction)

With an increasing number of new servers running on Linux, and even a third of Microsoft’s Azure virtual machines running Linux, they have made a choice to bring SQL Server to Linux in order to increase their market share and attract new customers.

随着越来越多的新服务器在Linux上运行,甚至Microsoft的三分之一运行Linux的Azure虚拟机,他们已经选择将SQL Server引入Linux,以增加其市场份额并吸引新客户。

Microsoft has started to make inroads outside of Windows environments with different products, such as Office 365 apps for various mobile phone operating systems, such as iOS and Android as well as their own Windows Phone OS. Microsoft has stated that they want to deliver a SQL Server on Ubuntu, Red Hat and SUSE that feels, looks and performs just like the Windows version of the SQL Server, where users should not be able to see the differences between those, at least from the front-end perspective.

Microsoft已开始使用不同的产品进入Windows环境之外,例如用于各种手机操作系统(例如iOS和Android)以及自己的Windows Phone OS的Office 365应用程序。 微软已经表示,他们希望在Ubuntu,Red Hat和SUSE上提供一种感觉,外观和性能类似于Windows版本SQL ServerSQL Server,在该版本中,用户至少看不到它们之间的区别。前端角度。

要考虑的事情 (Things to consider)

SQL Server on Linux is still very new, so inconsistent behaviour and partially supported features can be apparent when using it. Microsoft stated that the preview version of SQL Server on Ubuntu, Red Hat, SUSE and Docker engine will support the basic capabilities such as the core database engine components that support transactional processing and data warehousing. At the moment, as stated by Microsoft in their release notes for SQL Server on Linux, even in the latest Community Tech Preview 2.0 (CTP 2.0), there are still a lot of features which aren’t supported, so there is still work to be done in that field. Nevertheless, it is a huge step for Microsoft, and one that many DBAs have looked forward to.

Linux上SQL Server仍然很新,因此使用它时,行为的不一致性和部分受支持的功能可能会很明显。 微软表示,Ubuntu,Red Hat,SUSE和Docker引擎上SQL Server预览版将支持基本功能,例如支持事务处理和数据仓库的核心数据库引擎组件。 目前,正如Microsoft在Linux上SQL Server 发行说明中所指出的那样,即使在最新的Community Tech Preview 2.0 (CTP 2.0)中,仍然有很多功能不受支持,因此仍然有很多工作要做在那个领域完成。 尽管如此,对于微软而言,这是迈出的一大步,许多DBA都期待着这一步。

系统要求 (System requirements)

Microsoft hasn’t stated the full system requirements to install SQL Server on Ubuntu, Red Hat, SUSE and Docker engine, the only thing they noted is that it requires more than 3.25GB of RAM. Listed below will be the basic minimum system hardware requirements to run Ubuntu, adjusted for the RAM and HDD space requirements to run SQL Server on Ubuntu:

CPU: 700Mhz processor (Intel Celeron or better)
RAM: 4GB minimum (Ubuntu needs 512MB at minimum)
HDD: 5GB for Ubuntu and additional 3GB for SQL Server at minimum

微软尚未说明在Ubuntu,Red Hat,SUSE和Docker引擎上安装SQL Server的完整系统要求,他们唯一指出的是它需要超过3.25GB的RAM。 下面列出了运行Ubuntu的基本最低系统硬件要求,并针对在Ubuntu上运行SQL Server的RAM和HDD空间要求进行了调整:

CPU:700Mhz处理器(Intel Celeron或更高)
内存:最低4GB(Ubuntu最低需要512MB)
硬盘:Ubuntu为5GB,SQL Server至少为3GB

安装步骤 (Installation procedure)

SQL Server on Linux currently supports a couple of distributions of Linux, those being Red Hat, SUSE and Ubuntu, as well as Docker engine.

Linux上SQL Server当前支持Red Hat,SUSE和Ubuntu以及Docker引擎的Linux发行版。

For this article, we are going to install SQL Server on Ubuntu, the latest version being 17.04 at the time of writing this article.

对于本文,我们将在Ubuntu上安装SQL Server,在撰写本文时,最新版本为17.04。

  1. First, open Terminal by clicking right mouse click on desktop and selecting Open Terminal.

    首先,通过在桌面上单击鼠标右键并选择Open Terminal打开Terminal

    Alternatively, you could go to start menu in the top left, opening it and clicking on Terminal to open it.

    或者,您可以转到左上方的开始菜单,将其打开,然后单击“ 终端”以将其打开。

  2. After opening the Terminal, we are greeted with a window which looks like in the picture below.

    打开终端后,我们将看到一个如下图所示的窗口。

  3. It is here where the installation takes place. First, we need to have the public repository’s GPG keys imported by entering the following command:

    在这里进行安装。 首先,我们需要通过输入以下命令来导入公共存储库的GPG密钥 :

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –

    卷曲https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key添加–

  4. The user needs to insert the account password before completing the step.

    用户需要在完成该步骤之前插入帐户密码。

  5. After that, we need to have the Microsoft SQL Server’s Ubuntu repository registered. In this step as in previous, the user needs to enter the account password before completing the step (but only if 15 minutes from the last action have passed, as this is Ubuntu’s feature to only type the password only once in 15 minutes to make work flow easier).

    之后,我们需要注册Microsoft SQL Server的Ubuntu存储库。 在与上一步相同的步骤中,用户需要在完成该步骤之前输入帐户密码(但前提是距离上一次操作仅15分钟,因为这是Ubuntu的功能,它仅每15分钟输入一次密码即可工作流量更容易)。

    curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list

    卷曲https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list

  6. Now we can install SQL Server on Ubuntu by entering the following commands:

    现在,我们可以通过输入以下命令在Ubuntu上安装SQL Server:

    sudo apt-get update
    sudo apt-get install -y mssql-server

    sudo apt-get更新
    须藤apt-get install -y mssql-server

    With this, the package is installed. To completely install SQL Server on Ubuntu we need to run the mssql-conf setup and follow the prompts. Also, a strong password is recommended for the creation of SA account (Minimum length of 8 characters, including both uppercase and lowercase letters and base 10 digits or/and non-alphanumeric symbols). To continue the setup run the following command:

    这样就安装了软件包。 要在Ubuntu上完全安装SQL Server,我们需要运行mssql-conf安装程序并按照提示进行操作。 另外,建议使用强密码来创建SA帐户(最小长度为8个字符,包括大写和小写字母以及以10为基数的数字或非字母数字符号)。 要继续安装,请运行以下命令:

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

    sudo / opt / mssql / bin / mssql-conf设置

  7. After the install of SQL Server on Ubuntu has been completed, we can check if the service is started and running by entering the following command:

    在Ubuntu上完成SQL Server的安装后,我们可以通过输入以下命令来检查该服务是否已启动并正在运行:

    systemctl status mssql-server

    systemctl状态mssql-server

  8. After some time, a software update may be released and that can be handled with a few lines in the Terminal. First, it is needed to update the apt-get repository lists by running the command below and entering the account password.

    一段时间后,可能会发布软件更新,并且可以通过终端中的几行进行处理。 首先,需要通过运行以下命令并输入帐户密码来更新apt-get存储库列表。

    sudo apt-get update
    sudo /opt/mssql/bin/mssql-conf setup

    sudo apt-get更新
    sudo / opt / mssql / bin / mssql-conf设置

  9. After updating the repository lists, all that is needed to update the SQL Server is to run the above installation command which will update the mssql-server package:

    更新存储库列表之后,更新SQL Server所需要做的就是运行上述安装命令,该命令将更新mssql-server软件包:

    sudo apt-get install mssql-server

    sudo apt-get安装mssql-server

    Running these commands will try to download the latest package, afterwards replace the updated binaries which are located under /opt/mssql. No user-generated databases or system databases are affected with this operation.

    运行这些命令将尝试下载最新的软件包,然后替换位于/ opt / mssql下的更新的二进制文件。 此操作不影响用户生成的数据库或系统数据库。

安装SQL Server工具 (Installation of SQL Server Tools)

Optionally, users can install SQL Server Tools on Ubuntu to improve their experience. Currently, the package contains the Command line query utility (sqlcmd) and Bulk import export utility (bcp).

用户可以选择在Ubuntu上安装SQL Server工具来改善他们的体验。 当前,该软件包包含命令行查询实用程序( sqlcmd )和批量导入导出实用程序( bcp )。

The installation is also done from the Terminal:

也可以从终端安装:

  1. First, it is needed to import the public repository’s GPG keys. After running this command, it is necessary to input the account password.

    首先,需要导入公共存储库的GPG密钥。 运行此命令后,需要输入帐户密码。

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –

    卷曲https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key添加–

  2. After that it is needed to register the Microsoft Ubuntu repository:

    之后,需要注册Microsoft Ubuntu存储库:

    curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

    卷曲https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

  3. Update the sources list and run the installation command with the unixODBC developer package:

    更新源列表,并使用unixODBC开发人员软件包运行安装命令:

    sudo apt-get update
    sudo apt-get install mssql-tools unixodbc-dev

    sudo apt-get更新
    须藤apt-get install mssql-tools unixodbc-dev

  4. After running the second command, user will be prompted to allow the installation

    运行第二个命令后,将提示用户允许安装

  5. After which the user will need to Accept the license terms

    之后,用户将需要接受许可条款

  6. For the sqlcmd and bcp commands to be able to get accessed from bash shell, PATH needs to be modified in the ~/.bash_profile using the command:

    为了能够从bash shell中访问sqlcmdbcp命令,需要使用以下命令在〜/ .bash_profile中修改PATH

    echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile

    echo'export PATH =“ $ PATH:/ opt / mssql-tools / bin”'>>〜/ .bash_profile

    For non-login and interactive sessions, the PATH needs to be modified accordingly:

    对于非登录和交互式会话,需要相应地修改PATH

    echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
    source ~/.bashrc

    echo'export PATH =“ $ PATH:/ opt / mssql-tools / bin”'>>〜/ .bashrc
    来源〜/ .bashrc

  7. After completing the installation, a test database is created to check the functionality of the SQL Server on Ubuntu.

    完成安装后,将创建一个测试数据库以检查Ubuntu上SQL Server的功能。

  8. As the process completes, the latest SQL Server Management Studio installed on a Windows machine is started. Since the Ubuntu machine is in the local network, the IP address is 192.168.1.8. in this case. After connecting with SQL Server credentials (as Windows authentication doesn’t work in this case), it can be seen that the database we just created using sqlcmd tool in Linux Terminal is created and the server is reachable.

    完成该过程后,将启动Windows计算机上安装的最新SQL Server Management Studio。 由于Ubuntu计算机位于本地网络中,因此IP地址为192.168.1.8。 在这种情况下。 连接了SQL Server凭据之后(由于Windows身份验证在这种情况下不起作用),可以看到我们刚刚使用Linux Terminal中的sqlcmd工具创建的数据库已创建并且服务器可以访问。

安装SQL Server代理 (Installation of SQL Server Agent)

In addition to SQL Server Tools, SQL Server Agent can also be installed as an addition after we install SQL Server on Ubuntu to manage and run scheduled jobs.

除了SQL Server工具,在我们在Ubuntu上安装SQL Server以管理和运行计划的作业之后,还可以另外安装SQL Server代理。

  1. Update the sources list and run the installation command, after which the Terminal will prompt to restart the SQL Server for the Agent to be able to start.

    更新源列表并运行安装命令,然后终端将提示重新启动SQL Server,以使代理能够启动。

    sudo apt-get update
    sudo apt-get install mssql-server-agent
    sudo systemctl restart mssql-server

    sudo apt-get更新
    须藤apt-get install mssql-server-agent
    sudo systemctl重新启动mssql-server

    After that, connecting to the server in SSMS shows up that the SQL Server Agent is running.

    之后,连接到SSMS中的服务器将显示SQL Server代理正在运行。

故障排除 (Troubleshooting)

Problem

问题

  • Cannot connect to the SQL Server on Ubuntu from SSMS

    无法从SSMS连接到Ubuntu上SQL Server

Solutions

解决方案

  • Verify if the server is running on the Ubuntu machine by running the command:

    通过运行以下命令来验证服务器是否在Ubuntu计算机上运行:

    sudo systemctl status mssql-server

    sudo systemctl状态mssql-server

    If the server is not running, it can be started by running the command:

    如果服务器未在运行,则可以通过运行以下命令来启动它:

    sudo systemctl start mssql-server

    sudo systemctl启动mssql服务器

    After which, running the previous command again should look something like this:

    之后,再次运行前面的命令应如下所示:

  • Verify that the firewall has allowed the port 1433 which SQL Server is using by default. First we need to check the status of the ufw, which is Ubuntu’s Uncomplicated Firewall, by running the following command and entering the password for the account:

    验证防火墙是否默认允许SQL Server使用的端口1433。 首先,我们需要通过运行以下命令并输入该帐户的密码来检查ufw的状态,它是Ubuntu的Uncomplicated Firewall

    sudo ufw status

    sudo ufw状态

    • To allow a port through the ufw, run the following command:

      要允许端口通过ufw ,请运行以下命令:

      sudo ufw allow 1433

      sudo ufw允许1433

Problem

问题

  • Cannot connect to the server using SA account 无法使用SA帐户连接到服务器

Solution

  • To reset the system administrator (SA) password, run the following commands:

    要重置系统管理员(SA)密码,请运行以下命令:

    sudo systemctl stop mssql-server
    sudo /opt/mssql/bin/mssql-conf setup

    sudo systemctl停止mssql-server
    sudo / opt / mssql / bin / mssql-conf设置

    Take note that this will temporarily stop SQL Server mssql-server service.

    请注意,这将暂时停止SQL Server mssql-server服务。

翻译自: https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/

如何在Ubuntu上安装SQL Server相关推荐

  1. 在没有Docker容器的Ubuntu上安装SQL Server 2019

    Until now, we learned to install and configure SQL Server 2019 using the Docker container. In this a ...

  2. SQL Server on Ubuntu——Ubuntu上的SQL Server(全截图)

    本文从零开始一步一步介绍如何在Ubuntu上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一.   创建Ubuntu系统(Create U ...

  3. ubuntu 安装sql_在Ubuntu上进行SQL Server安装和故障排除

    ubuntu 安装sql A couple of years ago, Microsoft announced that SQL Server would be available on Open S ...

  4. 如何在Windows 10 上安装SQL Server 2000数据库?

    Win10本身是一个兼容性较好的操作系统,目前有很多人在咨询如何在Windows 10 上安装 SQL Server 2000数据库,都没有成功过.主要是卡在了安装过程中的mdac2.6 安装上,一直 ...

  5. Ubuntu上配置SQL Server Always On Availability Group

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

  6. centos7 安装sql_在Linux Distribution CentOS 7上安装SQL Server vNext CTP

    centos7 安装sql .polje { font-family:'Courier New'; } .polje { font-family:'Courier New'; } It was a p ...

  7. ubuntu ftp服务器_如何在Ubuntu上安装FTP服务器?

    ubuntu ftp服务器 In this tutorial, let's learn how to install FTP server on Ubuntu. FTP or File Transfe ...

  8. 如何在Ubuntu上安装MariaDB

    We can install MariaDB on Ubuntu from the Ubuntu repositories or the official MariaDB repositories. ...

  9. couchdb 安装_如何在Ubuntu上安装CouchDB –分步指南

    couchdb 安装 In this tutorial, we'll go over how to install CouchDB on Ubuntu. CouchDB is a NoSQL data ...

最新文章

  1. 对比Android和iPhone的优缺点
  2. VLC通信仿真中数字脉冲间隔调制(DPIM)实例
  3. 怎样快速使用富文本编辑器
  4. nginx mysql 安装_CentOS7下安装Nginx+MySQL教程
  5. Redis中的数据迁移
  6. mysql是bsd协议吗_freebsd下实现mysql的自动备份
  7. 备忘录怎么用红笔标注_备忘录丢失怎么找回来?教你轻松玩转备忘录
  8. AWR Report and session_cached_cursor
  9. python ssl模块_转 Python3 ssl模块不可用的问题
  10. Receive 163 mails
  11. 电脑里的所有播放器只能播放声音没有画面
  12. 高性能信号发生器介绍
  13. 分布式技术与实战第六课 分布式缓存设计
  14. 关于vs新建项目时只有空白项
  15. 实践出真知:大乱斗游戏
  16. 游戏思考系列03:游戏匹配机制(MMR、ELO、trueskill2、皇家战争、Glicko等,详细讲ELO,其他的简略)
  17. ejb3.0会成功吗?java成昨日黄花了?
  18. 最新网络监视工具列表
  19. 微众银行助力粤港澳大湾区首个跨境数据验证平台上线
  20. android 父控件的背景_android控件的属性

热门文章

  1. springcloud生产环境一般怎么部署_机器学习模型生产环境部署的四种系统架构总结...
  2. Vue 路由懒加载
  3. 理论篇-数理统计填坑篇
  4. LucasExlucas
  5. lc 297. Serialize and Deserialize Binary Tree
  6. 关于springmvc 只能在index.jsp页面显示图片的处理办法jsp页面无法显示图片
  7. mod_fcgid FcgidMaxRequestLen 131072 问题
  8. github 【第三章】Github综合
  9. 步步为营-87-imageAreaSelect插件使用(图片剪切)
  10. 使用7zip把jre集成到绿色运行程序内