Windows Server 2016上SQL Server Always On可用性组的全面指南

In this article, we will configure a SQL Server Always On Availability Group on the Windows Server 2016. We use SQL Server 2019 for configuration.

在本文中,我们将在Windows Server 2016上配置SQL Server Always On可用性组。我们使用SQL Server 2019进行配置。

介绍 (Introduction)

SQL Server Always On Availability Groups offers high availability and disaster recovery solution for mission-critical databases. It also supports to offload some read workloads to the secondary replica. We can also configure database backups from the secondary instance.

SQL Server Always On可用性组为关键任务数据库提供了高可用性和灾难恢复解决方案。 它还支持将某些读取工作负载卸载到辅助副本。 我们还可以从辅助实例配置数据库备份。

Usually, Database Administrators are responsible for configuring availability groups in an organization. Still, they are unaware of the underlying infrastructure creation such as virtual machine, configure an active directory, join virtual servers in the domain, configure a failover cluster, quorum configuration, and storage allocation.

通常,数据库管理员负责在组织中配置可用性组。 但是,他们仍然不知道基础架构的创建,例如虚拟机,配置活动目录,在域中加入虚拟服务器,配置故障转移群集,仲裁配置和存储分配。

Suppose you do not have any infrastructure set up as of now. You can follow this article series for an end to end guidance on configuration of SQL Server Always On Availability Groups in Windows Server 2016 with SQL Server 2019.

假设您目前尚未建立任何基础架构。 您可以按照本系列文章的顺序来获得有关在Windows Server 2016和SQL Server 2019中配置SQL Server Always On可用性组的端到端指导。

This series combines the following articles:

本系列结合了以下文章:

  1. A comprehensive guide to SQL Server Always On Availability Groups on Windows Server 2016

    Windows Server 2016上SQL Server Always On可用性组的全面指南
  2. Configure Domain Controller and Active Directory for SQL Server Always On Availability groups

    为SQL Server Always On可用性组配置域控制器和Active Directory
  3. Configure Failover Cluster, Storage controller, and Quorum configurations for SQL Server always-on availability groups

    为SQL Server永远在线可用性组配置故障转移群集,存储控制器和仲裁配置
  4. Install SQL Server 2019 on Windows Server 2016 with SQL Server always-on availability groups

    使用SQL Server永远在线可用性组在Windows Server 2016上安装SQL Server 2019

In this article, we will do the following tasks:

在本文中,我们将执行以下任务:

  • Oracle VirtualBox installation

    Oracle VirtualBox安装
  • Create Virtual machines with Windows Server 2019

    使用Windows Server 2019创建虚拟机
  • VM network configurations

    VM网络配置

Let’s start the journey toward your first SQL Server Always On Availability group.

让我们开始您的第一个SQL Server Always On可用性组的旅程。

在Oracle VirtualBox中配置虚拟机 (Configure a Virtual Machine in Oracle VirtualBox )

To begin with, we require the following servers.

首先,我们需要以下服务器。

  • Server 1: We require a server for configuring domain controller and active directory

    服务器1:我们需要一台用于配置域控制器和活动目录的服务器
  • Server 2: Primary node in the SQL Server Always On Availability group

    服务器2: “ SQL Server始终可用”组中的主节点
  • Server 3: It acts as a Secondary node for SQL Server Always On Availability group

    服务器3:它充当“ SQL Server始终可用”组的辅助节点

We will use the Oracle VM VirtualBox in this article to create the virtual machines on my laptop. It is an open-source virtualization software, and you can install Windows, Linux, Unix operating systems on it. In this article, I use Oracle VM VirtualBox 6.1 version.

我们将在本文中使用Oracle VM VirtualBox在笔记本电脑上创建虚拟机。 它是一种开源虚拟化软件,您可以在其上安装Windows,Linux和Unix操作系统。 在本文中,我使用Oracle VM VirtualBox 6.1版本。

Windows Server 2016上SQL Server Always On可用性组的全面指南

You can browse this URL, and download the platform-specific software, follow the steps and install it. It is pretty straightforward.

您可以浏览该URL ,然后下载特定于平台的软件,按照步骤进行安装。 这很简单。

