在Azure虚拟机上安装SQL server
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的更多相关文章
- Azure 虚拟机上的 SQL Server 常见问题
本主题提供有关运行 Azure 虚拟机中的 SQL Server 时出现的一些最常见问题的解答. 如果本文未解决你的 Azure 问题,请访问 MSDN 和 CSDN 上的 Azure 论坛. 你可以 ...
- 在Azure虚拟机上安装VNC
我们知道,Azure提供的linux虚拟机镜像是没有桌面的,是base版的,大多情况下能满足绝大部分工作需要,甚至很多习惯使用命令行的读者,反而用不惯带桌面的linux OS,但是有些情况下,桌面还是 ...
- 如何在windows Server 2008虚拟机上安装SQLServer2008数据库
一.环境准备 1.cn_windows_server_2008_r2_standard_enterprise_datacenter_web_x64_dvd_x15-50360.iso 2.NDP452 ...
- SQLServer-SQLServer2017:安装 SQL Server 的硬件和软件要求
ylbtech-SQLServer-SQLServer2017:安装 SQL Server 的硬件和软件要求 1.返回顶部 1. 安装 SQL Server 的硬件和软件要求 2018/11/06 适 ...
- Win7 安装SQL SERVER 2012需要SP1补丁
在操作系统Win7上安装SQL Server 2012时,报如下错误: 也就是说SQL Server 2012如要要安装在Windows 7 上,则至少需要安装SP1补丁.否则就会弹出上面提示信息.关 ...
- 安装 SQL Server 2012 的硬件和软件要求(官方全面)
以下各节列出了安装和运行 SQL Server 2012 的最低硬件和软件要求. 有关 SharePoint 集成模式下 Analysis Services 的要求的详细信息,请参阅硬件和软件要求(S ...
- Windows Azure功能更新:SQL Server AlwaysOn和Notification Hub 正式商用
一周以前Windows Azure发布了新的更新内容,主要的更新有3项: 虚拟机上的SQL Server支持AlwaysOn可用性组了 Notification Hub商用 自动缩放支持时间策略 这里 ...
- 安装SQL Server 2008R2 报错“此计算机上安装了 Microsoft Visual Studio 2008 的早期版本”解决方法
安装SQL Server 2008 R2报错“此计算机上安装了 Microsoft Visual Studio 2008 的早期版本,请在安装 SQL Server 2008 前将 VS2008 升级 ...
- 在VM虚拟机上安装Microsoft Dynamics CRM 2016 步骤图解及安装注意事项
安装Dynamics CRM 2016环境配置要求: 系统版本:Windows Server 2012 R2(必须) SQL 版本: SQLServer2014SP1-FullSlipstream-x ...
随机推荐
- webpack入门——webpack的安装与使用
一.简介 1.什么是webpack webpack是近期最火的一款模块加载器兼打包工具,它能把各种资源,例如JS(含JSX).coffee.样式(含less/sass).图片等都作为模块来使用和处理. ...
- [NOI2006] 最大获利
[NOI2006] 最大获利 ★★★☆ 输入文件:profit.in 输出文件:profit.out 简单对比时间限制:2 s 内存限制:512 MB [问题描述] 新的技术正冲击着手 ...
- [LeetCode] Range Sum Query - Mutable 区域和检索 - 可变
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...
- [LeetCode] Binary Search Tree Iterator 二叉搜索树迭代器
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the ro ...
- 【swift学习笔记】六.访facebook登录页面
代码最下边有下载地址. 做这个demo的主要心得就是自适应所有的屏幕,要先布局大的框架,再一步一步设置小的细节. 看一下效果 再看一下自动适应所有屏幕的效果: keyboard打开时整个frame上移 ...
- 记录PHP的超全局变量$_SERVER
$_SERVER是PHP中十分实用的超全局变量,在开发可移植的网站的时候会变得很有用. 下面我记录一下我自己常用到的几个变量 1.$_SERVER['SERVER_NAME']:记录了网站的域名. 2 ...
- C#中Abstract和Virtual的区别
c# 中 Abstract和Virtual比较容易混淆,都与继承有关,并且涉及override的使用.下面讨论一下二者的区别: 一.Virtual方法(虚方法) virtual 关键字用于在基类中修饰 ...
- jquery option
转--jquery动态添加option示例 http://www.jb51.net/article/45031.htm //js动态添加option var sel= document.getElem ...
- 如何在网页标题栏加入logo图标?
标题栏: <link rel="icon" href="ico地址" type="image/x-icon">收藏夹:<l ...
- java面向对象---对象初始化
在本地变量中,如果定义了一个变量后没有赋值就使用,那么eclipse就会报错:但是在成员变量中,java是会强制给一个没有初始化的变量一个默认的初始值0, 如果是一个boolean类型的变量,那么默认 ...