如何快速获得一个测试用SQL Server企业版

这里所说的测试仪SQL Server企业版,实际为Enterprise Evaluation Edition,和Enterprise Edition的区别在于,只能用180天,功能都是一样的。

本文描述了在一个OCI计算实例上安装SQL Server 2019的过程,操作系统为Oracle Linux 8,可以认为就是Redhat Linux。计算实例使用最小配置,即1 OCPU,16G内存。安装2019是我测试的需要,你也可以安装其他版本,如2022。过程都是类似的。

以下所有安装步骤均参照文档Quickstart: Install SQL Server and create a database on Red Hat

SQL Server 2019需要python2,本例的虚机中已安装python3,需要改为python2。

[opc@instance-20240731-1648-sqlserver-2019 ~]$ python --version
Python 3.6.8
[opc@instance-20240731-1648-sqlserver-2019 ~]$ sudo alternatives --config python

There are 3 programs which provide 'python'.

  Selection    Command
-----------------------------------------------
*  1           /usr/libexec/no-python
   2           /usr/bin/python2
 + 3           /usr/bin/python3

Enter to keep the current selection[+], or type selection number: 2
[opc@instance-20240731-1648-sqlserver-2019 ~]$ python --version
Python 2.7.18

下载SQL Server 2019 repository配置文件:

$ sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo

$ cat /etc/yum.repos.d/mssql-server.repo
[packages-microsoft-com-mssql-server-2019]
name=packages-microsoft-com-mssql-server-2019
baseurl=https://packages.microsoft.com/rhel/8/mssql-server-2019/
enabled=1
gpgcheck=1

安装SQL Server,时间稍长,印象中不到10分钟,比安装Oracle快(一般15分钟)。:

$ sudo yum install -y mssql-server
packages-microsoft-com-mssql-server-2019                                                                19 MB/s | 5.5 MB     00:00
Last metadata expiration check: 0:00:01 ago on Thu 01 Aug 2024 01:08:56 AM GMT.
Dependencies resolved.
=======================================================================================================================================
 Package                   Architecture      Version                         Repository                                           Size
=======================================================================================================================================
Installing:
 mssql-server              x86_64            15.0.4375.4-1                   packages-microsoft-com-mssql-server-2019            229 M
Installing dependencies:
 cyrus-sasl                x86_64            2.1.27-6.el8_5                  ol8_baseos_latest                                    96 k
 gdb                       x86_64            8.2-20.0.2.el8                  ol8_appstream                                       300 k
 gdb-headless              x86_64            8.2-20.0.2.el8                  ol8_appstream                                       3.7 M
 libatomic                 x86_64            8.5.0-22.0.1.el8_10             ol8_baseos_latest                                    35 k
Installing weak dependencies:
 gcc-gdb-plugin            x86_64            8.5.0-22.0.1.el8_10             ol8_appstream                                       130 k

Transaction Summary
=======================================================================================================================================
Install  6 Packages

Total download size: 233 M
Installed size: 1.1 G
Downloading Packages:
(1/6): libatomic-8.5.0-22.0.1.el8_10.x86_64.rpm                                                        1.2 MB/s |  35 kB     00:00
(2/6): cyrus-sasl-2.1.27-6.el8_5.x86_64.rpm                                                            2.9 MB/s |  96 kB     00:00
(3/6): gcc-gdb-plugin-8.5.0-22.0.1.el8_10.x86_64.rpm                                                   9.4 MB/s | 130 kB     00:00
(4/6): gdb-8.2-20.0.2.el8.x86_64.rpm                                                                    20 MB/s | 300 kB     00:00
(5/6): gdb-headless-8.2-20.0.2.el8.x86_64.rpm                                                           56 MB/s | 3.7 MB     00:00
(6/6): mssql-server-15.0.4375.4-1.x86_64.rpm                                                           981 kB/s | 229 MB     03:58
---------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                  1.0 MB/s | 233 MB     03:58
packages-microsoft-com-mssql-server-2019                                                                21 kB/s | 983  B     00:00
Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 Fingerprint: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
 From       : https://packages.microsoft.com/keys/microsoft.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                               1/1
  Installing       : gdb-headless-8.2-20.0.2.el8.x86_64                                                                            1/6
  Installing       : gcc-gdb-plugin-8.5.0-22.0.1.el8_10.x86_64                                                                     2/6
  Running scriptlet: gcc-gdb-plugin-8.5.0-22.0.1.el8_10.x86_64                                                                     2/6
  Installing       : gdb-8.2-20.0.2.el8.x86_64                                                                                     3/6
  Installing       : libatomic-8.5.0-22.0.1.el8_10.x86_64                                                                          4/6
  Running scriptlet: libatomic-8.5.0-22.0.1.el8_10.x86_64                                                                          4/6
  Running scriptlet: cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                              5/6
  Installing       : cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                              5/6
  Running scriptlet: cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                              5/6
  Running scriptlet: mssql-server-15.0.4375.4-1.x86_64                                                                             6/6
  Installing       : mssql-server-15.0.4375.4-1.x86_64                                                                             6/6
  Running scriptlet: mssql-server-15.0.4375.4-1.x86_64                                                                             6/6

