300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 配置SQL Server AlwaysOn高可用性组

配置SQL Server AlwaysOn高可用性组

时间:2019-05-13 23:59:23

相关推荐

配置SQL Server AlwaysOn高可用性组

In this article, we will learn the step by step configuration of SQL Server AlwaysOn High availability Group for two nodes. Once nodes are added to the cluster group, we will able to use the AlwaysOn feature in the SQL server.

在本文中,我们将学习两个节点SQL Server AlwaysOn高可用性组的分步配置。 将节点添加到群集组后,我们将能够使用SQL Server中的AlwaysOn功能。

In the following steps, we will create a Service account to connect SQL server instances. The Service account will be used to connect the SQL instance from both the node servers.

在以下步骤中,我们将创建一个服务帐户来连接SQL Server实例。 服务帐户将用于从两个节点服务器连接SQL实例。

创建服务帐户 (Create a Service Account)

We will log in to the Domain controller and perform the following steps.

我们将登录到域控制器并执行以下步骤。

OpenServer Manager,Toolsand ClickActive Directory Users and Computers.

打开服务器管理器工具,然后单击“Active Directory用户和计算机”

In Active Directory Users and Computers window,Right-Click Users > New > Useras shown in the following Fig.

在“ Active Directory用户和计算机”窗口中,右键单击“用户”>“新建”>“用户”,如下图所示。

In this step, we will create a Service account username, Specify the service account login name and Click Next

在此步骤中,我们将创建一个服务帐户用户名,指定服务帐户登录名,然后单击“下一步”。

Specify a Password and tick the options forUser cannot change passwordandPassword never expires. We need to selectPassword never expiresoption because, if the password expired, the service account login would fail, and it will cause a problem to the high availability configuration.

指定密码,然后勾选“用户无法更改密码密码永不过期”选项。 我们需要选择“密码永不过期”选项,因为如果密码过期,则服务帐户登录将失败,这将对高可用性配置造成问题。

ClickFinishto complete the service account creation process.

单击完成以完成服务帐户创建过程。

配置管理员权限,Windows用户和服务帐户的登录名 (Configure Administrator permission, windows user and login for the service account)

Once the Service account created on the Domain controller, we need to add service account as a member of the administrator account on both nodes.

在域控制器上创建服务帐户后,我们需要在两个节点上将服务帐户添加为管理员帐户的成员。

Connect to both node servers SQL1 and SQL2 and perform below steps

连接到两个节点服务器SQL1和SQL2并执行以下步骤

Add Service account as an Administrator 将服务帐户添加为管理员 Create a Windows user for the Service account 为服务帐户创建Windows用户 Create a Windows authentication login for a service account login in the SQL database instance 在SQL数据库实例中为服务帐户登录创建Windows身份验证登录

OpenServer managerand SelectToolsandComputer Management

打开服务器管理器,然后选择“工具计算机管理”

Inthe Computer management window, SelectGroupsand Right-ClickAdministratorsand Go toProperties

“计算机管理”窗口中,选择“组”,然后右键单击“管理员”,然后转到“属性”。

AddUser, Enter the Service account login name and Check names and ClickOK

添加用户,输入服务帐户登录名和检查名称,然后单击确定

Note –Once clicked on the Check Names, it may ask to enter username and password pop-up window. In the pop-up window, we need to register a domain controller username and password and make sure the location should select as a directory.

注–单击“检查名称”后,可能会要求输入用户名和密码弹出窗口。 在弹出窗口中,我们需要注册域控制器的用户名和密码,并确保将位置选择为目录。

In the following Fig. We will create the Service account as a windows user inControl Panel > User Account > Click on Manage User Accounts.

在下图中。我们将在控制面板>用户帐户>单击管理用户帐户中以Windows用户身份创建服务帐户

Enter aService account nameanddomain nameand ClickNext, SelectAdministratorand Finish

输入服务帐户名域名,然后单击“下一步”,选择“管理员”并单击完成”。

Next, we will create a windows authentication login for the service account as shown in the following fig.

接下来,我们将为服务帐户创建Windows身份验证登录名,如下图所示。

Take remote desktop connection of SQL1 with the service account windows user, connect to the SQL Server database engine instance SQL1 with default windows authentication login as shown in the following fig.

使用服务帐户Windows用户进行SQL1的远程桌面连接,并使用默认的Windows身份验证登录名连接到SQL Server数据库引擎实例SQL1,如下图所示。

启用AlwaysOn功能 (Enable AlwaysOn Feature)

