找回密码
 骑士注册

QQ登录

微博登录

搜索
❏ 站外平台:

查看: 3021|回复: 0
收起左侧

在RHEL7上安装SQL Server 2017

[复制链接]
独立奔走的靴子 发表于 2018-05-29 15:40:39 | 显示全部楼层 |阅读模式
本帖最后由 独立奔走的靴子 于 2018-05-29 16:02 编辑

  1. 在Red Hat Enterprise Linux 7.3上安装SQL Server 2017
    SQL Server,是Microsoft公司推出的关系型数据库服务,是一款成功的数据库产品,在微软的产品中占有非常重要的位置。下图是当前排行前三的数据库,分别是Oracle、MySQL和SQL Server(数据来自DB-Engines 2017年10月)

     picture1

    微软在去年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 Server本地测试
    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

 

您需要登录后才可以回帖 登录

本版积分规则

快速回复 返回顶部 返回列表

分享到微信

打开微信,点击顶部的“╋”,
使用“扫一扫”将网页分享至微信。