澳门新萄京官方网站-www.8455.com-澳门新萄京赌场网址

数据库容器化,CentOS7脱机安装SQL

2019-09-29 作者:数据库网络   |   浏览(144)
  1. 背景

SQL Server on Linux也揭破一段时间了,官方上协理Red Hat, SUSE, Ubuntu。手上未有上述Linux版本,选取了与Red Hat最附近的CentOS7.4来举办安装和测量试验。

SQL Server on Linux也昭示一段时间了,官方上支撑Red Hat, SUSE, Ubuntu。手上未有以上Linux版本,选拔了与Red Hat最临近的CentOS7.4来开展设置和测量检验。

算是按期完成第二篇。本来打算出手讲一些试行,可是数据库部分从没讲到,部分实行会设有部分主题素材,于是就有了此篇以及继续——数据水库蓄水体积器化。本篇将从SQL Server容器化实践初始,并日益批注其余数据库的容器化实行,中间再穿插一些知识点和奉行细节。在编排的进程中,笔者直接处于一种争论的心理,是一笔带过呢?照旧尽量的将施行细节全体讲到位呢?最终,作者选用了后世,纵然要成本越来越多的生命力,不过既然初阶了这次教程,就尽只怕写到位吧。

安装SQL Server on Linux之后,在命令行下使用sqlcmd,你会发觉代码提醒,语法高亮,以至连多行复制都不帮衬,相比较之下,MySQL的吩咐行顾客端辛亏用多了。只做轻易的一声令下管理尚可,做数据库开采确定还得利用SSMS才行。不过,微软新近发表了一款针对SQL Server新命令行的交互工具——mssql-cli,详细见SQL Server Blog有介绍:

 

 

澳门新萄京官方网站 1

https://blogs.technet.microsoft.com/dataplatforminsider/2017/12/12/try-mssql-cli-a-new-interactive-command-line-tool-for-sql-server/

1. 环境

Linux: CentOS Linux release 7.4.1708 (Core)

Memory: 4 GB

SQL Server: SQL Server 2017 (RC2) - 14.0.900.75 (X64)

 

 

1. 环境

Linux: CentOS Linux release 7.4.1708 (Core)

Memory: 4 GB

SQL Server: SQL Server 2017 (RC2) - 14.0.900.75 (X64)

 

 

什么是数据库?

数据库,简单来讲可正是电子化的文件柜——存款和储蓄电子文本的场馆,客商能够对文本中的数据运转新扩张、截取、更新、删除等操作。由此,所谓“数据库”是以一定措施积存在一齐、能与八个客户分享、具备尽可能小的冗余度、与应用程序相互独立的数额集合。

时下主流的数据库分为关系型数据库和非关系型数据库。

 

2. 安装mssql-server

2. 安装mssql-server

关系型数据库和非关系型数据库相比较

澳门新萄京官方网站 2

该工具提供了以下特征:

2.1 下载rpm包

[root@134test /opt]# mkdir -p /opt/sqlserver2017
[root@134test /opt]# cd /opt/sqlserver2017/
[root@134test /opt]# wget

2.1 下载rpm包

[root@134test /opt]# mkdir -p /opt/sqlserver2017
[root@134test /opt]# cd /opt/sqlserver2017/
[root@134test /opt]# wget

主流的数据库

关系型数据库:

· Microsoft SQL Server(Microsoft)

· MySQL

· Oracle

· MariaDB(MySQL的代替品)

· PostgreSQL

· DB2

非关系型数据库:

· MongoDB

· CouchDB(面向文书档案,Apache基金会)

· Redis

· MemcacheDB

· Hypertable

· Hadoop HBase

乘胜Docker的风靡,主流的数据库厂家均提供了有关的Docker镜像,因而大家能够足够有助于的将数据库托管到容器之中,用以测验和开采条件

瞩目,现阶段大家不引入在容器中托管正式意况的数据库,前段时间数据水库蓄水容量器化还存在部分主题材料、不适应性以及质疑,而且还缺少成熟的案例和方案(已经有许多商家在做那块的研究了,包涵Ali、京东)。

