天天看點

centos7系統部署SqlServer2019

微信公衆号“SRE成長記”可檢視原文

一 關于SQL Server

SQL Server資料庫是Microsoft開發設計的一個關系資料庫智能管理系統(RDBMS)。

centos7系統部署SqlServer2019

二 安裝部署

centos7系統部署SqlServer2019

2.1 安裝依賴 Python3

wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz 
tar -xvf Python-3.6.6.tar.xz 
cd Python-3.6.6 
./configure --prefix=/home/app/Python-3.6.6 
make && make install 
ln -s /home/app/Python-3.6.6/bin/python3.6 /usr/bin/python3
           

2.2 安裝mssql-server-2019

2.2.1 安裝mssql-server

wget -O /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
yum install -y mssql-server
           

2.2.2 配置安裝資訊

在指定位置輸入要安裝的版本号和管理者賬号SA的密碼:

[root@test66 server2019]# /opt/mssql/bin/mssql-conf setup
Choose an edition of SQL Server:   #仔細閱讀每個版本的說明,選擇适合自己的而版本,這裡選擇安裝 3)Express (free)
  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): 3  ##輸入上邊自己要安裝的版本對應的數字
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


Enter the SQL Server system administrator password:   #輸入管理者賬号SA的密碼,密碼長度八位以上,且密碼必須包含數字、字母和特殊字元
Confirm the SQL Server system administrator password:   #确認密碼
Configuring SQL Server...


The licensing PID was successfully processed. The new edition is [Express Edition].
ForceFlush is enabled for this instance. 
ForceFlush feature is enabled for log durability.
Setup has completed successfully. SQL Server is now starting.
           

2.2.3 檢查啟動狀态:

systemctl status mssql-server
           

檢視啟動端口

centos7系統部署SqlServer2019

三 安裝指令行工具

3.1 解除安裝伺服器上老版本unixODBC-utf16-devel (如有)

yum remove unixODBC-utf16 unixODBC-utf16-devel
           

3.2 安裝unixODBC-devel

wget -O /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
           

yum安裝,兩處互動資訊都輸入YES

[root@test66 tools]# yum install -y mssql-tools unixODBC-devel 
.......  #省略若幹行
Warning: RPMDB altered outside of yum.
  Installing : unixODBC-2.3.7-1.rh.x86_64                                                                       1/4 
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  #輸入YES
  Installing : msodbcsql17-17.9.1.1-1.x86_64                                                                    2/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-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   #輸入YES
  Installing : mssql-tools-17.9.1.1-1.x86_64                                                                    3/4 
  Installing : unixODBC-devel-2.3.7-1.rh.x86_64                                                                 4/4 
  Verifying  : unixODBC-2.3.7-1.rh.x86_64                                                                       1/4 
  Verifying  : unixODBC-devel-2.3.7-1.rh.x86_64                                                                 2/4 
  Verifying  : msodbcsql17-17.9.1.1-1.x86_64                                                                    3/4 
  Verifying  : mssql-tools-17.9.1.1-1.x86_64                                                                    4/4 

Installed:
  mssql-tools.x86_64 0:17.9.1.1-1                         unixODBC-devel.x86_64 0:2.3.7-1.rh                        

Dependency Installed:
  msodbcsql17.x86_64 0:17.9.1.1-1                            unixODBC.x86_64 0:2.3.7-1.rh
           

3.3 設定環境變量

echo "export PATH=$PATH:/opt/mssql-tools/bin" >> /etc/profile
source  /etc/profile
           

四 驗證資料庫

4.1 登入資料庫

[root@test66 tools]# sqlcmd -S localhost -U SA -p
Password: 
1>
           
centos7系統部署SqlServer2019

4.2 建立測試庫

1> CREATE DATABASE [SRE]
2> GO
           
centos7系統部署SqlServer2019

4.3 檢視所有database

1> SELECT [NAME] FROM SYS.DATABASES
2> GO
           
1> DROP DATABASE SRE
2> GO