Centos7安裝SQL Server 2019

一、硬體最低配置

系統版本:Centos7 ,記憶體4G(SQL Server記憶體要求至少2G),硬碟40G,2核CPU

SQL Server版本:SQL Server 2019,
網頁下載地址:

https://packages.microsoft.com/rhel/7/mssql-server-2019/mssql-server-15.0.4003.23-3.x86_64.rpm

wget https://packages.microsoft.com/rhel/7/mssql-server-2019/mssql-server-15.0.4003.23-3.x86_64.rpm

二、關閉防火牆和selinux

1.關閉firewall:Centos 7關閉方法

systemctl stop firewalld.service       #停止firewall

systemctl disable firewalld.service    #禁止firewall開機啟動

2.關閉SELINUX:

vi /etc/selinux/config

#SELINUX=enforcing     #註解掉

#SELINUXTYPE=targeted  #註解掉

SELINUX=disabled       #增加

:wq!  #更改完成後按wq!(存檔後離開)

三.添加軟體源並安裝依賴包

[root@localhost ~]# curl https://packages.microsoft.com/config/rhel/7/prod.repo -o /etc/yum.repos.d/msprod.repo

[root@localhost ~]# yum -y install mssql-tools unixODBC-devel bzip2 gdb libsss_nss_idmap cyrus-sasl cyrus-sasl-gssapi

root@localhost ~]# curl https://packages.microsoft.com/config/rhel/7/prod.repo -o /etc/yum.repos.d/msprod.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0     33      0  0:00:05  0:00:05 --:--:--    45
[root@localhost ~]# yum -y install mssql-tools unixODBC-devel bzip2 gdb libsss_nss_idmap cyrus-sasl cyrus-sasl-gssapi
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.cs.nctu.edu.tw
 * extras: centos.cs.nctu.edu.tw
 * updates: centos.cs.nctu.edu.tw
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
packages-microsoft-com-prod                              | 3.0 kB     00:00     
updates                                                  | 2.9 kB     00:00     
packages-microsoft-com-prod/primary_db                     | 487 kB   00:00     
Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version
Package gdb-7.6.1-120.el7.x86_64 already installed and latest version
Package libsss_nss_idmap-1.16.5-10.el7_9.10.x86_64 already installed and latest version
Package cyrus-sasl-2.1.26-23.el7.x86_64 already installed and latest version
Package cyrus-sasl-gssapi-2.1.26-23.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0:17.8.1.1-1 will be installed
--> Processing Dependency: msodbcsql17 >= 17.3.0.0 for package: mssql-tools-17.8.1.1-1.x86_64
---> Package unixODBC-devel.x86_64 0:2.3.1-14.el7 will be updated
---> Package unixODBC-devel.x86_64 0:2.3.7-1.rh will be an update
--> Processing Dependency: unixODBC = 2.3.7 for package: unixODBC-devel-2.3.7-1.rh.x86_64
--> Running transaction check
---> Package msodbcsql17.x86_64 0:17.8.1.1-1 will be installed
---> Package unixODBC.x86_64 0:2.3.1-14.el7 will be updated
---> Package unixODBC.x86_64 0:2.3.7-1.rh will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch      Version       Repository                      Size
================================================================================
Installing:
 mssql-tools       x86_64    17.8.1.1-1    packages-microsoft-com-prod    287 k
Updating:
 unixODBC-devel    x86_64    2.3.7-1.rh    packages-microsoft-com-prod     42 k
Installing for dependencies:
 msodbcsql17       x86_64    17.8.1.1-1    packages-microsoft-com-prod    905 k
Updating for dependencies:
 unixODBC          x86_64    2.3.7-1.rh    packages-microsoft-com-prod    213 k

Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)
Upgrade  1 Package (+1 Dependent package)