This article uses the term VirtualBox for subsequent sections.

本文在后续部分中使用术语VirtualBox。

On my laptop, I already have the following two virtual machines configured.

在我的笔记本电脑上,我已经配置了以下两个虚拟机。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Let’s click on New for a new virtual machine. It asks for the following details.

让我们单击“新建”以获取新的虚拟机。 它要求提供以下详细信息。

  • Machine name: It is the virtual machine name. It is similar to your laptop hostname

    机器名称 :这是虚拟机名称。 它类似于您的笔记本电脑主机名
  • Machine folder: It is the directory in your local system where VirtualBox stores all relevant files

    机器文件夹 :这是您的本地系统中VirtualBox存储所有相关文件的目录
  • Type: Select the required operating system from the drop-down values. I require Microsoft Windows operating system for all VM’s

    类型 :从下拉列表中选择所需的操作系统。 我的所有VM都需要Microsoft Windows操作系统
  • Version: Select the version of the operating system. In this article, we will install Windows Server 2016 standard edition

    版本 :选择操作系统的版本。 在本文中,我们将安装Windows Server 2016标准版

Windows Server 2016上SQL Server Always On可用性组的全面指南

Click Next and configure the RAM for the virtual machine. I would recommend you assign at least 4 GB RAM for testing purposes.

单击下一步,然后为虚拟机配置RAM。 我建议您至少分配4 GB RAM用于测试目的。

Windows Server 2016上SQL Server Always On可用性组的全面指南

In the next step, add a virtual disk in the new machine. You should consider your database requirements and configure a suitable size of the disk.

在下一步中,在新计算机中添加虚拟磁盘。 您应考虑数据库要求并配置合适的磁盘大小。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Choose the hard disk file type from the following values.

从以下值中选择硬盘文件类型。

  • VDI ( VirtualBox Disk Image)

    VDI(VirtualBox磁盘映像)
  • VHD(VirtualBox Hard Disk)

    VHD(VirtualBox硬盘)
  • VMDK(Virtual Machine Disk)

    VMDK(虚拟机磁盘)

We can go ahead with the default hard disk type as VDI. You can refer to VirtualBox documentation for details on hard disk types.

我们可以继续使用默认的硬盘类型VDI。 您可以参考VirtualBox文档以获取有关硬盘类型的详细信息。

Windows Server 2016上SQL Server Always On可用性组的全面指南

The next step is to configure the static or dynamic disk size. In case of static, if your disk becomes full, you need to expand it to avoid performance issues in the VM.

下一步是配置静态或动态磁盘大小。 如果是静态磁盘,则如果磁盘已满,则需要对其进行扩展以避免VM中的性能问题。

In the dynamic mode, it automatically grows the hard disk space up to maximum configured values. You should also note that it does not release the space once occupied.

在动态模式下,它将自动将硬盘空间增加到最大配置值。 您还应该注意,一旦被占用,它不会释放空间。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Select the VDI storage file location and size. You should have sufficient space in the drive to avoid any storage issues.

选择VDI存储文件的位置和大小。 驱动器中应该有足够的空间以避免任何存储问题。

Windows Server 2016上SQL Server Always On可用性组的全面指南

It creates a new virtual machine, as shown below.

它将创建一个新的虚拟机,如下所示。

Windows Server 2016上SQL Server Always On可用性组的全面指南

在虚拟机上安装Windows Server 2016 (Install Windows Server 2016 on Virtual machine)

下载Windows Server 2016 ISO for SQL Server Always On可用性组 (Download Windows Server 2016 ISO for SQL Server Always On Availability Group)

Microsoft gives 180 days evaluation copy to use and learn about the Windows Server 2016. It is beneficial to explore new things, especially if you do not have any corporate servers to perform the activity.

Microsoft提供了180天的评估副本以供使用和了解Windows Server2016。探索新事物非常有帮助,尤其是在您没有任何公司服务器来执行此活动的情况下。

Open Microsoft website and start the evaluation version valid up to 180 days. It requires a license to use Windows beyond 180 days. It is enough time for all your testing work or learns new features.