数据水库蓄水体积器化绝不是贰个伪命题,数据库容器化是值得大家来探究的八个方向,况且应是一种必然的动向。在本篇中,大家不做过多探求。

澳门新萄京官方网站 3

接下去,作者将稳步和咱们分享什么将主流的数据库托管到容器之中。

SQL Server是由Microsoft开荒和放大的关周全据库,其在操作数据库管理种类领域处于抢先水平,近些日子早就提供SQL Server 2019预览版。在那之中,SQL Server 2017 跨出了最首要的一步,它力求通过将 SQL Server 的兵不血刃成效引进Linux、基于 Linux 的 Docker 容器和 Windows,使客商能够在 SQL Server 平台上采取开垦语言、数据类型、本地开辟或云端开垦,以及操作系统开垦。

于是,在本篇教程中,大家将选拔SQL Server 2017来开表身体力行。

澳门新萄京官方网站 4

镜像表达

官方镜像分为Windows版本和Linux版本,官方镜像表达页为:

此处大家任重(Ren Zhong)而道远介绍Linux版本的镜像。

条件要求

· Docker Engine 1.8 。

· Dockeroverlay2积累驱动程序。

· 最少2 GB的磁盘空间。

· 最少2 GB 的 RAM。假设您在Docker for Mac或Windows上运行,请保管为Docker VM分配丰富的内存。

· Linux 上的 SQL Server 的类别供给。

蒙受变量

必填项:

· ACCEPT_EULA = Y(表示接受最后客户许可公约,不然不恐怕起动)

· SA_PASSWO奥迪Q7D = <强密码> (密码必需切合复杂密码供给,包含大小写字母以及数字或特殊符号,长度无法轻巧8个字符,不然不能起动)

注意项:

· MSSQL_PID = <your_product_id | edition_name>(用于安装产品ID或版本,私下认可值:Developer)

值范围支持Developer、Express、Standard 、Enterprise、EnterpriseCore、产品密钥 ,常常意况下,大家应用Developer即可,即开拓版本,其蕴涵企业版具备的意义,丰裕我们用来开荒和测量试验。

其他:

澳门新萄京官方网站 5

  • T-SQL AMDliSense T-SQL智能感知
  • Syntax highlighting 语法高亮
  • Pretty formatting for query results, including Vertical Format 查询结果格式美化,包含垂直格式
  • Multi-line edit mode 多行编辑情势
  • Configuration file support 协理配置文件

 

 

PowerShell运行

在Windows系统之上,大家能够运用PowerShell来运营SQL Server镜像。脚本如下所示:

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=123456abcD" `

