1. 程式人生 > >在Red Hat Enterprise Linux 7.3上安裝SQL Server 2017

在Red Hat Enterprise Linux 7.3上安裝SQL Server 2017

serve utf end 沒有 ring 教程 brush 修改 服務器

必要條件:

1、在此快速安裝過程中,您需要安裝SQL Server 2017或SQL Server 2019上Red Hat Enterprise Linux (RHEL) 7.3 +。然後使用sqlcmd創建第一個數據庫連接以及運行查詢。

2、必須使用RHEL 7.3或7.4且必須擁有至少2GB的內存。如果以前已安裝CTP或SQL Server 2017的RC版本,必須在執行以下步驟之前刪除舊存儲庫。

技術分享圖片

  1. 在Red Hat Enterprise Linux 7.3上安裝SQL Server 2017
    SQL Server,是Microsoft公司推出的關系型數據庫服務,是一款成功的數據庫產品,在微軟的產品中占有非常重要的位置。下圖是當前排行前三的數據庫,分別是Oracle,MySQL和SQL Server(數據來自DB-Engines 2017年10月)

    技術分享圖片

    微軟在去年3月份的時候,宣布了旗下數據庫SQL Server向Linux系統開放。如今,我們已經可以在RHEL中安裝SQL Server。今天給大家介紹如何在RHEL7.3上安裝SQL Server。在本教程中,首先安裝Red Hat Enterprise 7.3,並確保和Internet相連接

    註意:在RHEL7.3或更高版本上安裝SQL Server 2017要保證計算機至少有3.25G的內存。

  2. 第一部分:SQL Server的安裝及配置
    1.1,下載Microsoft SQL Server Red Hat軟件倉庫配置文件,此倉庫為我們提供了安裝SQL Server所必須的軟件

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

    1.2,更新軟件倉庫並安裝SQL Server

    $ yum update
    $ yum -y install mssql-server

    1.3,運行包安裝完成後,使用mssql-conf安裝並按照提示操作以設置SA密碼,並選擇你的版本(註意,設置密碼時請符合密碼安全策略,建議最少8個字符,包括大寫和小寫字母,十進制數字和/或非字母數字符號。

    $ /opt/mssql/bin/mssql-conf setup
    The license terms for this product can be found in /usr/share/doc/mssql-server or downloaded from:`
    部分省略...
    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.
    部分省略....
    Enter your edition(1-7): 3 Enter the SQL Server system administrator password: [你的SA密碼]
    Confirm the SQL Server system administrator password: [你的SA密碼]
    Configuring SQL Server...
    部分省略...
    Setup has completed successfully. SQL Server is now starting.

    1.4,配置完成後,請驗證服務是否正在運行。

    $ 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 2017-10-12 03:50:58 CST; 3min 58s ago
    Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 3238 (sqlservr)
    CGroup: /system.slice/mssql-server.service
    ├─3238 /opt/mssql/bin/sqlservr
    └─3258 /opt/mssql/bin/sqlservr

    1.5,如果你的服務器允許遠程連接數據庫,請在防火墻上設置相關策略,SQL Server默認使用1433 / tcp端口

    $ firewall-cmd --permanent --add-port = 1433 / tcp
    $ firewall-cmd --reload

    第二部分:SQL Server的其他配置此時
    數據庫已經準備就緒。如果需要安裝SQL Server命令行,例如創建數據庫,需要使用命令sqlcmd和bcp。則需要安裝相應軟件,此時請執行以下操作:

    2.1,同樣下載Microsoft Red Hat軟件庫配置文件,並更新

    $ yum update

    2.2,如果你有以前版本的mssql工具安裝,請刪除任何較舊的unixODBC程序包。如果沒有,請跳過此步驟,直接進行2.3步

    $ yum remove unixODBC-utf16 unixODBC-utf16-devel

    2.3,安裝mssql工具與unixODBC開發人員包

    $ yum install -y mssql-tools unixODBC-devel
    Loaded plugins: product-id, search-disabled-repos, subscription-manager
    部分省略...
    The license terms for this product can be downloaded from https://aka.ms/odbc131eula and found in /usr/share/doc/msodbcsql/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 : >msodbcsql-13.1.9.1-1.x86_64 3/5
    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
    部分省略...
    Complete!

    2.4,為方便起見,添加/opt/mssql-tools/bin/到你路徑環境變量。這使您可以在Bash中直接運行工具,而無需指定完整路徑。運行以下命令以修改路徑登錄會話和交互式/非 - 登錄會話:

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

    註意:這裏做了全局的環境變量,如果您不要設置全局的環境變量,可以將/etc/bashrc替換為$HOME/.bashrc,將/etc/profile替換為$HOME/.bash_profile
    第三部分:SQL服務器本地測試
    3.1,測試,使用本地方式登錄數據庫,如果登錄成功,則提示1>

    $ /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa
    Password:
    1> CREATE DATABASE test
    2> GO
    1> USE test 2> GO
    Changed database context to ‘test‘.
    1> quit
  3. 至此,安裝就結束了。

在Red Hat Enterprise Linux 7.3上安裝SQL Server 2017