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
In select features, add failover cluster
Once added, select Failover Cluster Manager in Tools
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)
The configuration is as shown below
Choose to run all tests
Tick "Create cluster now using verified nodes".
Enter the cluster name "CRMDBCLUSTER"
IP address I set it as 192.168.1.143
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)
Right click - more operations - configure cluster quorum settings, as shown in the figure below
Choose a quorum witness
Select Configure File Share Witness
Here, log in to our quorum witness server Dynamics-SAS, and create a folder, which I created as "SQLServerAlwaysOnShareFolder"
Right click folder - share - specific user
Add "Everyone" permission level set to "Read/Write", click the share button
Record the path of the shared folder, as shown below
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)
Next, click Finish.
Open Failover Cluster Manager -> right click and select properties
Click on "Manage Core Cluster Resource Groups"
Adjust failover time and times as needed
Install SQL Server
Select a new SQL Server independent installation, as shown in the figure below (both DB servers need to be installed)
Select all functions, remove unnecessary parts, Reporting Service will not be installed for the time being
Configure related services as specified domain users
option mixed mode, and add current user
add current user
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)
If you need report service, you can install Reporting Service on any DB server. The server I chose is Dynamics-DB01
It is used when installing SSMS on the two DB servers for subsequent configuration related information.
Configure Always On
Open SQL Server Configuration Manager
Right-click SQL Server (MSSQLSERVER) as shown in the figure below, and click Properties.
To enable the high availability group, both DB servers need to be started, and restart the service after startup.
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
Right-click on the "Alwayson High Availability" node in SQL Server Management Studio and select "New Availability Group Wizard
Enter an availability group name
Select the created test library
Click "Add Copy"
update secondary replicas, readable secondary replicas to yes
Select the endpoint and change the URL to the IP address
Select "Full database and log backup" and enter the share path
Next step until complete
Right-click the newly added availability group "SQLAG" and select properties
to change the availability mode to "synchronous commit" and the failover mode to "automatic"
Now the database test of Dynamics-DB01 and Dynamics-DB02 has synchronized
the availability group listener right-click to add the listener
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)
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.
Configure Reporting Services
Open the Reporting Services Configuration Manager for the report server and click Connect
Click on the web service URL, click on Apply
click on the database select "Change Database"
select to create a new report server database
Enter the listening name CRMDBLISTENER configured in the process of configuring ALWAYSON, and click Next after the test passes