Azure虽然向用户提供SQL paas服务,但是大多数用户还是习惯在用虚拟机自己搭建SQL server,这样的好处是便于后期最大化的扩展,所以鉴于这些情况,所以觉得有必要写这篇博客。

首先,我们要建立一台虚拟机,鉴SQL server对虚拟机内存的要求最低为3GB,所以笔者建议虚拟机选择A3或者A4,当然也可以选择A1的虚拟机,然后再升为A3或者A4,因为本次环境只是测试,这里我就直接建立A3虚拟机,OS为centos7.1

第一步,建立虚拟机,过程省略,有不会的读者自行百度,结果如下

第二步,登陆虚拟机,切换到root用户

[yangyang@sqlserver1 ~]$ sudo su - root

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things: #) Respect the privacy of others.
#) Think before you type.
#) With great power comes great responsibility. [sudo] password for yangyang:
Sorry, try again.
[sudo] password for yangyang:
[root@sqlserver1 ~]#

第三步,获得yum源,yum的repo文件地址

下载到本地

[root@sqlserver1 ~]# wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo
---- ::-- https://packages.microsoft.com/config/rhel/7/mssql-server.repo
Resolving packages.microsoft.com (packages.microsoft.com)... 13.75.127.55
Connecting to packages.microsoft.com (packages.microsoft.com)|13.75.127.55|:... connected.
HTTP request sent, awaiting response... OK
Length: [application/octet-stream]
Saving to: 鈓ssql-server.repo? %[======================================>] --.-K/s in 0s -- :: (13.7 MB/s) - 鈓ssql-server.repo?saved [/] [root@sqlserver1 ~]#

接下来把文件复制到/etc/yum.repos.d目录

[root@sqlserver1 ~]# cp mssql-server.repo /etc/yum.repos.d/

更新yum信息

[root@sqlserver1 ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB :
extras | 3.4 kB :
openlogic | 1.3 kB :
packages-microsoft-com-mssql-server | 2.9 kB :
updates | 3.4 kB :
(/): base//x86_64/group_gz | kB :
(/): base//x86_64/primary_db | 5.6 MB :
(/): base//x86_64/other_db | 2.4 MB :
(/): base//x86_64/filelists_db | 6.6 MB :
(/): extras//x86_64/prestodelta | kB :
(/): extras//x86_64/filelists_db | kB :
(/): extras//x86_64/primary_db | kB :
(/): extras//x86_64/other_db | kB :
(/): openlogic//x86_64/filelists | 8.8 kB :
(/): openlogic//x86_64/primary | kB :
(/): openlogic//x86_64/other | 4.0 kB :
(/): packages-microsoft-com-mssql-server/primary_db | 3.2 kB :
(/): packages-microsoft-com-mssql-server/other_db | B :
(/): packages-microsoft-com-mssql-server/filelists_db | 1.8 kB :
(/): updates//x86_64/prestodelta | kB :
(/): updates//x86_64/filelists_db | kB :
(/): updates//x86_64/primary_db | 1.2 MB :
(/): updates//x86_64/other_db | MB :
Determining fastest mirrors
openlogic /
openlogic /
openlogic /
Metadata Cache Created

第四步,通过yum安装sql server

yum查找mssql的相关信息

[root@sqlserver1 ~]# yum search mssql
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
============================== N/S matched: mssql ==============================
mssql-server.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
mssql-server-ha.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine Name and summary matches only, use "search all" for everything.

我们可以看到有两个版本,ha应该是做高可用性的版本,所以我们选择安装第一个

[root@sqlserver1 ~]# yum install mssql-server -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 :14.0.100.187- will be installed
--> Finished Dependency Resolution Dependencies Resolved ================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mssql-server x86_64 14.0.100.187- packages-microsoft-com-mssql-server M Transaction Summary
================================================================================
Install Package Total download size: M
Installed size: M
Downloading packages:
warning: /var/cache/yum/x86_64//packages-microsoft-com-mssql-server/packages/mssql-server-14.0.100.187-.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-server-14.0.100.187-.x86_64.rpm is not installed
mssql-server-14.0.100.187-.x86_64.rpm | MB :
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
Userid : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
Fingerprint: bc52 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
Installing : mssql-server-14.0.100.187-.x86_64 / +-------------------------------------------------------------------+
| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
| Microsoft(R) SQL Server(R). |
+-------------------------------------------------------------------+ Verifying : mssql-server-14.0.100.187-.x86_64 / Installed:
mssql-server.x86_64 :14.0.100.187- Complete!

看到上面的结果表示安装完成

第五步,配置SQL server

[root@sqlserver1 ~]# cd /opt/mssql/bin
[root@sqlserver1 bin]# pwd
/opt/mssql/bin
[root@sqlserver1 bin]# ./sqlservr-setup
Microsoft(R) SQL Server(R) Setup You can abort setup at anytime by pressing Ctrl-C. Start this program
with the --help option for information about running it in unattended
mode. The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388 and found
in /usr/share/doc/mssql-server/LICENSE.TXT. Do you accept the license terms? If so, please type "YES": YES Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account: Setting system administrator (SA) account password... Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y
ln -s '/usr/lib/systemd/system/mssql-server.service' '/etc/systemd/system/multi-user.target.wants/mssql-server.service'
ln -s '/usr/lib/systemd/system/mssql-server-telemetry.service' '/etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service' Setup completed successfully.
[root@sqlserver1 bin]#

这样就配置成功了

第六步,检查状态

[root@sqlserver1 bin]# systemctl status mssql-server
mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled)
Active: active (running) since Thu -- :: UTC; 5min ago
Main PID: (sqlservr)
CGroup: /system.slice/mssql-server.service
忖1629 /opt/mssql/bin/sqlservr
忖1639 /opt/mssql/bin/sqlservr Jan :: sqlserver1 sqlservr[]: -- ::34.22 spid6s ....
Jan :: sqlserver1 sqlservr[]: -- ::34.86 spid6s ....
Jan :: sqlserver1 sqlservr[]: -- ::34.87 spid20s ....
Jan :: sqlserver1 sqlservr[]: -- ::34.87 spid20s ....
Jan :: sqlserver1 sqlservr[]: -- ::34.92 spid20s ....
Jan :: sqlserver1 sqlservr[]: -- ::35.01 spid5s ....
Jan :: sqlserver1 sqlservr[]: -- ::35.99 spid38s ...
Jan :: sqlserver1 systemd[]: [/usr/lib/systemd/system/mssql-serve...e'
Jan :: sqlserver1 systemd[]: [/usr/lib/systemd/system/mssql-serve...e'
Jan :: sqlserver1 systemd[]: [/usr/lib/systemd/system/mssql-serve...e'
Hint: Some lines were ellipsized, use -l to show in full.

可以从上图看出SQL server已经在运行,这一步说明SQL server已经完全安装成功了

但是接下来我们还要做一个工作,就是检查,我们需要使用SQL ToolTs,sqlcmd是mssql ODBC的一个工具,可以通过yum的repo直接yum安装

首先下载yum的repo

[root@sqlserver1 bin]# cd /root/
[root@sqlserver1 ~]# wget https://packages.microsoft.com/config/rhel/7/prod.repo
---- ::-- https://packages.microsoft.com/config/rhel/7/prod.repo
Resolving packages.microsoft.com (packages.microsoft.com)... 13.75.127.55
Connecting to packages.microsoft.com (packages.microsoft.com)|13.75.127.55|:... connected.
HTTP request sent, awaiting response... OK
Length: [application/octet-stream]
Saving to: 鈖rod.repo? %[======================================>] --.-K/s in 0s -- :: (31.7 MB/s) - 鈖rod.repo?saved [/] [root@sqlserver1 ~]# mv prod.repo /etc/yum.repos.d/
[root@sqlserver1 ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB :
extras | 3.4 kB :
openlogic | 1.3 kB :
packages-microsoft-com-mssql-server | 2.9 kB :
packages-microsoft-com-prod | 2.9 kB :
updates | 3.4 kB :
(/): packages-microsoft-com-prod/filelists_db | 3.2 kB :
(/): packages-microsoft-com-prod/other_db | kB :
(/): packages-microsoft-com-prod/primary_db | 6.7 kB :
Loading mirror speeds from cached hostfile
Metadata Cache Created

接下来进行安装

[root@sqlserver1 ~]#  yum install mssql-tools
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 :14.0.1.246- will be installed
--> Processing Dependency: msodbcsql for package: mssql-tools-14.0.1.246-.x86_64
--> Running transaction check
---> Package msodbcsql.x86_64 :13.1.1.0- will be installed
--> Processing Dependency: unixODBC-utf16 for package: msodbcsql-13.1.1.0-.x86_64
--> Processing Dependency: libodbcinst.so.()(64bit) for package: msodbcsql-13.1.1.0-.x86_64
--> Running transaction check
---> Package unixODBC-utf16.x86_64 :2.3.- will be installed
--> Processing Dependency: libltdl.so.()(64bit) for package: unixODBC-utf16-2.3.-.x86_64
--> Running transaction check
---> Package libtool-ltdl.x86_64 :2.4.-.el7_2 will be installed
--> Finished Dependency Resolution Dependencies Resolved ================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mssql-tools x86_64 14.0.1.246- packages-microsoft-com-prod k
Installing for dependencies:
libtool-ltdl x86_64 2.4.-.el7_2 base k
msodbcsql x86_64 13.1.1.0- packages-microsoft-com-prod 3.9 M
unixODBC-utf16 x86_64 2.3.- packages-microsoft-com-prod k Transaction Summary
================================================================================
Install Package (+ Dependent packages) Total download size: 4.5 M
Installed size: 4.5 M
Is this ok [y/d/N]: y
Downloading packages:
(/): libtool-ltdl-2.4.-.el7_2.x86_64.rpm | kB :
(/): mssql-tools-14.0.1.246-.x86_64.rpm | kB :
(/): unixODBC-utf16-2.3.-.x86_64.rpm | kB :
(/): msodbcsql-13.1.1.0-.x86_64.rpm | 3.9 MB :
--------------------------------------------------------------------------------
Total 3.0 MB/s | 4.5 MB :
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libtool-ltdl-2.4.-.el7_2.x86_64 /
Installing : unixODBC-utf16-2.3.-.x86_64 /
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746838 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
Installing : msodbcsql-13.1.1.0-.x86_64 /
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-14.0.1.246-.x86_64 /
Verifying : libtool-ltdl-2.4.-.el7_2.x86_64 /
Verifying : msodbcsql-13.1.1.0-.x86_64 /
Verifying : mssql-tools-14.0.1.246-.x86_64 /
Verifying : unixODBC-utf16-2.3.-.x86_64 / Installed:
mssql-tools.x86_64 :14.0.1.246- Dependency Installed:
libtool-ltdl.x86_64 :2.4.-.el7_2 msodbcsql.x86_64 :13.1.1.0-
unixODBC-utf16.x86_64 :2.3.- Complete!

安装成功,接下来测试连接

登陆,输入刚刚的密码,并创建数据库test

[root@sqlserver1 ~]# sqlcmd -S localhost -U SA
Password:
> create database test;
> go
> use test;
> go
Changed database context to 'test'.

查看数据库

> select name from sys.databases;
> go
name
--------------------------------------------------------------------------------------------------------------------------------
master
tempdb
model
msdb
test ( rows affected)

创建表yytable,并插入数据,最后进行查询

> create table yytable ( id int, name varchar(), gender varchar(), age int)
> go
> insert into yytable values (, 'yangyang','male',);
> go ( rows affected)
> select * from yytable;
> go
id name gender age
----------- -------------------- -------------------- -----------
yangyang male ( rows affected)
>

说明该步骤成功,且SQL server也可以使用了

在Azure虚拟机上安装SQL server的更多相关文章

  1. Azure 虚拟机上的 SQL Server 常见问题

    本主题提供有关运行 Azure 虚拟机中的 SQL Server 时出现的一些最常见问题的解答. 如果本文未解决你的 Azure 问题,请访问 MSDN 和 CSDN 上的 Azure 论坛. 你可以 ...

  2. 在Azure虚拟机上安装VNC

    我们知道,Azure提供的linux虚拟机镜像是没有桌面的,是base版的,大多情况下能满足绝大部分工作需要,甚至很多习惯使用命令行的读者,反而用不惯带桌面的linux OS,但是有些情况下,桌面还是 ...

  3. 如何在windows Server 2008虚拟机上安装SQLServer2008数据库

    一.环境准备 1.cn_windows_server_2008_r2_standard_enterprise_datacenter_web_x64_dvd_x15-50360.iso 2.NDP452 ...

  4. SQLServer-SQLServer2017:安装 SQL Server 的硬件和软件要求

    ylbtech-SQLServer-SQLServer2017:安装 SQL Server 的硬件和软件要求 1.返回顶部 1. 安装 SQL Server 的硬件和软件要求 2018/11/06 适 ...

  5. Win7 安装SQL SERVER 2012需要SP1补丁

    在操作系统Win7上安装SQL Server 2012时,报如下错误: 也就是说SQL Server 2012如要要安装在Windows 7 上,则至少需要安装SP1补丁.否则就会弹出上面提示信息.关 ...

  6. 安装 SQL Server 2012 的硬件和软件要求(官方全面)

    以下各节列出了安装和运行 SQL Server 2012 的最低硬件和软件要求. 有关 SharePoint 集成模式下 Analysis Services 的要求的详细信息,请参阅硬件和软件要求(S ...

  7. Windows Azure功能更新:SQL Server AlwaysOn和Notification Hub 正式商用

    一周以前Windows Azure发布了新的更新内容,主要的更新有3项: 虚拟机上的SQL Server支持AlwaysOn可用性组了 Notification Hub商用 自动缩放支持时间策略 这里 ...

  8. 安装SQL Server 2008R2 报错“此计算机上安装了 Microsoft Visual Studio 2008 的早期版本”解决方法

    安装SQL Server 2008 R2报错“此计算机上安装了 Microsoft Visual Studio 2008 的早期版本,请在安装 SQL Server 2008 前将 VS2008 升级 ...

  9. 在VM虚拟机上安装Microsoft Dynamics CRM 2016 步骤图解及安装注意事项

    安装Dynamics CRM 2016环境配置要求: 系统版本:Windows Server 2012 R2(必须) SQL 版本: SQLServer2014SP1-FullSlipstream-x ...

随机推荐

  1. 使用SQLiteOpenHelper的onUpgrade实现数据库版本升级

    Andoird的SQLiteOpenHelper类中有一个onUpgrade方法.帮助文档中只是说当数据库升级时该方法被触发.经过实践,解决了我一连串的疑问: 1. 帮助文档里说的"数据库升 ...

  2. pcl曲面重建模块-poisson重建算法示例

    poisson曲面重建算法 pcl-1.8测试通过 #include <iostream> #include <pcl/common/common.h> #include &l ...

  3. Openjudge 1.13-23:区间内的真素数(每日一水)

    总时间限制:  1000ms 内存限制:  65536kB 描述 找出正整数 M 和 N 之间(N 不小于 M)的所有真素数.真素数的定义:如果一个正整数 P 为素数,且其反序也为素数,那么 P 就为 ...

  4. [LeetCode] Hamming Distance 汉明距离

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  5. [个人翻译]Redis 集群教程(中)

    上一篇:http://www.cnblogs.com/li-peng/p/6143709.html 官方原文地址:https://redis.io/topics/cluster-tutorial  水 ...

  6. web兼容学习分析笔记--块级、内联、内联块级元素

    一.块级.内联.内联块级元素 (1)块级元素:block **独占一行 **可设置width,height,margin,padding **内部可包含块级或内联元素 (3)内联(行内)元素:inli ...

  7. MobaXterm.9.4|ssh连接工具

    在狂博客中,无意发现的一款集成的远程连接工具MobaXterm.9.4,官方有个人免费版,和企业版!有连接数限制,此款为破解版.感觉还挺不错的,ssh远程连接工具! 01.主界面  02.可选的远程 ...

  8. array

    1.array() //创建数组 2.array_change_key_case($arr,CASE_UPPER); //将键名全部大写,不加参数全变小写--没啥用 3.array_chunk($ar ...

  9. web前端面试总结

    本文由我收集总结了一些前端面试题,初学者阅后也要用心钻研其中的原理,重要知识需要系统学习.透彻学习,形成自己的知识链.万不可投机取巧,临时抱佛脚只求面试侥幸混过关是错误的!也是不可能的! 前端还是一个 ...

  10. 信鸽推送 10004,os文件配置出错,解决办法

    信鸽推送注册失败 返回码 10004 是 os  配置出现问题 经过询问客服,得到以下解决办法 将SDK中的so文件复制下来 新建文件夹jniLibs,并将 so 配置文件粘贴进去 便可完成注册