Total download size: 1.4 M
Downloading packages:
No Presto metadata available for packages-microsoft-com-prod
warning: /var/cache/yum/x86_64/7/packages-microsoft-com-prod/packages/mssql-tools-17.8.1.1-1.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-tools-17.8.1.1-1.x86_64.rpm is not installed
(1/4): mssql-tools-17.8.1.1-1.x86_64.rpm                   | 287 kB   00:00     
(2/4): unixODBC-2.3.7-1.rh.x86_64.rpm                      | 213 kB   00:00     
(3/4): unixODBC-devel-2.3.7-1.rh.x86_64.rpm                |  42 kB   00:00     
(4/4): msodbcsql17-17.8.1.1-1.x86_64.rpm                   | 905 kB   00:05     
--------------------------------------------------------------------------------
Total                                              241 kB/s | 1.4 MB  00:05     
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
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
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : unixODBC-2.3.7-1.rh.x86_64                                   1/6 
The license terms for this product can be downloaded from
https://aka.ms/odbc17eula and found in
/usr/share/doc/msodbcsql17/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 : msodbcsql17-17.8.1.1-1.x86_64                                2/6 
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/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-tools-17.8.1.1-1.x86_64                                3/6 
  Updating   : unixODBC-devel-2.3.7-1.rh.x86_64                             4/6 
  Cleanup    : unixODBC-devel-2.3.1-14.el7.x86_64                           5/6 
  Cleanup    : unixODBC-2.3.1-14.el7.x86_64                                 6/6 
  Verifying  : unixODBC-devel-2.3.7-1.rh.x86_64                             1/6 
  Verifying  : mssql-tools-17.8.1.1-1.x86_64                                2/6 
  Verifying  : unixODBC-2.3.7-1.rh.x86_64                                   3/6 
  Verifying  : msodbcsql17-17.8.1.1-1.x86_64                                4/6 
  Verifying  : unixODBC-devel-2.3.1-14.el7.x86_64                           5/6 
  Verifying  : unixODBC-2.3.1-14.el7.x86_64                                 6/6 

Installed:
  mssql-tools.x86_64 0:17.8.1.1-1                                               

Dependency Installed:
  msodbcsql17.x86_64 0:17.8.1.1-1                                               

Updated:
  unixODBC-devel.x86_64 0:2.3.7-1.rh                                            

Dependency Updated:
  unixODBC.x86_64 0:2.3.7-1.rh                                                  

Complete!

四.安裝SQL Server2019

[root@localhost Downloads]# ls

mssql-server-15.0.4003.23-3.x86_64.rpm

[root@localhost Downloads]#  rpm -ivh mssql-server-15.0.4003.23-3.x86_64.rpm

Preparing…                          ################################# [100%]

Updating / installing…

   1:mssql-server-15.0.4003.23-3      ################################# [100%]

+————————————————————–+

Please run ‘sudo /opt/mssql/bin/mssql-conf setup’

to complete the setup of Microsoft SQL Server

+————————————————————–+

[root@localhost Downloads]# cd ~

[root@localhost ~]# /opt/mssql/bin/mssql-conf setup

usermod: no changes

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): 2 #選擇 2) Developer

The license terms for this product can be found in

/usr/share/doc/mssql-server or downloaded from:

https://go.microsoft.com/fwlink/?LinkId=2104294&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    #輸入Yes接受許可條款

Enter the SQL Server system administrator password:      #設置SA密碼

Confirm the SQL Server system administrator password:

Configuring SQL Server…

ForceFlush is enabled for this instance.

ForceFlush feature is enabled for log durability.

Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.

Setup has completed successfully. SQL Server is now starting.

[root@localhost ~]# echo ‘export PATH=$PATH:/opt/mssql-tools/bin’ > /etc/profile.d/mssql.sh

[root@localhost ~]# source !$

source /etc/profile.d/mssql.sh

五、設定環境變數

[root@localhost ~]# echo ‘export PATH=$PATH:/opt/mssql-tools/bin’ > /etc/profile.d/mssql.sh

[root@localhost ~]# source !$

六.Linux cmd指令下連線測試、版本查詢

[root@localhost ~]# sqlcmd -S localhost -U sa

Password:

1> select name,database_id from sys.databases;

2> go

# 顯示系統資料庫

# 查看SQL Server軟體版本

[root@localhost ~]# sqlcmd -S localhost -U sa

Password:

1> SELECT @@VERSION

2> go

七.使用ssms連線測試

七.防火牆對開放外服務(安裝時已經關閉防火牆,記得要打開)

[root@localhost ~]# firewall-cmd –permanent –add-service=mssql

success

[root@localhost ~]# firewall-cmd –reload

success

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料

近期留言
分類
BlogUpp!