打开Microsoft网站,并启动评估版本,有效期长达180天。 它要求获得许可才能使用Windows 180天以上。 这是您所有测试工作或学习新功能的足够时间。

Windows Server 2016上SQL Server Always On可用性组的全面指南

It downloads the Windows Server 2016, depending upon your network bandwidth. Its size is approximately 6.49 GB.

它会根据您的网络带宽下载Windows Server 2016。 其大小约为6.49 GB

Click on Start in the virtual machine, browse to the directory where we downloaded the Windows Server 2016 ISO, and click Choose.

单击虚拟机中的开始,浏览到我们下载Windows Server 2016 ISO的目录,然后单击选择。

  • Note: In the below screenshots, it shows the server name as Windows2k16-1. However, all steps remain the same.

    注意:在以下屏幕截图中,它显示的服务器名称为Windows2k16-1。 但是,所有步骤均保持不变。

Windows Server 2016上SQL Server Always On可用性组的全面指南

It shows up the start disk to configure the virtual machine.

它显示了用于配置虚拟机的启动磁盘。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Click Start, and it starts to create the process of the virtual machine.

单击“开始”,它开始创建虚拟机的进程。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Choose the language, Time & currency format, and keyboard type. By default, it takes the input as per your system configuration. You can change these values if required.

选择语言,时间和货币格式以及键盘类型。 默认情况下,它根据系统配置接受输入。 您可以根据需要更改这些值。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Click Next and Install now to begin Windows configuration for SQL Server Always On Availability group.

单击“下一步”,然后单击“立即安装”以开始Windows配置SQL Server Always On可用性组。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Windows Server 2016 ISO involves the following operating systems.

Windows Server 2016 ISO涉及以下操作系统。

  • Windows Server 2016 standard evaluation edition

    Windows Server 2016标准评估版
  • Windows Server 2016 standard evaluation edition (desktop experience)

    Windows Server 2016标准评估版(桌面体验)
  • Windows Server 2016 datacenter evaluation edition

    Windows Server 2016数据中心评估版
  • Windows Server 2016 datacenter evaluation edition(desktop experience)

    Windows Server 2016数据中心评估版(桌面体验)

If we choose edition without desktop edition, it comes without a GUI. You can connect with command-line tools such as CMD, PowerShell to perform your stuff on it. You should be good with the PowerShell or scripting in this case.

如果我们选择不带桌面版的版本,则它GUI。 您可以连接命令行工具(例如CMD,PowerShell)在其中执行您的工作。 在这种情况下,您应该熟练使用PowerShell或脚本。

For this article, we install Windows Server 2016 standard edition with the desktop experience.

对于本文,我们将安装具有桌面体验的Windows Server 2016标准版。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Accept notice and license terms.

接受通知和许可条款。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Select the installation type.

选择安装类型。

  • Upgrade: Install Windows. Keep files, applications, and settings

    升级:安装Windows。 保留文件,应用程序和设置
  • Custom: Install Windows only

    自定义:仅安装Windows

We require a fresh Windows installation; therefore, select the second option and proceed.

我们需要全新的Windows安装; 因此,选择第二个选项并继续。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Select the root operating system directory. In our case, we have a single drive in the virtual machine. By default, it is available for all installation.

选择根操作系统目录。 在我们的例子中,虚拟机中只有一个驱动器。 默认情况下,它可用于所有安装。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Click Next, and it starts the Windows operating system, with default programs and features.

单击“下一步”,它将使用默认程序和功能启动Windows操作系统。

Windows Server 2016上SQL Server Always On可用性组的全面指南

After the Windows installation, it automatically reboots the virtual machine.

Windows安装后,它将自动重新引导虚拟机。

Windows Server 2016上SQL Server Always On可用性组的全面指南

After reboot, once it comes up, it asks you to configure a password for the default administrator user. We do not have any domain for this virtual machine. Therefore, we will use this user to login to the system.

重新启动后,一旦启动,它会要求您为默认管理员用户配置密码。 我们没有此虚拟机的任何域。 因此,我们将使用该用户登录系统。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Finish the installation process and login with the administrator user credentials set above.

