博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用PowerShell设置SQL Server 2019 Azure容器实例
阅读量:2511 次
发布时间:2019-05-11

本文共 10694 字,大约阅读时间需要 35 分钟。

This guide is all about provisioning SQL Server 2019 using Azure Container Instance (ACI), including the installation and configuration. In this article, we talk about the Azure Container Instance (ACI), the Azure PowerShell module, installation and configuration of SQL Server using the Azure PowerShell module, and automation of installation and deployment using templates.

本指南全部关于使用Azure容器实例(ACI)设置SQL Server 2019,包括安装和配置。 在本文中,我们讨论了Azure容器实例(ACI),Azure PowerShell模块,使用Azure PowerShell模块安装和配置SQL Server以及使用模板自动化安装和部署。

介绍 (Introduction)

Azure Container Instance (ACI) is a service offering for managing and running containers on the Azure cloud. In this article you’ll see in detail, how to setup and automate SQL Server 2019 installation on Azure Container Instance using the Azure PowerShell module. Also, I will show you how to create a template for the same. The template is a JSON file, which gives you the ability to modify the input parameters as you would edit plain text, and helps perform a successful deployment in a relatively simpler way.

Azure容器实例(ACI)是一项服务产品,用于在Azure云上管理和运行容器。 在本文中,您将详细了解如何使用Azure PowerShell模块在Azure容器实例上设置和自动化SQL Server 2019安装。 另外,我将向您展示如何为该模板创建模板。 该模板是一个JSON文件,使您能够像编辑纯文本时一样修改输入参数,并以相对简单的方式帮助成功完成部署。

Containers are in great demand because they are lightweight in nature and provides an agile method to test the code before it gets deployed into production. Using Azure Container Instance (ACI) provides an interface to provision deploy containers with very a few simple steps.

容器的需求量很大,因为它们本质上是轻量级的,并且提供了一种敏捷的方法来在将代码部署到生产中之前对其进行测试。 使用Azure容器实例(ACI)提供了一个界面,可以通过几个简单的步骤来配置部署容器。

Note: Microsoft Azure Container Instances (ACI) provides hypervisor isolation — it ensures that the containers run without sharing a kernel.

注意 :Microsoft Azure容器实例(ACI)提供了虚拟机管理程序隔离-确保容器在运行时无需共享内核。

Azure PowerShell模块 (The Azure PowerShell module)

The new Azure (Az) PowerShell module is built to leverage PowerShell Core and the Cloud Shell. The module is compatible with PowerShell 5.1 as well as PowerShell Core. Az provides cross-platform capabilities and ensures that PowerShell and PowerShell Core users get the latest Azure interface tooling platform. By default, Azure Cloud Shell ships with Az; the module is also available for .

构建了新的Azure(Az)PowerShell模块以利用PowerShell Core和Cloud Shell。 该模块与PowerShell 5.1以及PowerShell Core兼容。 Az提供跨平台功能,并确保PowerShell和PowerShell Core用户获得最新的Azure界面工具平台。 默认情况下,Azure Cloud Shell附带有Az。 该模块还可以 。

Note: Az is a replacement for AzureRM and AzureRM.Netcore modules. Az runs on PowerShell 5.1 and PowerShell Core. All cmdlets use Az as their noun prefix. Data plane and management plane cmdlets for all services have now been combined in the Azure PowerShell module. Az ships with new cmdlets to enable script compatibility with AzureRM (Enable-/Disable-AzureRmAlias).

注意Az替代了AzureRM和AzureRM.Netcore模块。 Az在PowerShell 5.1和PowerShell Core上运行。 所有cmdlet均使用Az作为其名词前缀。 所有服务的数据平面和管理平面cmdlet现在已在Azure PowerShell模块中合并。 Az附带了新的cmdlet,以使脚本与AzureRM(Enable- / Disable-AzureRmAlias)兼容。

如何使用PowerShellGet安装Azure PowerShell模块 (How to install Azure PowerShell module using PowerShellGet)

This section contains the instructions to install the Azure PowerShell module. Here are the prerequisites:

本节包含安装Azure PowerShell模块的说明。 这是前提条件:

  1. You must have .NET Framework 4.7.2 installed

    您必须安装.NET Framework 4.7.2
  2. You can have both AzureRM and Azure PowerShell modules but it is recommended to remove all Azure RM modules

    您可以同时拥有AzureRM和Azure PowerShell模块,但建议删除所有Azure RM模块

Install the module in a single step, with the following command:

使用以下命令一步安装模块:

Install-Module -Name Az

Note: If your script uses AzureRm or Azure in cmdlet names, then it’s time to start getting used to Az instead. The process is simple and requires relatively less effort to redesign entire scripts. For example, if you’re using New-AzureRMVm in your script, it becomes New-AzVm.

