azure批量创建虚拟机_如何将数据库迁移到Azure虚拟机

azure批量创建虚拟机

In one of my articles about Microsoft Azure, I show how to create credentials and how to connect to an Azure Database using SQL Server Management Studio (SSMS). In this new article, we will talk about the Azure Virtual Machines and we will learn how to connect to them using our local SSMS. You will require unblocking ports, add endpoints and other tasks that I will explain later. We will also learn how to export a local database to an Azure Virtual Machine with SQL Server installed.

我的有关Microsoft Azure的文章中 ,我展示了如何创建凭据以及如何使用SQL Server Management Studio(SSMS)连接到Azure数据库。 在这篇新文章中,我们将讨论Azure虚拟机,并将学习如何使用本地SSMS连接到它们。 您将需要取消阻塞端口,添加端点和其他任务,我将在后面解释。 我们还将学习如何将本地数据库导出到安装了SQL Server的Azure虚拟机。

要求 ( Requirements )

In this example, we will require an Azure Virtual Machine installed, a local machine with SQL Server and SSMS installed, the Cloud Adapter (we are including the steps to configure it) and a certificate which will also be explained in this section.

在此示例中,我们将需要安装Azure虚拟机,安装了SQL Server和SSMS的本地计算机,云适配器(我们包括配置它的步骤)和证书,本节还将对此进行说明。

  1. this link. To create a virtual machine, review 此链接 。 要创建虚拟机,请查看this link.此链接
  2. A local machine with the SQL Server Engine Installed and a database to export with access to internet.

    安装了SQL Server引擎的本地计算机和要访问Internet的要导出的数据库。

    The Cloud Adapter

    云适配器

    1. A Cloud Adapter. The cloud adapter is an Azure Service required for SQL Server and generates a SSL certificate In the Azure portal. In order to create it, go to Virtual Machines and click on the virtual machine name.

      云适配器。 云适配器是SQL Server必需的Azure服务,并在Azure门户中生成SSL证书。 为了创建它,请去虚拟机并且点击虚拟机名称。


      Figure r1. The Azure virtual machines.


      图r1。 Azure虚拟机。

    2. Click on EndPoints.

      单击端点。


      Figure r2. The Endpoints


      图r2。 终点


    3. Figure r3. Add new endpoints


      图r3。 添加新端点

    4. Add the Endpoint name, protocol and port (by default it is the port 11435).

      添加端点名称,协议和端口(默认情况下为端口11435)。


      Figure r4. The cloud Adapter for SQL


      图r4。 适用于SQL的云适配器

    A certificate

    证书

    Another requirement is a certificate to connect to the Cloud. In order to do it do the following steps:

    另一个要求是连接到云的证书。 为此,请执行以下步骤:

    1. Open the certmgr.msc. You can create your certificate or use an existing one. In this example we will use an existing one.

      打开certmgr.msc。 您可以创建证书或使用现有证书 。 在此示例中,我们将使用现有示例。


      R5. The certificate console


      R5。 证书控制台

    2. Select the certificate right click and select All Tasks>Export


      R6. Export a certificate
    3. 右键单击证书,然后选择“所有任务”>“导出”


      R6。 导出证书
    4. The wizard to export certificates will be displayed. Click next.

      将显示导出证书的向导。 点击下一步。


      R7. Export Wizard.


      R7。 导出向导。

    5. Select if you want to have a private key.

      选择是否要使用私钥。


      R8. Private key question


      R8。 私人 关键 问题

    6. Specify the format of the certificate.

      指定证书的格式。


      R9. Select the certify format


      R9。 选择认证格式

    7. Specify a name and a path.

      指定名称和路径。


      R10. Selecting name and path of the .cer file.


      R10。 选择名称和路径 cer 文件。

    8. Once the Wizard is completed, press finish.

      向导完成后,按完成。


      R11. Final step of the export wizard.


      R11。 导出向导的最后一步。

    9. Go to the Azure portal and click on the Virtual Machine.

      转到Azure门户,然后单击“虚拟机”。


      R12. The virtual machine.


      R12。 虚拟机。

    10. Click on the Management Certificates link.

      单击管理证书链接。

      R13. The certificates

      R13。 证书

    11. Click the Upload button and upload the certificate created on step 7.

      单击上载按钮,然后上载在步骤7中创建的证书。


      R14. The option to upload certificates.


      R14。 上传证书的选项。

    12. 入门 ( Getting Started )

      1. To connect to a Virtual Machine, you can use the SQL Server Account. In order to enable the SQL Server authentication, in the Azure Virtual Machine (VM), open the SSMS and connect to the database. Right click on your Server and select properties. Change the Server Authentication to SQL Server and Windows Authentication to connect from your local machine.

        要连接到虚拟机,您可以使用SQL Server帐户。 为了启用SQL Server身份验证,请在Azure虚拟机(VM)中,打开SSMS并连接到数据库。 右键单击服务器,然后选择属性。 将服务器身份验证更改为SQL Server和Windows身份验证以从本地计算机连接。

        Figure 1. Server properties

        图1. 服务器属性

      2. You will be prompted a message about restarting the SQL Server Service.

        系统将提示您有关重新启动SQL Server服务的消息。


        Figure 2. Information message.


        图2. 信息消息。

      3. Restart the Service in order for the new configuration to take effect.

        重新启动服务,以使新配置生效。


        Figure 3. Restarting the MSSQL Service


        图3.重新启动MSSQL服务

      4. Now that the SQL Server authentication is enabled, create a SQL Server Login.

        现在已启用SQL Server身份验证,请创建一个SQL Server登录名。


        Figure 4. Creating a new login.


        图4.创建一个新的登录名。

      5. Specify the login name and passwords. It is recommended to enforce the password policy for security reasons. In this example, we will omit the Enforce password policy to simplify the example.

        指定登录名和密码。 出于安全原因,建议强制执行密码策略。 在此示例中,我们将省略“强制密码”策略以简化示例。


        Figure 5. Login settings


        图5.登录设置

      6. Go to the Virtual Machine in the Azure Portal and click on the Virtual Machine name.

        转到Azure门户中的虚拟机,然后单击虚拟机名称。


        Figure 6. The virtual machine status


        图6.虚拟机状态

      7. Click the ENDPOINTS link and press the Add icon to add a new Endpoint.

        单击ENDPOINTS链接,然后按添加图标以添加新的端点。

        Figure 7. Endpoints

        图7.端点

      8. Select the add Standalone Endpoint

        选择添加独立端点


        Figure 8. Adding endpoint


        图8. 添加端点

      9. Write the name of the Endpoint. The protocol should be TCP and the port by default in the default instance is 1433.

        输入端点的名称。 该协议应为TCP,默认实例中的默认端口为1433。


        Figure 9. Endpoint settings


        图9.端点设置

      10. The ACL allows you to specify the range of subnets allowed to access to your Azure virtual Machine. You can provide the name and subnet. If you do not your Internet IP, you can use this link.

        ACL允许您指定允许访问Azure虚拟机的子网范围。 您可以提供名称和子网。 如果您没有Internet IP,则可以使用此链接


        Figure 10. The ACL details


        图10. ACL详细信息

      11. You also need to enable the ports used to access remotely. Go to the Windows Firewall and right click on the Inbound Rules and select new rule.

        您还需要启用用于远程访问的端口。 转到Windows防火墙,然后右键单击“入站规则”,然后选择新规则。


        Figure 11. The Inbound rules.


        图11.入站规则。

      12. Specify the port to which you want to apply a rule. In this case, it is the port 1433.

        指定要对其应用规则的端口。 在这种情况下,它是端口1433。


        Figure 12. The TCP IP SQL Server port


        图12. TCP IP SQL Server端口

      13. In the action, select the allow the connection option.

        在操作中,选择“允许连接”选项。


        Figure 13. Allow permissions


        图13. 允许权限

      14. Select the rule that you want to apply.

        选择您要应用的规则。


        Figure 14. Rules to apply


        图14. 适用规则

      15. Write a name for the rule.

        为规则写一个名字。


        Figure 15. Rule name


        图15.规则名称

      16. Now connect to your Azure VM from the SSMS of the local machine.

        现在,从本地计算机的SSMS连接到您的Azure VM。

        Figure 16. 图16. Connect to an Azure VM from the local SSMS 从本地SSMS连接到Azure VM

        If everything is OK you can now connect to the SQL Server machine with Azure from your local machine.

        如果一切正常,您现在可以从本地计算机使用Azure连接到SQL Server计算机。

      如何使用将数据库部署到Windows Azure VM来部署数据库 ( How to deploy your database using the Deploy Database to Windows Azure VM )

      Now we will export our local database to the Azure Vm.

      现在,我们将本地数据库导出到Azure Vm。

      1. In the local SSMS, Select the database that you want to copy and select Tasks>Deploy Database to Windows Azure.

        在本地SSMS中,选择要复制的数据库,然后选择“任务”>“将数据库部署到Windows Azure”。


        Figure 17. The Deploy Database to Azure VM Wizard.


        图17.将数据库部署到Azure VM向导。

      2. The Introduction Wizard Windows will be displayed.

        将显示“简介向导”窗口。


        Figure 18. The Introduction Wizard.


        图18.简介向导。

      3. Press the Connect button to connect to the local SQL Server.

        按“连接”按钮连接到本地SQL Server。


        Figure 19. The local machine information


        图19. 本地机器信息

      4. Specify the Server name and credentials and press Connect.

        指定服务器名称和凭据,然后按连接。


        Figure 20. The local machine credentials.


        图20.本地计算机凭据。

      5. Select a database to export and a temporary location for the backup files. Make sure that the SQL Server has permissions on a temporary location.

        选择要导出的数据库和备份文件的临时位置。 确保SQL Server对临时位置具有权限。



        Figure 21. The Database to export and the temporary file. 图21.要导出的数据库和临时文件。
      6. To connect to Azure, you will need a Certificate. You can also work with a publishing profile. For more information about a publishing profile.

        若要连接到Azure,您将需要一个证书。 您也可以使用发布配置文件。 有关发布配置文件的更多信息。


        Figure 22. Certificate.


        图22 证书。

      7. Press the Select button and select the certificate created on the requirements section of this article. Copy the subscription ID of step 9 of the requirements in the certificate section.

        按“选择”按钮,然后选择在本文的“需求”部分上创建的证书。 在证书部分中复制需求的步骤9的订阅ID。


        Figure 23. The subscription ID.


        图23.订阅ID。

      8. Specify the Cloud Service name, Virtual Machine name and Storage Account and then press Settings.

        指定云服务名称,虚拟机名称和存储帐户,然后按设置。


        Figure 24. The subscription ID.


        图2 4 订阅ID。

      9. Specify the Virtual Machine, your credentials and the Cloud Adapter port. Verify in the requirements the port used. By default, it is the port 11435.

        指定虚拟机,您的凭据和云适配器端口。 在要求中验证使用的端口。 默认情况下,它是端口11435。


        Figure 25. Cloud Adapter information.


        图25.云适配器信息。

      10. You will receive a message about the certificate. If you agree, press Trust Publisher and connect.

        您将收到有关证书的消息。 如果您同意,请按Trust Publisher并进行连接。


        Figure 26. The Trust message.


        图26.信任消息。

      11. Finally you will have your information like this:

        最后,您将获得如下信息:


        Figure 27. The Azure VM information and the Local SQL Server information


        图27. Azure VM信息和本地SQL Server信息

      12. If everything is OK, the summary window will be displayed.

        如果一切正常,将显示“摘要”窗口。


        Figure 28. Summary Window


        图28.摘要窗口

      13. Finally, you will receive the results windows that will be green if everything is OK.

        最后,如果一切正常,您将收到绿色的结果窗口。

        Figure 29. The Results wizard. 图29.结果向导。
      14. To verify that the database was copied successfully, go to the virtual machine and verify that the database was copied successfully.

        要验证数据库是否已成功复制,请转到虚拟机并验证数据库是否已成功复制。

      结论 ( Conclusion )

      In this tutorial, we’ve learned how to connect to an Azure virtual machine with SQL Server using our local SQL Server. We also learned how to export a local database to a SQL Server Azure VM.

      在本教程中,我们学习了如何使用本地SQL Server通过SQL Server连接到Azure虚拟机。 我们还学习了如何将本地数据库导出到SQL Server Azure VM。

翻译自: https://www.sqlshack.com/migrate-your-database-to-an-azure-virtual-machine/

azure批量创建虚拟机

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值