+--------------------------------------------------------------+
Please run 'sudo /opt/mssql/bin/mssql-conf setup'
to complete the setup of Microsoft SQL Server
+--------------------------------------------------------------+


  Verifying        : mssql-server-15.0.4375.4-1.x86_64                                                                             1/6
  Verifying        : cyrus-sasl-2.1.27-6.el8_5.x86_64                                                                              2/6
  Verifying        : libatomic-8.5.0-22.0.1.el8_10.x86_64                                                                          3/6
  Verifying        : gcc-gdb-plugin-8.5.0-22.0.1.el8_10.x86_64                                                                     4/6
  Verifying        : gdb-8.2-20.0.2.el8.x86_64                                                                                     5/6
  Verifying        : gdb-headless-8.2-20.0.2.el8.x86_64                                                                            6/6

Installed:
  cyrus-sasl-2.1.27-6.el8_5.x86_64          gcc-gdb-plugin-8.5.0-22.0.1.el8_10.x86_64        gdb-8.2-20.0.2.el8.x86_64
  gdb-headless-8.2-20.0.2.el8.x86_64        libatomic-8.5.0-22.0.1.el8_10.x86_64             mssql-server-15.0.4375.4-1.x86_64

Complete!

配置SQL Server。即选择版本(本例选择了1:Evaluation )和SA口令:

$ sudo /opt/mssql/bin/mssql-conf setup
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) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
  7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
  8) 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=2109348&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-8): 1
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=2104078&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

Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

The licensing PID was successfully processed. The new edition is [Enterprise Evaluation Edition].
ForceFlush is enabled for this instance.
ForceFlush feature is enabled for log durability.
Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service → /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.