完成安装过程,并使用上面设置的管理员用户凭据登录。

Windows Server 2016上SQL Server Always On可用性组的全面指南

It configures your Windows systems for the first time startup. You can see that VM is part of a workgroup. We will add the domain for this server later.

它将配置您的Windows系统,以便首次启动。 您可以看到VM是工作组的一部分。 我们稍后将为该服务器添加域。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Open the command prompt and check the IP configuration of this server using the ipconfig command.

打开命令提示符,然后使用ipconfig命令检查此服务器的IP配置。

Windows Server 2016上SQL Server Always On可用性组的全面指南

Follow the above steps and prepare the below specified virtual machines.

请执行上述步骤,并准备以下指定的虚拟机。

  • SQLNode1: It is the first node for SQL Server Always On Availability group

    Windows Server 2016上SQL Server Always On可用性组的全面指南

    SQLNode1 :它是“ SQL Server始终可用”组的第一个节点

  • SQLNode2: It is the second node for SQL Server Always On Availability group

    Windows Server 2016上SQL Server Always On可用性组的全面指南

    SQLNode2:这是“ SQL Server始终可用”组的第二个节点

  • VDITest3(DC): This server serves as a domain controller and active directory

    Windows Server 2016上SQL Server Always On可用性组的全面指南

    VDITest3(DC):此服务器充当域控制器和活动目录

VirtualBox中虚拟机的网络配置 (Network configurations for the Virtual machine in VirtualBox)

By default, a virtual machine is configured for the Network Address Translation (NAT). In a NAT configuration, usually, a firewall assigns a public address to the VM inside the private network. To view the network configuration, go to the VirtualBox, right-click on it and view Settings -> Network.

默认情况下,为网络地址转换(NAT)配置一个虚拟机。 通常,在NAT配置中,防火墙将专用地址分配给专用网络内的VM。 要查看网络配置,请转到VirtualBox,右键单击它并查看Settings- > Network

Windows Server 2016上SQL Server Always On可用性组的全面指南

Modify the network adapter from NAT to Bridged adapter. In the bridged adapter, select the ethernet adapter.

将网络适配器从NAT修改为桥接适配器。 在桥接适配器中,选择以太网适配器。

Windows Server 2016上SQL Server Always On可用性组的全面指南

You can also configure multiple network adapters in a VM. For example, in my case, I have an internet connection using Wi-fi. To use the internet on VM as well, I configured the second adapter for all VM’s as shown below.

您还可以在一个VM中配置多个网络适配器。 例如,在我的情况下,我使用Wi-fi连接了互联网。 为了同时在VM上使用Internet,我为所有VM配置了第二个适配器,如下所示。

Windows Server 2016上SQL Server Always On可用性组的全面指南

结论 (Conclusion)

In this article, we configured Oracle Virtual machine and prepared three VM’s. We will use these VM’s in the subsequent articles for configuration of SQL Server Always On Availability Groups.

在本文中,我们配置了Oracle虚拟机并准备了三个VM。 在后续文章中,我们将使用这些VM来配置SQL Server Always On可用性组。

目录 (Table of contents)

A comprehensive guide to SQL Server Always On Availability Groups on Windows Server 2016
Configure Domain Controller and Active Directory for SQL Server Always On Availability Groups
Configure failover clusters, storage controllers and quorum configurations for SQL Server Always On Availability Groups
Install SQL Server 2019 on Windows Server 2016 with SQL Server Always On Availability Groups
Add a new node into existing SQL Server Always On Availability Groups
Configure Managed Service Accounts for SQL Server Always On Availability Groups
Windows Server 2016上SQL Server Always On可用性组的全面指南
为SQL Server Always On可用性组配置域控制器和Active Directory
为SQL Server Always On可用性组配置故障转移群集,存储控制器和仲裁配置
在Windows Server 2016和SQL Server Always On可用性组上安装SQL Server 2019
将新节点添加到现有SQL Server Always On可用性组中
为SQL Server Always On可用性组配置托管服务帐户

翻译自: https://www.sqlshack.com/a-comprehensive-guide-to-sql-server-always-on-availability-groups-on-windows-server-2016/