注意 :如果您的脚本在cmdlet名称中使用AzureRm或Azure,那么该是开始习惯使用Az的时候了。 该过程很简单,并且需要相对较少的精力来重新设计整个脚本。 例如,如果您在脚本中使用New-AzureRMVm,它将变为New-AzVm。

设置SQL Server 2019 ACI (Setting up SQL Server 2019 ACI)

In this section we discuss the Az cmdlets used to setup and install SQL Server 2019 container instance using Azure Container Instance (ACI).

在本节中,我们讨论用于使用Azure容器实例(ACI)设置和安装SQL Server 2019容器实例的Az cmdlet。

The following table lists the Az commands that are used to configure SQL 2019:

下表列出了用于配置SQL 2019的Az命令:

Resource type

Command

list

az group show

az group delete

container create

Container logs

az container logs

Container delete

az container delete

Container list

az container list

资源类型

命令

列表

az团体秀

Az组删除

容器创建

集装箱日志

Az容器日志

容器删除

Az容器删除

货柜清单

Az容器列表

Now, let us discuss the steps that are required to configure SQL Server 2019 Azure Container Instance (ACI).

现在,让我们讨论配置SQL Server 2019 Azure容器实例(ACI)所需的步骤。

First, create a new resource group dockercontainerRG using the az create group cmdlets. In this case, dockercontainerRG is configured in the location, eastUS.

首先,使用az create group cmdlet创建一个新的资源组dockercontainerRG 。 在这种情况下, dockercontainerRG被配置在eastUS位置。

PS Azure:\> az group create --name dockercontainerRG --location eastUS

Azure PowerShell module - Az group create command reference

Next, create a container in the container group, dockercontainerRG that runs Linux, with 1 CPU, 3.5 GB of memory, and mapped to a public IP address, with port 1433 opened, followed by the SQL Server configuration parameters.

接下来,在容器组dockercontainerRG中创建一个容器,该容器运行Linux,具有1个CPU,3.5 GB的内存,并映射到公共IP地址(打开端口1433),后跟SQL Server配置参数。

PS Azure:\> az container create --image mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu  --name mssql-2019 --resource-group dbmigrationRG --cpu 1 --memory 3.5 --port 1433 --ip-address public -e ACCEPT_EULA=Y MSSQL_SA_PASSWORD=thanVitha@2019 MSSQL_PID=Developer MSSQL_COLLATION=Latin1_General_CI_AS MSSQL_ENABLE_HADR=Y --location eastus  --dns-name-label sqldemo

Parameter

Description

-e ‘ACCEPT_EULA=Y’

Set the variable ACCEPT_EULA=Y to confirm the acceptance of the  (EULA). This is a mandatory setting for the SQL Server installation.

-e ‘SA_PASSWORD= ‘

Specify a strong password as it must meet the . It is also a mandatory setting for the SQL Server installation and configuration.

-p 1433

Map a TCP port. In this case, SQL Server set to listen on port 1433 of the container.

–name

Specify a custom name for the container. In this example, the custom name mssql-2019 is used. The name must be unique.

–image mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu

This is the image that corresponds to SQL Server 2019. You can also change it to microsoft/mssql-server-linux:latest for SQL Server 2017 installation. In this case, the image is referring to the SQL Server 2019 CTP 2.2 Linux container image.

MSSQL_PID= Developer

Specify the SQL Server edition. The following are the possible values:

  1. Evaluation
  2. Developer
  3. Express
  4. Web
  5. Standard
  6. Enterprise

MSSQL_COLLATION= Latin1_General_CI_AS

Specify the SQL Server collation. In this case, we use Latin1_General_CI_AS

MSSQL_ENABLE_HADR=Y

This option enables an Availability Group (AG).

–dns-name-label

The filed dns-name- label is for identifying the container with the public IP.

参数

描述

-e'ACCEPT_EULA = Y'

设置变量ACCEPT_EULA = Y以确认接受 (EULA)。 这是SQL Server安装的必需设置。

-e'SA_PASSWORD = '

指定一个强密码,因为它必须满足 。 它也是SQL Server安装和配置的必需设置。

-p 1433

映射一个TCP端口。 在这种情况下,SQL Server设置为侦听容器的端口1433。

-名称

指定容器的自定义名称。 在此示例中,使用了自定义名称mssql-2019 。 名称必须唯一

–图像mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu

这是与SQL Server 2019对应的映像。对于SQL Server 2017安装,您也可以将其更改为microsoft / mssql-server-linux:latest 。 在这种情况下,该映像引用的是SQL Server 2019 CTP 2.2 Linux容器映像。

MSSQL_PID =开发人员

指定SQL Server版本。 以下是可能的值:

  1. 评价
  2. 开发者
  3. 表达
  4. 网页
  5. 标准
  6. 企业

MSSQL_COLLATION = Latin1_General_CI_AS

指定SQL Server排序规则。 在这种情况下,我们使用Latin1_General_CI_AS

MSSQL_ENABLE_HADR = Y

