SQL Server 2019 AlwaysOn Installation

Preparation

1. Two DB servers (mine are Dynamics-DB01 and Dynamics-DB02).

2. A quorum witness server (a server independent of the database cluster server, providing file sharing witness, mine is Dynamics-SAS).

3. Five IPs (one for each of the two DB servers, one for the cluster, one for the arbitration server, and one for the listening IP).

4. Related SQL Server installation packages.

5. Be sure to ensure that the SQL Server is the Enterprise Edition (Enterprise) or the Developer Edition (Developer), otherwise some high-availability configurations cannot be used. (https://learn.microsoft.com/zh-cn/sql/sql-server/editions-and-components-of-sql-server-2019?view=sql-server-ver16)

注意:下面演示的侦听器名称"CRMDBLISTENER"和群集名称"CRMDBCLUSTER"很相似,配置的时候不要弄混了。

Install the cluster

Add failover clusters and related configurations to the Dynamics-DB01 and Dynamics-DB02 servers respectively.

The specific configuration is as shown in the figure below:
Click to add roles and functions
insert image description here

In select features, add failover cluster
insert image description here

Once added, select Failover Cluster Manager in Tools
insert image description here

configure cluster

After opening the failover cluster manager in one of the DB servers, click "Verify Configuration" in the red box below (which one is used to configure, which one is the master server, I use Dynamics-DB01, configure the one is fine)

insert image description here

The configuration is as shown below
insert image description here

Choose to run all tests

insert image description here
Tick ​​"Create cluster now using verified nodes".
insert image description here

Enter the cluster name "CRMDBCLUSTER"
IP address I set it as 192.168.1.143

insert image description here

uncheck"Add all eligible storage to the cluster", the next step until the completion (please ensure that the current domain user is used to create, and the current domain user has the right to create computer objects on the domain controller)

insert image description here

Right click - more operations - configure cluster quorum settings, as shown in the figure below
insert image description here

Choose a quorum witness
insert image description here

Select Configure File Share Witness
insert image description here

Here, log in to our quorum witness server Dynamics-SAS, and create a folder, which I created as "SQLServerAlwaysOnShareFolder"

insert image description here

Right click folder - share - specific user

insert image description here

Add "Everyone" permission level set to "Read/Write", click the share button
insert image description here

Record the path of the shared folder, as shown below
insert image description here

Now go back to configure the cluster quorum server and fill in the shared folder path to the file share path. (You can also click Browse to select the corresponding shared folder server)

insert image description here

Next, click Finish.

insert image description here

Open Failover Cluster Manager -> right click and select properties

insert image description here

Click on "Manage Core Cluster Resource Groups"

insert image description here

Adjust failover time and times as needed

insert image description here

Install SQL Server

Select a new SQL Server independent installation, as shown in the figure below (both DB servers need to be installed)

insert image description here

Select all functions, remove unnecessary parts, Reporting Service will not be installed for the time being

insert image description here
Configure related services as specified domain users

insert image description here

option mixed mode, and add current user

insert image description here

add current user

insert image description here

insert image description here

After the addition is complete, the next step is to install
. After the installation is complete, set the startup type of the SQL Server Agent service to automatic (if it has been set during installation, this step can be ignored)

insert image description here

If you need report service, you can install Reporting Service on any DB server. The server I chose is Dynamics-DB01

insert image description here

It is used when installing SSMS on the two DB servers for subsequent configuration related information.

insert image description here
insert image description here

Configure Always On

Open SQL Server Configuration Manager
insert image description here

Right-click SQL Server (MSSQLSERVER) as shown in the figure below, and click Properties.
insert image description here

To enable the high availability group, both DB servers need to be started, and restart the service after startup.
insert image description here

The requirements for supporting the AlwaysOn database are
(1) the recovery mode of the database must be the "full" recovery mode
(2) the database has been fully backed up
(3) it needs to be a user library, and the system library cannot be added to the availability group
(4) the database can be read Write, read-only libraries cannot be added to the availability group
(5) the database is in multi-user mode
(6) the database does not use AUTO_CLOSE
(7) does not belong to any other availability group
(8) the database is not configured with database mirroring

Because the above requirements need to be met, we can perform the following operations.
Log in to any database and open SQL Server Management Studio
to execute the following statement

CREATE DATABASE [test] go

USE [test]
CREATE TABLE [test]([id] INT,[name] VARCHAR(100))
INSERT INTO [test] SELECT 1,'test'

DECLARE @CurrentTime VARCHAR(50), @FileName VARCHAR(200)
SET @CurrentTime = REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 120 ),'-','_'),' ','_'),':','')
    
--(test 数据库完整备份)
SET @FileName = 'C:\test_FullBackup_' + @CurrentTime+'.bak'
BACKUP DATABASE [test]
TO DISK=@FileName WITH FORMAT ,COMPRESSION

  --(test 数据库日志备份) 
SET @FileName = 'C:\test_logBackup_' + @CurrentTime+'.bak'
BACKUP log [test]
TO DISK=@FileName WITH FORMAT ,COMPRESSION

insert image description here

Right-click on the "Alwayson High Availability" node in SQL Server Management Studio and select "New Availability Group Wizard

insert image description here

Enter an availability group name
insert image description here

Select the created test library
insert image description here

Click "Add Copy"

insert image description here
update secondary replicas, readable secondary replicas to yes

insert image description here

Select the endpoint and change the URL to the IP address

insert image description here
Select "Full database and log backup" and enter the share path

insert image description here
Next step until complete

insert image description here

Right-click the newly added availability group "SQLAG" and select properties
insert image description here
to change the availability mode to "synchronous commit" and the failover mode to "automatic"

insert image description here
Now the database test of Dynamics-DB01 and Dynamics-DB02 has synchronized
insert image description here
the availability group listener right-click to add the listener

insert image description here
Select network mode to add port number for "Static IP"
(mine is 1433), add static IP address (mine is 192.168.1.123), add listener DNS name (mine is CRMDBLISTENER)

insert image description here
Make sure that the virtual server of the cluster "CRMDBCLUSTER" has the permission to create computer objects. If not, you need to add the administrator group to the virtual machine; if the DNS record is not automatically created, you need to create it manually.
insert image description here
insert image description here

Configure Reporting Services

Open the Reporting Services Configuration Manager for the report server and click Connect

insert image description here

Click on the web service URL, click on Apply
insert image description here
click on the database select "Change Database"
insert image description here
select to create a new report server database

insert image description here
Enter the listening name CRMDBLISTENER configured in the process of configuring ALWAYSON, and click Next after the test passes

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/tantu666/article/details/128222400