验证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 Thu 2024-08-01 01:15:51 GMT; 1min 13s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 145861 (sqlservr)
    Tasks: 141
   Memory: 705.4M
   CGroup: /system.slice/mssql-server.service
           ├─145861 /opt/mssql/bin/sqlservr
           └─145889 /opt/mssql/bin/sqlservr

Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [155B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [92B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [61B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [96B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [66B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [75B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [96B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [100B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [71B blob data]
Aug 01 01:15:54 instance-20240731-1648-sqlserver-2019 sqlservr[145889]: [124B blob data]

如果希望远程访问,可以在防火墙中开通端口:

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

安装客户端工具

下载操作系统版本对应的repository,本例为Linux 8:

curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

安装mssql-tools18包:

$ sudo yum install -y mssql-tools18 unixODBC-devel
packages-microsoft-com-prod                                                                             36 MB/s |  12 MB     00:00
Last metadata expiration check: 0:00:03 ago on Thu 01 Aug 2024 01:21:41 AM GMT.
Dependencies resolved.
=======================================================================================================================================
 Package                        Architecture           Version                       Repository                                   Size
=======================================================================================================================================
Installing:
 mssql-tools18                  x86_64                 18.4.1.1-1                    packages-microsoft-com-prod                 293 k
 unixODBC-devel                 x86_64                 2.3.11-1.rh                   packages-microsoft-com-prod                  53 k
Installing dependencies:
 msodbcsql18                    x86_64                 18.4.1.1-1                    packages-microsoft-com-prod                 923 k
 unixODBC                       x86_64                 2.3.11-1.rh                   packages-microsoft-com-prod                 274 k

Transaction Summary
=======================================================================================================================================
Install  4 Packages

Total download size: 1.5 M
Installed size: 3.8 M
Downloading Packages:
(1/4): mssql-tools18-18.4.1.1-1.x86_64.rpm                                                             3.3 MB/s | 293 kB     00:00
(2/4): unixODBC-2.3.11-1.rh.x86_64.rpm                                                                 2.9 MB/s | 274 kB     00:00
(3/4): unixODBC-devel-2.3.11-1.rh.x86_64.rpm                                                           3.3 MB/s |  53 kB     00:00
(4/4): msodbcsql18-18.4.1.1-1.x86_64.rpm                                                               7.2 MB/s | 923 kB     00:00
---------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                   12 MB/s | 1.5 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                               1/1
  Installing       : unixODBC-2.3.11-1.rh.x86_64                                                                                   1/4
  Running scriptlet: unixODBC-2.3.11-1.rh.x86_64                                                                                   1/4
  Running scriptlet: msodbcsql18-18.4.1.1-1.x86_64                                                                                 2/4
The license terms for this product can be downloaded from
https://aka.ms/odbc18eula and found in
/usr/share/doc/msodbcsql18/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
  Installing       : msodbcsql18-18.4.1.1-1.x86_64                                                                                 2/4
  Running scriptlet: msodbcsql18-18.4.1.1-1.x86_64                                                                                 2/4
odbcinst: Driver installed. Usage count increased to 1.
    Target directory is /etc

  Running scriptlet: mssql-tools18-18.4.1.1-1.x86_64                                                                               3/4
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools18/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
  Installing       : mssql-tools18-18.4.1.1-1.x86_64                                                                               3/4
  Installing       : unixODBC-devel-2.3.11-1.rh.x86_64                                                                             4/4
  Running scriptlet: msodbcsql18-18.4.1.1-1.x86_64                                                                                 4/4
  Running scriptlet: unixODBC-devel-2.3.11-1.rh.x86_64                                                                             4/4
  Verifying        : msodbcsql18-18.4.1.1-1.x86_64                                                                                 1/4
  Verifying        : mssql-tools18-18.4.1.1-1.x86_64                                                                               2/4
  Verifying        : unixODBC-2.3.11-1.rh.x86_64                                                                                   3/4
  Verifying        : unixODBC-devel-2.3.11-1.rh.x86_64                                                                             4/4

Installed:
  msodbcsql18-18.4.1.1-1.x86_64   mssql-tools18-18.4.1.1-1.x86_64   unixODBC-2.3.11-1.rh.x86_64   unixODBC-devel-2.3.11-1.rh.x86_64

Complete!

更新操作,可选,其实已经是最新:

$ sudo yum check-update
Last metadata expiration check: 0:00:50 ago on Thu 01 Aug 2024 01:21:41 AM GMT.

python36-oci-sdk.x86_64                                         2.130.0-1.el8                                          ol8_oci_included
python36-oci-sdk.x86_64                                         2.130.0-1.el8                                          ol8_addons
Security: kernel-uek-core-5.15.0-208.159.3.2.el8uek.x86_64 is an installed security update
Security: kernel-uek-core-5.15.0-207.156.6.el8uek.x86_64 is the currently running version

$ sudo yum update mssql-tools18
Last metadata expiration check: 0:01:07 ago on Thu 01 Aug 2024 01:21:41 AM GMT.
Dependencies resolved.
Nothing to do.
Complete!

记忆一点点恢复,可以看到熟悉的bcp和sqlcmd了:

$ ls /opt/mssql-tools18/bin/
bcp  sqlcmd

把路径加到启动文件中:

echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc

下面可以连数据库了,先尝试本地连接,第一次失败了:

$ sqlcmd -S localhost -U sa
Password:
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722.

原因是默认的连接模式是强制加密的,那我们先不考虑连接加密,利用-No选项,于是成功了:

$ sqlcmd -S localhost -No -U sa
Password:
1>

再确认一下版本,为Enterprise Evaluation Edition:

1> select @@version;
2> go
                                                                                                                                                                                              
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU27) (KB5037331) - 15.0.4375.4 (X64)
        Jun 10 2024 18:00:07
        Copyright (C) 2019 Microsoft Corporation
        Enterprise Evaluation Edition (64-bit) on Linux (Oracle Linux Server 8.10) <X64>

(1 rows affected)

参考

  • https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-red-hat?view=sql-server-ver15&tabs=rhel8
  • https://www.microsoft.com/en-us/evalcenter/download-sql-server-2019
  • https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver15
  • https://learn.microsoft.com/en-us/answers/questions/1078293/is-evaluation-version-of-sql-server-2019-same-as-s
  • 10
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值