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. 优化IPOL网站中基于DCT(离散余弦变换)的图像去噪算法(附源代码)。

    在您阅读本文前,先需要告诉你的是:即使是本文优化过的算法,DCT去噪的计算量依旧很大,请不要向这个算法提出实时运行的苛刻要求. 言归正传,在IPOL网站中有一篇基于DCT的图像去噪文章,具体的链接地址 ...

  2. 简单深入SpringMvc

    简单深入SpringMvc 一.如何让一个普通类成为Controller? 方案一:实现接口Controller解析:handleRequest(request,response) 方案二:继承Abs ...

  3. Laravel中的ajax跨域请求

    最近接触Laravel框架ajax跨域请求的过程中遇到一些问题,在这里做下总结. 一开始发起ajax请求一直报500错误,搜索相关资料后发现Laravel要允许跨域请求可以加入Cors中间件,代码如下 ...

  4. Python资源

    25本免费的Python电子书 http://python.jobbole.com/29281/ 9本免费的Python编程书 http://python.jobbole.com/765/

  5. ActiveMQ笔记(3):基于Networks of Brokers的HA方案

    上一篇介绍了基于ZK的ActiveMQ HA方案,虽然理解起来比较容易,但是有二个不足: 1)  占用的节点数过多,1个zk集群至少3个节点,1个activemq集群也至少得3个节点,但其实正常运行时 ...

  6. [原]CentOS7部署PostGis

    转载请注明原作者(think8848)和出处(http://think8848.cnblogs.com) 本文参考了<An almost idiot's guide to install Pos ...

  7. [LeetCode] Valid Word Square 验证单词平方

    Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...

  8. C语言内存分配方法。

    当C程序运行在操作系统上时,操作系统会给每一个程序分配一定的栈空间. 堆为所有程序共有的,需要时需要申请访问. 一.栈 局部变量.函数一般在栈空间中. 运行时自动分配&自动回收:栈是自动管理的 ...

  9. Linux用户管理(centos)

    useradd testuser; 添加用户 testuser为用户名 passwd testuser; 修改用户密码 提示两次输入密码   赋予root权限 修改 /etc/sudoers 文件,找 ...

  10. Django框架

    一.首先,到底什么是框架? 想要回答这个问题,我们要慢慢来. ①首先从DRY原则开始说起 Don't Repeat Yourself,不要重复你的代码. DRY原则的重要性怎么提都不过分,很多人说编程 ...