-p 1433:1433 --name mySqlServer `

-d mcr.microsoft.com/mssql/server:2017-latest

连锁参数表明如下所示:

澳门新萄京官方网站 6澳门新萄京官方网站 7

留意:密码应符合 SQL Server 暗中认可密码战术,不然容器不能设置 SQL Server,将告一段落专门的学业。 私下认可情形下,密码必得起码为 8 个字符长,且含有多个以下四种字符集的字符:大写字母、 小写字母、 十进制数字和标记。 你能够由此试行 docker logs 命令检查错误日志。

试行之后(镜像不设有会自动拉取,大家也能够利用拉取命令下拉取镜像,比方:docker pull mcr.microsoft.com/mssql/server:2017-latest),会暗许创设一个用到 SQL Server 2017 开辟人士版的器皿,端口为1433,密码为123456abcD。

澳门新萄京官方网站 8

镜像拉取完毕未来成功运营:

澳门新萄京官方网站 9

本来,大家也可以由此命令行查看:

docker ps -a

澳门新萄京官方网站 10

假若“状态”列展现“UP”,则 SQL Server 就要容器中运作,并侦听“端口”列中钦赐的端口。

澳门新萄京官方网站 11

2.2 yum安装

[root@134test /opt/sqlserver2017]# yum localinstall mssql-server-14.0.900.75-1.x86_64.rpm

Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining mssql-server-14.0.900.75-1.x86_64.rpm: mssql-server-14.0.900.75-1.x86_64
Marking mssql-server-14.0.900.75-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 0:14.0.900.75-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                             Arch                          Version                                

2.2 yum安装

[root@134test /opt/sqlserver2017]# yum localinstall mssql-server-14.0.900.75-1.x86_64.rpm

Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining mssql-server-14.0.900.75-1.x86_64.rpm: mssql-server-14.0.900.75-1.x86_64
Marking mssql-server-14.0.900.75-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 0:14.0.900.75-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                             Arch                          Version                                

Bash Shell运行

一旦是Linux系统,大家能够因而Bash Shell试行以下命令:

sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=123456abcD'

-p 1433:1433 --name mySqlServer

-d mcr.microsoft.com/mssql/server:2017-latest

澳门新萄京官方网站 12

SQL Server Management Studio 是 Microsoft免费提供为付出和管理必要的 SQL 工具套件的一局地。 SSMS 是贰个合龙的条件,若要访谈、 配置、 管理、 管理和支付 SQL Server 的具有组件。 它能够连接到其余平台上运维那多个在地方,在 Docker 容器八月云中的 SQL Server。 它还总是到 Azure SQL 数据库和 Azure SQL 数据仓库。 SSMS 将一大波图片工具与增加的剧本编辑器相结合,各类本领水平的开辟人士和大班都能采访SQL Server。

SSMS 提供适用于 SQL Server 的汪洋开支和治本成效,包蕴实行以下任务的工具:

· 配置、 监视和治本单个或七个 SQL Server 实例

· 安顿、 监视和进级数据层组件,如数据库和数据货仓

· 备份和还原数据库

· 生成和实践 T-SQL 查询和本子,并查阅结果

· 生成数据库对象的 T-SQL 脚本

· 查看和编写制定数据库中的数据

· 以可视格局设计 T-SQL 查询和数据库对象,如视图、 表和存款和储蓄的历程

下载地址:

设置到位之后,大家就足以运营SSMS来张开管制大家的数据库了。

澳门新萄京官方网站 13澳门新萄京官方网站 14

如图所示,大家输入上述内容,以及刚刚大家因而碰着变量设置的密码“123456abcD”,点击连接,能够看来如下图所示的分界面:

澳门新萄京官方网站 15

咱俩得以由此分界面来保管大家的数据库以及实行相关的询问:

澳门新萄京官方网站 16

咱俩得以在容器内部使用 SQL Server 命令行工具 sqlcmd 来连接和管理SQL Server。

  1. 选择 docker exec -it 命令在运转的器皿内部运行交互式 Bash Shell

PowerShell:

docker exec -it mySqlServer "bash"

澳门新萄京官方网站 17

bash:

sudo docker exec -it mySqlServer "bash"

  1. 选择 sqlcmd 举行本地连接。 默许情形下,sqlcmd 不在路线之中,由此必要钦命完整路线。

命令:

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '123456abcD'

澳门新萄京官方网站 18

马到功成的话,就能够展现 sqlcmd 命令提醒符 1> 。

  1. 执行SQL脚本。

比方,我们创制一个MyDb数据库,能够实行以下脚本:

CREATE DATABASE MyDB

SELECT Name from sys.Databases

GO

先是表现创库脚本,第二行试行查询,查询服务器上具备数据库的名称,第三作为实行。

只顾:唯有输入GO才会霎时奉行此前的命令。

澳门新萄京官方网站 19

举行理并了结果如上海体育地方所示。大家通过SSMS能够查阅到我们刚刚创设的数据库:

澳门新萄京官方网站 20

除去上述办法,大家也能够在容器外使用sqlcmd连接数据库:

sqlcmd -S localhost,1433 -U SA -P "123456abcD"

澳门新萄京官方网站 21

注意:退出SQLCMD命令为:QUIT。

而外上述的连年管理工科具,大家还是能够运用以下工具举行接二连三:

· Visual Studio Code

澳门新萄京官方网站 22

· Azure Data Studio(跨平台数据库工具,适用于在Windows,MacOS和Linux上运用Microsoft体系内部布署和云数据平台的多寡正式人士)

澳门新萄京官方网站 23

· mssql-cli(SQL Server的新的交互式命令行查询工具,援助跨平台,开源,提供智能提示和语法高亮等)

澳门新萄京官方网站 24

Figure-1:智能提示

Repository                                                 Size

Installing:
 mssql-server                        x86_64                        14.0.900.75-1                           /mssql-server-14.0.900.75-1.x86_64                        870 M

Repository                                                 Size

Installing:
 mssql-server                        x86_64                        14.0.900.75-1                           /mssql-server-14.0.900.75-1.x86_64                        870 M

 

Transaction Summary

Install  1 Package

Total size: 870 M
Installed size: 870 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-14.0.900.75-1.x86_64                                                                                                                       1/1

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

  Verifying  : mssql-server-14.0.900.75-1.x86_64                                                                                                                       1/1

Installed:
  mssql-server.x86_64 0:14.0.900.75-1                                                                                                                                      

Complete!

 

Transaction Summary

Install  1 Package

Total size: 870 M
Installed size: 870 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-14.0.900.75-1.x86_64                                                                                                                       1/1

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

  Verifying  : mssql-server-14.0.900.75-1.x86_64                                                                                                                       1/1

Installed:
  mssql-server.x86_64 0:14.0.900.75-1                                                                                                                                      

Complete!

 

澳门新萄京官方网站 25

2.3 配置

[root@134test /opt/mssql/bin]# /opt/mssql/bin/mssql-conf setup
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:

The privacy statement can be viewed at:

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.

Details about editions can be found at

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-7): 2
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

This is an evaluation version.  There are [40] days left in the evaluation period.
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.

 

留心评估版本有应用定时。

 

2.3 配置

[root@134test /opt/mssql/bin]# /opt/mssql/bin/mssql-conf setup
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:

The privacy statement can be viewed at:

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.

Details about editions can be found at

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-7): 2
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

This is an evaluation version.  There are [40] days left in the evaluation period.
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.

 

只顾评估版本有选用年限。

 

Figure-2:格式化呈现

2.4 验证服务

[root@134test /opt/mssql/bin]# 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-12-14 18:25:03 CST; 1min 23s ago
     Docs:
 Main PID: 56504 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─56504 /opt/mssql/bin/sqlservr
           └─56525 /opt/mssql/bin/sqlservr

Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.36 Server      Server is listening on [ ::1 <ipv6> 1434].
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.37 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.37 Server      Dedicated admin connection support was established for listening locally on port 1434.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.38 spid19s     SQL Server is now ready for client connections. This is an informational message; ... required.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.42 spid9s      Starting up database 'tempdb'.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.61 spid9s      The tempdb database has 1 data file(s).
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.61 spid20s     The Service Broker endpoint is in disabled or stopped state.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s     The Database Mirroring endpoint is in disabled or stopped state.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s     Service Broker manager has started.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.63 spid6s      Recovery is complete. This is an informational message only. No user action is required.
Hint: Some lines were ellipsized, use -l to show in full.

2.5 甘休、运转或重启 SQL Server 服务
systemctl stop mssql-server
systemctl start mssql-server
systemctl restart mssql-server

2.6 日志文件
/var/opt/mssql/log/errorlog

2.4 验证服务

[root@134test /opt/mssql/bin]# 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-12-14 18:25:03 CST; 1min 23s ago
     Docs:
 Main PID: 56504 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─56504 /opt/mssql/bin/sqlservr
           └─56525 /opt/mssql/bin/sqlservr

Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.36 Server      Server is listening on [ ::1 <ipv6> 1434].
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.37 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.37 Server      Dedicated admin connection support was established for listening locally on port 1434.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.38 spid19s     SQL Server is now ready for client connections. This is an informational message; ... required.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.42 spid9s      Starting up database 'tempdb'.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.61 spid9s      The tempdb database has 1 data file(s).
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.61 spid20s     The Service Broker endpoint is in disabled or stopped state.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s     The Database Mirroring endpoint is in disabled or stopped state.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.62 spid20s     Service Broker manager has started.
Dec 14 18:25:10 134test sqlservr[56504]: 2017-12-14 18:25:10.63 spid6s      Recovery is complete. This is an informational message only. No user action is required.
Hint: Some lines were ellipsized, use -l to show in full.

2.5 甘休、运行或重启 SQL Server 服务
systemctl stop mssql-server
systemctl start mssql-server
systemctl restart mssql-server

2.6 日志文件
/var/opt/mssql/log/errorlog

 

3. 安装 sqlcmd 和 bcp SQL Server 命令行工具

3. 安装 sqlcmd 和 bcp SQL Server 命令行工具

 

3.1 下载

wget
wget

3.1 下载

wget
wget

  1. 安装

3.2 安装

yum localinstall msodbcsql-13.1.6.0-1.x86_64.rpm
yum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm

3.2 安装

yum localinstall msodbcsql-13.1.6.0-1.x86_64.rpm
yum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm

上边就来试用下那款工具吧。这里仅以CentOS7下亲自过问,其余平台可参考SQL Server Blog,大概在Github上有更详细的安装引导:https://github.com/dbcli/mssql-cli/blob/master/doc/installation_guide.md

3.3 加多到遇到变量

[root@134test /opt]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
[root@134test /opt]# source ~/.bash_profile
[root@134test /opt]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
[root@134test /opt]# source ~/.bashrc

3.3 增添到情形变量

[root@134test /opt]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
[root@134test /opt]# source ~/.bash_profile
[root@134test /opt]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
[root@134test /opt]# source ~/.bashrc

 

3.4 本地连接

[root@134test /opt/mssql/bin]# sqlcmd -S localhost -U sa
Password:
1> select name from sys.databases;
2> go
name                                                                                                                          

3.4 本地连接

[root@134test /opt/mssql/bin]# sqlcmd -S localhost -U sa
Password:
1> select name from sys.databases;
2> go
name                                                                                                                          

 

 

数据库容器化,CentOS7脱机安装SQL。master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb                                                                                                                                                                                                                                           

(5 rows affected)
1>
1>create database TestDB;
2>go
1>

1> use TestDB;
2> go
Changed database context to 'TestDB'.
1> create table t1 (id int, cname nvarchar(50))
2> go
1>
1> insert into t1 (id, cname) values (1,'abc');
2> go

(1 rows affected)
1> select * from t1;
2> go
id          cname                                             


          1 abc                                               

(1 rows affected)
1>

 

master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb                                                                                                                                                                                                                                           

(5 rows affected)
1>
1>create database TestDB;
2>go
1>

1> use TestDB;
2> go
Changed database context to 'TestDB'.
1> create table t1 (id int, cname nvarchar(50))
2> go
1>
1> insert into t1 (id, cname) values (1,'abc');
2> go

(1 rows affected)
1> select * from t1;
2> go
id          cname                                             


          1 abc                                               

(1 rows affected)
1>

2.1 安装新型的EPEL(Extra Packages for Enterprise Linux)

3.5 退出

1> quit

3.5 退出

1> quit

[root@134test ~]# yum install epel-release

4. 安装SQL Server Agent

4. 安装SQL Server Agent

 

4.1 下载

wget

4.1 下载

wget

2.2 安装相关信任

 

 

[root@134test ~]# yum install libunwind libicu python-pip

4.2 安装

[root@134test /opt/sqlserver2017]# yum localinstall mssql-server-agent-14.0.900.75-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining mssql-server-agent-14.0.900.75-1.x86_64.rpm: mssql-server-agent-14.0.900.75-1.x86_澳门新萄京官方网站,64
Marking mssql-server-agent-14.0.900.75-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mssql-server-agent.x86_64 0:14.0.900.75-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                                Arch                       Version                             

4.2 安装

[root@134test /opt/sqlserver2017]# yum localinstall mssql-server-agent-14.0.900.75-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining mssql-server-agent-14.0.900.75-1.x86_64.rpm: mssql-server-agent-14.0.900.75-1.x86_64
Marking mssql-server-agent-14.0.900.75-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mssql-server-agent.x86_64 0:14.0.900.75-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                                Arch                       Version                             

 

Repository                                                    Size

Installing:
 mssql-server-agent                     x86_64                     14.0.900.75-1                        /mssql-server-agent-14.0.900.75-1.x86_64                     8.9 M

Repository                                                    Size

Installing:
 mssql-server-agent                     x86_64                     14.0.900.75-1                        /mssql-server-agent-14.0.900.75-1.x86_64                     8.9 M

2.3 安装mssql-cli

Transaction Summary

Install  1 Package

Total size: 8.9 M
Installed size: 8.9 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-agent-14.0.900.75-1.x86_64                                                                                                                 1/1

--------------------------------------------------------------------------------
Please restart mssql-server to enable Microsoft SQL Server Agent.
--------------------------------------------------------------------------------

  Verifying  : mssql-server-agent-14.0.900.75-1.x86_64                                                                                                                 1/1

Installed:
  mssql-server-agent.x86_64 0:14.0.900.75-1                                                                                                                                

Complete!

Transaction Summary

Install  1 Package

Total size: 8.9 M
Installed size: 8.9 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-agent-14.0.900.75-1.x86_64                                                                                                                 1/1

--------------------------------------------------------------------------------
Please restart mssql-server to enable Microsoft SQL Server Agent.
--------------------------------------------------------------------------------

  Verifying  : mssql-server-agent-14.0.900.75-1.x86_64                                                                                                                 1/1

Installed:
  mssql-server-agent.x86_64 0:14.0.900.75-1                                                                                                                                

Complete!

[root@134test ~]# pip install mssql-cli

5. 在Windows上应用SSMS连接数据库

澳门新萄京官方网站 26

Figure-1:SSMS连接Linux下的数据库

 

澳门新萄京官方网站 27

Figure-2:查询版本新闻

 

SELECT @@VERSION;
GO
Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64)
    Jul 27 2017 08:53:49
    Copyright (C) 2017 Microsoft Corporation
    Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))

澳门新萄京官方网站 28
Figure-3:查询数据

意识Red Gate部分机能否选取。rpm包安装不能指虞升卿装目录。

 

5. 在Windows上采用SSMS连接数据库

澳门新萄京官方网站 29

Figure-1:SSMS连接Linux下的数据库

 

澳门新萄京官方网站 30

Figure-2:查询版本消息

 

SELECT @@VERSION;
GO
Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64)
    Jul 27 2017 08:53:49
    Copyright (C) 2017 Microsoft Corporation
    Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))

澳门新萄京官方网站 31
Figure-3:查询数据

意识Red Gate部分机能还是不能够应用。rpm包安装不可能指定安装目录。

 

 

6. 参考




 

 

 

 

6. 参考




 

 

 

 

2.4 使用mssql-cli登录

[root@134test ~]# mssql-cli -U sa

Password:

Version: 0.8.0

Mail: sqlcli@microsoft.com

Home:

master>SELECT @@version

--------------------

| (No column name) |

|--------------------|

| Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64)

Jul 27 2017 08:53:49

Copyright (C) 2017 Microsoft Corporation

Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core)) |

--------------------

(1 row affected)

Time: 0.103s

master>

 

 

 

  1. 体验

在Xshell使用mssql-cli,有以下几茶食得,接待补充。

  • 语法高亮,智能提示,查询结果格式美化都有了。
  • 一旦横向显示的字段过长,会活动把表的字段以纵向的格式展现,并援助逐行上下翻。
  • 直白回车就能够施行语句,无须以GO甘休。

 

唯独也意识几个难点:

  • 一贯粘贴多行语句依旧会出错。(难道本身复制的姿态不对?)
  • 查询重临的多寡非常多,重回结果极慢;查询非常的大的数据,相当慢。纵然气息奄奄按下四遍ctrl c,会如下错误。
  • 字段的原委过长不可能出示完整。

澳门新萄京官方网站 32

Figure-3:查询进程中五遍ctrl c后报错

 

澳门新萄京官方网站 33

Figure-3:字段的剧情突显不完全

 

 

  1. 总结

在命令行境况下有所增进的效应照旧非常好的,相符于尚未图形化分界面包车型大巴场合下利用。假设用于开荒、管理或询问等,有标准的意况下,仍然建议在Windows平台下采用SSMS吧。

 

别的再补充一下:http://www.codeplex.com/曾经不再更新,要下载SQL Server的身体力行数据库直接到Github(https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks)下载更有利。

 

 

本文由澳门新萄京官方网站发布于数据库网络,转载请注明出处:数据库容器化,CentOS7脱机安装SQL

关键词: