You are on page 1of 71

SQL Server

DBA Co-op Project


(Group 2)
(Requirement 2.4:
SQL Server 2017 for Upgrade & Migration)

Jay Liu
E: LJJYX@yahoo.com C: 647-833-5887

1
2.4c Synchronization SQL Server 2017

2.4c.1 Setup AlwaysOn Environment


1. List of environment and pre-checking
2. Configure Quorum, Backup Folder and Recovery Mode
3. Add Failover Feature and create cluster into Server

2.4c.2 AlwaysOn
1. Enable AlwaysOn
2. Prepare AlwaysOn Database Orders
3. Setup Replicas
4. Configure Failover Cluster (Manual Failover)
5. Testing Failover (Auto Failover)
6. Remove AlwaysOn

2
2.4c.1.1. List of environment and pre-checking:

1. Failover Cluster Sever Group


PROD-PP-1216 and RPT-DR-1216

2. Failover Availability Instances:


PROD-PP-1216\SQL2017PRD and
RPT-DR-1216\SQL2017DR

3. AlwaysOn Database: [Orders]

4. Cluster Quorum(shared): \\DC\QuorumShare

5. Shared AlwaysOn Database Folder:


\\PROD-PP-1216\SQL2017PRD

3
2.4c.1.1. List of environment and pre-checking:

- Check, make sure Windows firewall are turned off in both PRD-PP-1216 and
RPT-DR-1216 servers:

4
2.4c.1.1. List of environment and pre-checking:

- Check, make sure Named Pipes and TCP/IP are enabled in both instance
SQL2017PRD and SQL2017DR instance:

5
2.4c.1.1. List of environment and pre-checking:
- Check, database [Orders]:Recovery model  Full / Compatibility level  SQL
Server 2017(140)
- Check, database [Orders] is not attached in RPT-DR-1216\SQL2017DR

6
2.4c.1.2. Configure Quorum, Backup Folder and Recovery Mode
- Quorum is a configuration database accessible to all nodes on a shared location.
- Create [QuorumShare] folder on DC > properties > [Sharing] Tab > give full
control to [Everyone] > Add [SQL2K8\Administrator]

7
2.4c.1.2. Configure Quorum, Backup Folder and Recovery Mode
- Give [Change] and [Read] permission to [SQL2K8\Administrator]

8
2.4c.1.2. Configure Quorum, Backup Folder and Recovery Mode
- On PRD-PP-1216, use [SQL2017PRD] folder under C: drive
- Share out C:\ SQL2017PRD with proper permissions:​
Everyone with [Read​], [Read & execute], [List folder contents]

9
2.4c.1.2. Configure Quorum, Backup Folder and Recovery Mode
- In RPT-DR-1216 C:\ Drive, create folder SQL2017PRD with 3 subfolders -
Backup, Data, Log.

10
2.4c.1.3. Add Failover Feature and create cluster into Server
Install Failover Cluster feature in both PROD-PP-1216 and RPT-DR-1216:
- Open Server Manager
- Under [Manage] click [Add Roles and Features]

11
2.4c.1.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Select destination server

12
2.4c.1.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Take the default server roles selection > Next

13
2.4c.1.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Select [Failover Clustering] > Add Features > Next

14
2.4c.1.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Allow server restarts automatically > Install

15
2.4c.1.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Allow the feature installing > Close after installed
- Repeat the steps above to install the Feature in RPT-DR-1216

16
2.4c.1.3. Add Failover Feature and create cluster into Server
Before creating cluster, log off and log in with SQL2K8\Administrator
- [Server Manager] > [Tools] > [Failover Cluster Manager]

17
2.4c.1.3. Add Failover Feature and create cluster into Server
- Right click [Failover Cluster Manager] > Create Cluster
- Follow the Wizard > Next

18
2.4c.1.3. Add Failover Feature and create cluster into Server
- Browse two servers PROD-PP-1216 and RPT-DR-1216
- Following Wizard > Next > Agree to run the test
- Following Wizard > Next > Agree you have local admin permission

19
2.4c.1.3. Add Failover Feature and create cluster into Server
- Take the default selection Yes to run configuration validation tests > Next
- Following Wizard > Next

20
2.4c.1.3. Add Failover Feature and create cluster into Server
- Following the Wizard > Next > Run all tests
- Following the Wizard > Next > Ready to start the validation

21
2.4c.1.3. Add Failover Feature and create cluster into Server
- Ignore warnings during the validation, let the test running
- When you see [Failover Cluster Validation Report] > Finish

22
2.4c.1.3. Add Failover Feature and create cluster into Server
- Before creating the cluster, need to make sure VM using Domain IP address
starting with 10.10.10.xx instead of its own IP address: 192.168.xx.xx
- Go to [Control Panel] > [Network and Sharing Center] > [Change adapter
settings] > Disable Ethernet 2 and Ethernet 3

23
2.4c.1.3. Add Failover Feature and create cluster into Server
- Create cluster name: [AG_Cluster]
- Network: 10.10.10.0/24, Address: 10.10.10.33
- 2 Nodes: PROD-PP-1216 and RPT-DR-1216
- NOTE: if IP address showing 192.168.xx.xx, make sure Ethernet 2 and
Ethernet 3 are disabled, cancel the wizard and recreate the cluster again.

24
2.4c.1.3. Add Failover Feature and create cluster into Server
- Cluster [AG_Cluster] is created

25
2.4c.1.3. Add Failover Feature and create cluster into Server
- In [AG_Cluster], the Witness is None
- Need to use the [QuorumShare] we created on DC to configure the Witness

26
2.4c.1.3. Add Failover Feature and create cluster into Server
- [AG_Cluster.SQL2K8.com] > right click > More Action > Configure Cluster
Quorum Setting
- Following the Wizard > Next

27
2.4c.1.3. Add Failover Feature and create cluster into Server
- In Select Quorum Configuration Option > choose the radio button [Select the
quorum witness] > choose radio button [Configure a file share witness]

28
2.4c.1.3. Add Failover Feature and create cluster into Server
- Type in the path [\\DC\QuorumShare] > Next > Finished

29
2.4c.1.3. Add Failover Feature and create cluster into Server
- When finish the configuration, the Witness will show as [\\DC\QuorumShare]
- As long as we create in PROD-PP-1216, there is no need to do all steps above
again in RPT-DR-1216

30
2.4c.1.3. Add Failover Feature and create cluster into Server
- Go back to DC, verify the Witness information showing up under the folder
[QuorumShare]

31
2.4c.2. AlwaysOn

We have setup the cluster environment for AlwaysOn, now we


will setup AlwaysOn as followings:

1. Enable AlwaysOn
2. Prepare AlwaysOn Database Orders
3. Setup Replicas
4. Testing Failover

When working on AlwaysOn, we can log back with username:


[SQLDBA1] or [SQLDBA2]

32
2.4c.2.1. Enable AlwaysOn
In PROD-PP-1216\SQL2017PRD and RPT-DR-1216\SQL2017PRD
- Launch SQL Server Configuration Manager

33
2.4c.2.1. Enable AlwaysOn

In [SQL Server Configuration Manager], right click on the SQL2017PRD


instance and choose Properties

34
2.4c.2.1. Enable AlwaysOn
- Go to [AlwaysOn High Availablity] tab
- Enable AlwaysOn
- Restart the instance(Engine and Agent Services)

35
2.4c.2.1. Enable AlwaysOn
- Restart the instance(Engine and Agent Services)
- Do the same thing in [RPT-DR-1216\SQL2017DR] instance

36
2.4c.2.1. Enable AlwaysOn
- In SSMS, [PROD-PP-1216\SQL2017PRD] > right click > properties >
General > HADR is Enabled
- Check the same for [RPT-DR-1216\SQL2017DR] instance

37
2.4c.2.1. Enable AlwaysOn
- Run the script below to check the cluster members:
select * from sys.dm_hadr_cluster_members

38
2.4c.2.2. Prepare AlwaysOn Database Orders
- Create Full Backup in [PROD-PP-1216\SQL2017PRD] with the scripting:
BACKUP DATABASE Orders TO
DISK=‘C:\SQL2017PRD\Backup\Orders.Full.bak’ WITH COMPRESSION
- In [RPT-DR-1216\SQL2017DR], there is no database [Orders] attached

39
2.4c.2.3. Setup Replicas
- In [PROD-PP-1216\SQL2017PRD] > Expand [AlwaysOn High Availability​
] > Right click [Availability Groups] > New Availability Group Wizard

40
2.4c.2.3. Setup Replicas
- Give the group name: [AG-CLUSTER]
- Note: the name is [AG-CLUSTER], different from cluster name:
[AG_Cluster]

41
2.4c.2.3. Setup Replicas
- Check [Orders] for the AlwaysOn database

42
2.4c.2.3. Setup Replicas
- Check [Automatic Failover] > Set [Readable Secondary] to Yes >- Add
Replica

43
2.4c.2.3. Setup Replicas
- Add Replica to [RPT-DR-1216\SQL2017DR] as the secondary from
Network Servers

44
2.4c.2.3. Setup Replicas
- Configure the secondary replica
- Check [Automatic Failover] > Set [Readable Secondary] to Yes

45
2.4c.2.3. Setup Replicas
- Check [Endpoint]

46
2.4c.2.3. Setup Replicas
- Check [Backup Preference], set to [Primary]

47
2.4c.2.3. Setup Replicas
- In [Listener] > Type in Listener DNS Name [AG_LSN_2017] >
Port: 1433 > Add IP Address

48
2.4c.2.3. Setup Replicas
- Add IP Address: 10.10.10.38 > OK

49
2.4c.2.3. Setup Replicas
- Check [Listener] information we entered > Next

50
2.4c.2.3. Setup Replicas
- Select [Full database and log backup] > Browse > select the shared
backup folder path: [\\Prod-pp-1216\SQL2017PRD\Backup]

51
2.4c.2.3. Setup Replicas
- Check the [Validation] page > Next

52
2.4c.2.3. Setup Replicas
- [Finish] the setup

53
2.4c.2.3. Setup Replicas
- Install successfully and [Close] the wizard

54
2.4c.2.3. Setup Replicas
- Refresh and check AlwaysOn for database [Orders] on both PROD-PP-
1216 and RPT-DR-1216

55
2.4c.2.3. Setup Replicas
- Check from [Failover Cluster Manager], see the information from [Roles]

56
2.4c.2.3. Setup Replicas
- Check from [Failover Cluster Manager], see the information from
[Nodes]

57
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- In [PROD-PP-1216] SSMS, right click [AG-Cluster] > Failover > Next

58
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- Select [RPT-DR-1216\SQL2017DR] as new Failover Primay > Next

59
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- Connect to [RPT-DR-1216\SQL2017DR] as Failover availability replica
- Before making this configuration, need to login with
[SQL2K8\Administrator], or any logins which have [sysadmin] role in
[RPT-DR-1216\SQL2017DR]

60
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- Connect to [RPT-DR-1216\SQL2017DR] with [SQL2K8\Administrator] as
login

61
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- Verified the information and [Finish] the configuration

62
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- Completed successfully and [Close] the configuration

63
2.4c.2.4. Configure Failover Cluster (Manual Failover)
- After the configuration, we can see the Primary failover from [PROD-PP-
1216\SQL2017PRD] to [RPT-DR-1216\SQL2017DR]

64
2.4c.2.5. Testing Failover (Auto Failover)
- Pause the VM [PROD-PP-1216] and check [RPT-DR-1216\SQL2017DR]
- AG-Cluster in SQL2017DR change the status from [Resolving] to [Primary]

65
2.4c AlwaysOn
We are done for the AlwaysOn configuration
and tested failover, and it works as expected.​

66
2.4c.2.6 Remove AlwaysOn
- Now we practice to remove the AlwaysOn availability group [AG-
CLUSTER]

It’s better to delete from
the primary side.

67
2.4c.2.6 Remove AlwaysOn
- Click [OK] to remove the AlwaysOn availability group [AG-CLUSTER]

68
2.4c.2.6 Remove AlwaysOn
Refresh [PROD-PP-1216\SQL2017PRD] and [RPT-DR-1216\SQL2017DR]
- AlwaysOn was deleted.
- On [RPT-DR-1216\SQL2017DR] side, the database [Orders] still in
[Restoring…] status
- Need to restore database [Orders] on server [RPT-DR-1216\SQL2017DR]

69
2.4c.2.6 Remove AlwaysOn
- To restore database [Orders] on server [RPT-DR-1216\SQL2016DR], use
the scripting below:
USE master
GO
RESTORE DATABASE Orders
- After the database [Orders] restored, we can safely detached it from [RPT-
DR-1216\SQL2016DR]

70
Q&A

Thanks and See You Next Time

71

You might also like