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. Execl数据导入sql server方法

    在日常的程序开发过程中,很多情况下,用户单位给予开发人员的数据往往是execl或者是access数据,如何把这些数据转为企业级是数据库数据呢,下面就利用sqlserver自带的功能来完成此项任务. 首 ...

  2. ImportError: No module named 'requests'

    补充说明: 当前环境是在windows环境下 python版本是:python 3.4. 刚开始学习python,一边看书一边论坛里阅读感兴趣的代码, http://www.oschina.net/c ...

  3. 安装Oracle 10g

    本文仅用于学习交流,商业用途请支持正版!转载请注明: http://www.cnblogs.com/mxbs/p/6217052.html 准备: Oracle 10g for Win(32-Bit) ...

  4. [LeetCode] Binary Tree Right Side View 二叉树的右侧视图

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...

  5. hihocoder-1014 Trie树

    hihocoder 1014 : Trie树 link: https://hihocoder.com/problemset/problem/1014 题意: 实现Trie树,实现对单词的快速统计. # ...

  6. ie11的DOM管理器报错

    IE11 Windows7下F12 DOC资源管理器不能用Exception in window.onload: Error: An error has ocurredJSPlugin.3005--- ...

  7. 【BZOJ 4580】【Usaco2016 Open】248

    http://www.lydsy.com/JudgeOnline/problem.php?id=4580 区间dp,f(i,j)表示区间[i,j]全部合成一个数,这个数是多少. 可以归纳证明[i,j] ...

  8. 在Windows平台上绿色安装postgresQL

    本文使用案例:postgresql-9.6.0-beta3-windows-x64-binaries.rar (win64免安装) 环境:window10,postgresql-9.6.0-beta3 ...

  9. spring MVC入门教程

    写一个spring mvc后台传值到前台的一个小例子. 分为以下几个步骤: 1.创建web项目. 导入项目包.具体有如下: spring-aop-4.0.4.RELEASE.jar spring-be ...

  10. git简易操作

    git config --global user.name 'scales' git config --global user.email "1477835701@qq.com" ...