Once SQL Server instance is connected, we need to decide database which will take part in SQL Server AlwaysOn High Availability.

连接SQL Server实例后,我们需要确定将要加入SQL Server AlwaysOn高可用性的数据库。

In this demonstration, we will create a new databaseSTUDENT, and then we will create a table and add a few records into it as shown in the following fig.

在此演示中,我们将创建一个新的数据库STUDENT,然后将创建一个表并向其中添加一些记录,如下图所示。

Next, Expand SQL Server AlwaysOn High Availability option, we will get an error while expanding the AlwaysOn option

接下来,展开“ SQL Server AlwaysOn高可用性”选项,在扩展“ AlwaysOn”选项时会出现错误

The AlwaysOn feature must be enabled for the server instance ‘SQL1’ before you can create an availability group on this instance. To enable AlwaysOn, open the SQL Server Configuration Manager, select SQL Server Services, right-click the SQL Server instance name, select Properties, and use the AlwaysOn High Availability tab of the SQL Server Properties dialog. (ObjectExplorer)

必须先为服务器实例“ SQL1”启用AlwaysOn功能,然后才能在该实例上创建可用性组。 若要启用AlwaysOn,请打开SQL Server配置管理器,选择SQL Server服务,右键单击SQL Server实例名称,选择“属性”,然后使用“ SQL Server属性”对话框的AlwaysOn高可用性选项卡。 (对象浏览器)

To enable AlwaysOn feature,Open SQL Server Configuration Manager,Right-click SQL Server instanceandgo to properties, SelectAlwaysOn High Availability tab sectionand tick checkbox forEnable AlwaysOn AvailabilityGroups

要启用AlwaysOn功能,请打开SQL Server配置管理器右键单击SQL Server实例转到属性,选择AlwaysOn高可用性选项卡部分,然后选中启用AlwaysOn AvailabilityGroups复选框。

Note: –We also need to make sure nodes where we will enable AlwaysOn feature is part of Windows Failover Cluster.

注意:–我们还需要确保要启用AlwaysOn功能的节点是Windows故障转移群集的一部分。

Once we enabled, Apply and ClickOK. Restart the SQL Server services.

启用后,应用并单击确定。 重新启动SQL Server服务。

As shown in the following fig. we will able to use SQL Server AlwaysOn High Availability feature. Right-clickAvailability Groupsand ClickNew Availability Group.

如下图所示。 我们将能够使用SQL Server AlwaysOn高可用性功能。 右键单击可用性组,然后单击新建可用性组

配置可用性组 (Configuring Availability Group)

An AlwaysOn Availability Group contains a set of user databases; we need to select user databases which will be part of the Availability group. These databases called as an Availability database.

AlwaysOn可用性组包含一组用户数据库。 我们需要选择将成为“可用性”组一部分的用户数据库。 这些数据库称为可用性数据库。

SpecifyAvailability Group nameand clickNext

指定可用性组名称,然后单击下一步。

As shown in fig. we will use databaseSTUDENT. To proceed further, we need to perform one essential pre-requisite step, a Full backup of the database. So, take a Full backup of STUDENT and clickNext

如图所示。 我们将使用数据库STUDENT。 要进一步进行操作,我们需要执行一个基本的先决条件步骤,即数据库的完整备份。 因此,请对学生进行完整备份,然后单击“下一步”。

Next,Specify Replicastep has four sections.Replica, Endpoint, Backup Preferences, and Listener

接下来,“指定副本”步骤包含四个部分。副本,端点,备份首选项和侦听器

Replica–Replica isa server. There are one primary replica and multiple replicas. In SQL server , It supports up to 4 secondary replicas, while in SQL Server , it supports up to 8 replicas.

Replica-副本一台服务器。 有一个主副本和多个副本。 在SQL Server 中,它最多支持4个辅助副本,而在SQL Server 中,它最多支持8个副本。

The primary replica is primary source server or production server. A secondary replica is a server which maintain a backup copy of the primary server availability database. On the Primary replica, it allows to perform Read and write operations while on the secondary replica only read operations.

主副本是主源服务器或生产服务器。 辅助副本是一台服务器,用于维护主服务器可用性数据库的备份副本。 在主副本上,它允许执行读取和写入操作,而在辅助副本上,只能执行读取操作。

In this case, SQL1 is our primary replica and SQL2 is a secondary replica. So, we will add SQL2 as a secondary replica as shown in the following fig.

在这种情况下,SQL1是我们的主副本,SQL2是辅助副本。 因此,我们将添加SQL2作为辅助副本,如下图所示。

Initial Role– It specifies the role of replica whether Primary or secondary.

初始角色–指定副本的角色,无论是Primary还是secondary

Automatic Failover– It failovers functional role from primary replica to secondary replica by an automated method with no data loss.

自动故障转移–通过自动方法将功能角色从主副本故障转移到辅助副本,而不会丢失数据。

Synchronous Commit –In the Synchronous-commit mode, failover can happen by either Automatic or manual way with no data loss.So, in this case, we will use synchronous commit with automatic failover.

同步提交–在同步提交模式下,可以通过自动或手动方式进行故障转移,而不会丢失数据。因此,在这种情况下,我们将使用具有自动故障转移功能的同步提交。

Once clickedAdd Replica, connect to the server, Select SQL2 and Connect

单击添加副本后,连接到服务器,选择SQL2并连接

Once we add secondary server SQL2 as a secondary replica, the primary role of SQL2 is secondary.

一旦将辅助服务器SQL2添加为辅助副本,SQL2的主要角色就是辅助角色。

In the Endpoint section, it will show configured endpoint URL, port, endpoint name, and the service account name for SQL1 and SQL2 nodes.

在“端点”部分,它将显示为SQL1和SQL2节点配置的端点URL,端口,端点名称和服务帐户名称。

Backup Preferences –Backup preferences indicate the backup location oftheavailability group.It provides four backup options.

备份首选项–备份首选项指明了备份位置可用性组。它提供了四个备份选项。

Prefer Secondary– Automatic backup will occur on a secondary replica首选二级-自动备份将在二级副本上进行Secondary only– Automatic backup must occur on a secondary replica仅辅助数据库–必须在辅助副本上进行自动备份Primary– Automatic backup must occur on a primary replica-自动备份必须在主副本上进行Any Replica– Backup will occur on any replica任何副本–备份将在任何副本上进行

On the secondary replica, we can only take a log backup, and Copy-only backup, Differential, and Full back up are not allowed on a secondary replica. While on the primary replica, we can perform Full, log, and Differential backups.

在辅助副本上,我们只能进行日志备份,并且在辅助副本上不允许仅复制备份,差异备份和完整备份。 在主副本上时,我们可以执行完整,日志和差异备份。

Listener– Listener is a server through which nodes get to communicate with each other. The Listener has all information about availability group. We need to selectCreate an Availability group listeneroption and specify Name, Port and static IP as shown in the following fig.

侦听器–侦听器是一台服务器,节点可通过该服务器相互通信。 侦听器具有有关可用性组的所有信息。 我们需要选择创建可用性组侦听器选项,并指定名称,端口和静态IP,如下图所示。

InData Synchronization step, SelectFullwhere it performs Full and Log backup and puts it into shared location path.

在“数据同步”步骤中,选择“完整”,在该位置执行完整和日志备份,并将其放入共享位置路径。

创建共享位置 (Create a Shared location)

Connect to node SQL1 and choose desired drive location and folder,Right-click folderandGo to Properties,Select Securityand clickShare. It will show a pop-up window to add a user to whom, share permission need to grant.

连接到节点SQL1并选择所需的驱动器位置和文件夹,右键单击文件夹转到属性选择安全性,然后单击共享。 它将显示一个弹出窗口,向其添加需要授予共享权限的用户。

Provide the service account name and ClickAdd; it will show pop-up window to check names, once service account name found in the domain name, clickShare.

提供服务帐户名称,然后单击添加; 它会显示一个弹出窗口以检查名称,一旦在域名中找到服务帐户名,请单击“共享”

Inthe Validation step, SQL Server performs validations against any required actions, and It will provide warning or error messages for missing required steps.

“验证”步骤中,SQL Server对所有必需的操作执行验证,并且它将针对缺少的必需步骤提供警告或错误消息。

It performed all validation steps successfully, and wizard operation completed as shown in the following fig.

它成功执行了所有验证步骤,并且向导操作完成,如下图所示。

After successful completion, we will verify the database at secondary replica SQL2. As we can observe, Database STUDENT is in Synchronizing state, and it is in sync with the primary replica, and we can read data successfully.

成功完成后,我们将在辅助副本SQL2上验证数据库。 如我们所见,Database STUDENT处于同步状态,并且与主副本同步,我们可以成功读取数据。

目录 (Table of contents)

翻译自: /configuring-a-sql-server-alwayson-high-availability-group/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。