此选项启用可用性组(AG)。

–dns名称标签

归档的dns-name-标签用于标识具有公共IP的容器。

In the output, you can see the container creation process status. the following screenshot shows it as Running.

在输出中,您可以看到容器创建过程的状态。 以下屏幕截图将其显示为Running

In about a minute or two, the container will be up and ready to use. You can scroll the displayed log details and check for the state Running in the output.

在大约一两分钟内,容器将准备好使用。 您可以滚动显示的日志详细信息,并检查输出中的状态“正在运行 ”。

Azure PowerShell module - Az Container create command output validation for the state - Running

Next, you’ll learn to examine the logs for the specified container mssql-2019, residing in the container group dockercontainerRG.

接下来,您将学习检查位于容器组dockercontainerRG中的指定容器mssql-2019的日志。

PS Azure:\> az container logs --resource-group dockercontainerRG --name mssql-2019

Next, verify its status by connecting to the SQL Server 2019 Azure Container Instance either using sqlcmd or PowerShell.

接下来,通过使用sqlcmd或PowerShell连接到SQL Server 2019 Azure容器实例来验证其状态。

PS Azure:\> sqlcmd -S 104.45.186.59 -U SA -P thanVitha@2019 -Q "select @@version"

The output confirms that the connection was successful.

输出确认连接成功。

To delete the container, mssql-2019, from the resource group dockercontainerRG, run the following Az command.

要从资源组dockercontainerRG删除容器mssql-2019 ,请运行以下Az命令。

PS Azure:\> az container delete --name mssql-2019 --resource-group dockercontainerRG

Azure PowerShell module - Container cleanup activity using az container delete command

To remove the resource group, run the following command:

要删除资源组,请运行以下命令:

PS Azure:\> az group delete --name dockercontainerRG

自动化 (Automation)

Let us now see how to automate the installation and configuration of SQL Server using Azure Container Instance (ACI).

现在,让我们看看如何使用Azure容器实例(ACI)自动执行SQL Server的安装和配置。

In the Azure portal blade, click on Automation script and then click Add to library. This option will add the template to the Azure library.

在Azure门户刀片服务器中,单击“ 自动化”脚本 ,然后单击“ 添加到库”。 此选项会将模板添加到Azure库。

Click Deploy.

点击部署

Now, you should see an option to edit the template. Click Edit template and change the values to the appropriate ones. In this case, defaultValue is set to mssql-2019-1.

现在,您应该看到一个编辑模板的选项。 单击编辑模板,然后将值更改为适当的值。 在这种情况下,defaultValue设置为mssql-2019-1。

Click Save.

点击保存

In the next page, select the appropriate resource group settings, accept the terms and conditions, and click Purchase.

在下一页中,选择适当的资源组设置,接受条款和条件,然后单击“ 购买”

Clicking on the notification icon will show that the deployment is in progress.

单击通知图标将显示部署正在进行中。

In about two minutes, the SQL Server 2019 instance will be up and running with the name, mssql-2019-1. You can connect to the instance using sqlcmd as shown below:

大约两分钟后,SQL Server 2019实例将启动并运行,名称为mssql-2019-1 。 您可以使用sqlcmd连接到实例,如下所示:

摘要 (Summary )

In this article, we covered the installation and configuration of a SQL Server 2019 Ubuntu Azure Container Instance. We also discussed the steps that are required to automate the deployment of SQL Server 2019 using templates and the Azure PowerShell module. I hope you found this article useful. Feel free to start a conversation in the comments below.

在本文中,我们介绍了SQL Server 2019 Ubuntu Azure容器实例的安装和配置。 我们还讨论了使用模板和Azure PowerShell模块自动执行SQL Server 2019部署所需的步骤。 希望本文对您有所帮助。 请随时在下面的评论中开始对话。

翻译自:

转载地址:http://ppswd.baihongyu.com/

你可能感兴趣的文章
spark算子
查看>>
(转)Linux服务器SNMP常用OID
查看>>
zoj2112 主席树动态第k大 ( 参考资料链接)
查看>>
弹出框popupWindow
查看>>
Python学习(007)-函数的特性
查看>>
扑克牌的顺子
查看>>
nodejs + express 热更新
查看>>
ClientScriptManager.RegisterClientScriptBlock Method 无效
查看>>
asp.net web site中reference的version的autoupdate
查看>>
第4章 网络层
查看>>
volatile
查看>>
项目需求分析答辩总结
查看>>
mysql-6正则表达式
查看>>
廖雪峰Java2面向对象编程-5包和classpath-1包package
查看>>
廖雪峰Java7处理日期和时间-3java.time的API-1LocalDateTime
查看>>
利用golang语法检查对象是否实现了接口
查看>>
在UBUNTU上安装基于bochs的 xv6
查看>>
Azure Storage Blob文件重命名
查看>>
RxJava2.0 使用
查看>>
FreeImage的图像处理软件
查看>>