4

在 Linux 上安装 SQL Server 2017

 11 months ago
source link: https://www.51cto.com/article/769381.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在 Linux 上安装 SQL Server 2017

作者:雪竹聊技术 2023-10-11 09:02:27
SQL Server for Linux版本,可以在某些Linux发行版上直接安装和运行。但是有一些具体系统要求,首先,确保你的Linux发行版满足SQL Server的要求。
f1c8e90530ff54617b85473dbae7adf06b8bdf.png

通过将平台抽象层 (PAL) 引入 SQL Server,Linux 上的 SQL Server 成为可能。PAL 将所有操作系统特定代码集中在一处,并允许其余代码保持独立于操作系统。PAL 是 Microsoft 研究项目 Drawbridge 的成果。目前,Red Hat Enterprise Server、SUSE Linux Enterprise Server 和 Ubuntu 支持 SQL Server。它还支持在 Docker 容器中运行。

SQL Server for Linux版本,可以在某些Linux发行版上直接安装和运行。但是有一些具体系统要求,首先,确保你的Linux发行版满足SQL Server的要求。例如,SQL Server 2017要求操作系统为Red Hat Enterprise Linux(RHEL)7.3或Ubuntu 16.04 LTS,而SQL Server 2019要求操作系统为RHEL 8.0、SUSE Linux Enterprise Server(SLES)15或Ubuntu 18.04 LTS。

本文将阐述在 Linux 上安装 SQL Server 2017的具体过程。

为什么应该在 Linux 上运行 SQL Server?

企业需求:Linux 上的 SQL Server 为企业关键功能(例如使用针对 Linux 操作系统的开源集群机制的 AlwaysOn 可用性组的高可用性和灾难恢复)提供了一个可靠的平台。AlwaysOn 配置还可以将节点与 Linux 和 Windows 操作系统混合。AlwaysOn 可用性组可以帮助您的应用程序满足强大的业务连续性要求。

降低运营成本:组织在 Linux 上使用 SQL Server 时可以实现运营成本的降低。SQL Server 许可证允许它根据架构的需要在 Windows、Linux 或 Docker 上使用。跨平台的许可模型,允许在多操作系统环境中提供 SQL Server 功能。SQL Server 在 Windows 和 Linux 上的许可方式相同,例如,运行在windows上的现有许可证可以转移到 Linux,无需额外费用。

性能:与运行在 Windows 操作系统相比,Linux 上的 SQL Server 性能应该相当或更好。

简单性:Linux 上的 SQL Server 允许 SQL Server DBA 和开发人员使用现有工具和脚本执行日常任务,而无需关注其中的差异。在 Windows 上运行的所有核心数据库功能在 Linux 中也可用。但是,某些依赖于 Windows 功能的 SQL Server 功能将不可用。可以在此处找到不受支持的功能的列表。

安装和维护:在Linux上命令行安装SQL Server、补丁比Windows上相对要快。这使得企业能够节省代价高昂的停机时间。较旧版本的 SQL Server(例如 SQL Server 2008 或 2008 R2)可以轻松升级到 Linux 上较新版本的 SQL Server。

非生产环境一键完成:利用 docker 容器来配置非生产数据库环境,使开发人员和 DBA 能够立即执行测试。

步骤 1:下载 Microsoft SQL Server Red Hat 存储库配置文件:

  • 以 root 用户身份运行以下命令:
curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo

第 2 步:安装 SQL Server:

yum -y install mssql-server

步骤 3:设置 SQL Server :

/opt/mssql/bin/mssql-conf setup
  • 安装程序将提示输入版本类型和 sa 密码,请在命令提示符上提供相关的信息。
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 [132] days left in the evaluation period.
Setup has completed successfully. SQL Server is now starting.

这样就完成了 Linux 上的 SQL Server 安装,您可以通过以下命令检查 SQL Server 服务和进程:

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 Wed 2017-09-13 13:40:54 BST; 6min ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 6017 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─6017 /opt/mssql/bin/sqlservr
           └─6048 /opt/mssql/bin/sqlservr
 
Sep 13 13:41:08 dbalab1 sqlservr[6017]: 2017-09-13 13:41:08.95 spid6s      8 transactions rolled forward in database 'msdb' (4:0). This is an informat... required.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.06 spid9s      Polybase feature disabled.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.06 spid9s      Clearing tempdb database.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.10 spid6s      0 transactions rolled back in database 'msdb' (4:0). This is an information... required.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.73 spid9s      Starting up database 'tempdb'.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.19 spid9s      The tempdb database has 1 data file(s).
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.20 spid22s     The Service Broker endpoint is in disabled or stopped state.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.21 spid22s     The Database Mirroring endpoint is in disabled or stopped state.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.32 spid22s     Service Broker manager has started.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.46 spid6s      Recovery is complete. This is an informational message only. No user action is required.
ps -ef | grep sqlservr | grep -v grep
 
mssql     6017     1  0 13:40 ?        00:00:01 /opt/mssql/bin/sqlservr
mssql     6048  6017  8 13:40 ?        00:00:31 /opt/mssql/bin/sqlservr
netstat -tulpn | grep 1433
tcp    0   0 0.0.0.0:1433      0.0.0.0:*        LISTEN   6048/sqlservr
tcp6    0   0 :::1433         :::*          LISTEN   6048/sqlservr

步骤 4:连接到 SQL Server 实例:

要进行连接,您首先需要安装 mssql-tools(sqlcmd 和 bcp),可以通过执行以下命令来安装:

curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
yum install -y mssql-tools unixODBC-devel

Mssq-tools 现已安装,但要使用它们,请将 mssql-tools 二进制文件添加到您的路径中:

export PATH="$PATH:/opt/mssql-tools/bin"

如果永久生效,请把mssql-tools 二进制文件加入用户的bash_profile文件或/etc/profile:

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

完成此操作后,您可以通过执行以下命令连接到 SQL Server 实例:-

sqlcmd -S localhost -U SA -P ''

第 5 步:现在要允许远程连接(通过您最喜欢的 SSMS 连接),您需要禁用防火墙,这可以通过以下方式实现:

禁用防火墙:

systemctl disable firewalld

或者允许端口 1433:

firewall-cmd --zone=public --add-port=1433/tcp --permanent``firewall-cmd --reload

第6步:安装SQL Server代理。

yum install mssql-server-agent
systemctl restart mssql-server
责任编辑:姜华 来源: 今日头条

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK